-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
74 lines (60 loc) · 1.93 KB
/
SConstruct
File metadata and controls
74 lines (60 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import itertools
import operator
import pathlib
import os.path
import contextlib
import traceback
import jinja2
from util import noisy, parse_yaml
AddOption(
'--draft',
action='store_true',
help='Build in draft form'
)
AddOption(
'--inline-verses',
action='store',
default=3,
type=int,
help='Number of verses to place inline'
)
AddOption(
'--twoup',
action='store_true',
help='Build in 2up form'
)
root = Dir('.').srcnode().abspath
jinja_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(pathlib.Path(root)),
autoescape=jinja2.select_autoescape()
)
calendar = File(str(pathlib.Path(root) / 'calendar.yaml'))
env = Environment(BUILDERS={
'TwoUp': Builder(
action="pdfjam --nup 2x1 --landscape --clip true --outfile $TARGET $SOURCE"
)
},
tools=['default', 'lilypond', 'jinja', 'geometry'],
ROOT=root,
FULLDIR=Dir('full'),
SINGLEDIR=Dir('single'),
BODYDIR=Dir('body'),
MUSICDIR=Dir('music'),
TEMPLATEDIR=Dir('templates'),
jinja_env=jinja_env,
num_inline_verses=GetOption('inline_verses'),
DRAFT=GetOption('draft'))
env.Append(TEXINPUTS=str(pathlib.Path(root) / 'texmf' / 'tex' / 'latex'))
@noisy()
def Render(env, target_name, template_name, data):
template = env['jinja_env'].get_template(str(template_name))
rendered = template.render(**data)
pathlib.Path(str(target_name)).write_text(rendered)
return env.File(target_name)
AddMethod(env, Render)
@noisy()
def FindTemplate(env, fname):
return env.FindFile(fname, env['TEMPLATEDIR'])
AddMethod(env, FindTemplate)
Decider('timestamp-match')
env.SConscript(['$FULLDIR/SConscript', '$SINGLEDIR/SConscript', '$BODYDIR/SConscript', '$MUSICDIR/SConscript'], exports='env')