-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwscript
executable file
·112 lines (80 loc) · 3.3 KB
/
wscript
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
import os
top='.'
#-quiet
def options(opt):
opt.load('tex')
opt.add_option('--prompt-level', default=0,
help="pdfLaTeX prompt level. Set to 1 for debugging.")
def configure(cfg):
# cfg.find_program('dune-params', var='DUNEPARAMS')
cfg.load('tex')
cfg.find_program('chapters.sh', var='CHAPTERS',
path_list=[os.path.realpath(".")])
cfg.env.PDFLATEXFLAGS += ["-file-line-error"]
pass
def build_params(bld):
'''
Build DUNE PARAMS.
'''
paramsxls = bld.path.find_resource('data/parameters.xls')
paramspy = bld.path.find_resource('python/parameters.py')
os.environ['PYTHONPATH'] = paramspy.parent.abspath()
# generate files from parameter templates
for tmpl in bld.path.ant_glob('**/templates/*.tex.j2'):
tmp = tmpl.parent.parent
gen_dir = tmp.make_node('generated')
target = gen_dir.make_node(str(tmpl.change_ext('.tex', '.tex.j2')))
rule='${DUNEPARAMS} render -f parameters.filter -t ${SRC[1].abspath()} -o ${TGT[0].abspath()} ${SRC[0].abspath()}'
bld(rule=rule,
source = [paramsxls, tmpl, paramspy], # last ones just for dependencies
target = target,
shell = True)
def build(bld):
prompt_level = bld.options.prompt_level
#build_params(bld)
# The "DUNE Words" doc is just plopped here and does not provide
# "volume" semantics so we build it special.
bld(features='tex', prompt=prompt_level,
source = 'dune-words.tex',
target = 'dune-words.pdf')
#
# Volumes and their chapters:
#
voltexs = ["executive-summary.tex",
"far-detector-single-phase.tex",
"far-detector-dual-phase.tex",
"software-computing.tex"]
chaptex = bld.path.find_resource("chapters.tex")
volnum = 0
for voltex in voltexs:
volnum += 1
volname = voltex.replace(".tex","")
voldir = bld.path.find_dir(volname)
bld(features='tex', prompt=prompt_level,
source = voltex,
target = voltex.replace(".tex",".pdf"))
bld.install_files('${PREFIX}',voltex.replace(".tex",".pdf"))
#voltit = volname.replace("-"," ").capitalize()
voltit = voltex
for chtex in voldir.ant_glob("**/chapter*.tex"):
chname = os.path.basename(str(chtex))
chmaintex = bld.path.find_or_declare("%s-%s" % (volname, chname))
#chtit = chname.replace(".tex","").replace("-"," ").capitalize()
chtit = chname
bld(source=[chaptex, chtex],
target=os.path.basename(str(chmaintex)),
rule="${CHAPTERS} ${SRC} ${TGT} '%s' '%s' %d" % (voltit, chtit, volnum))
bld(features='tex',
prompt = prompt_level,
source = os.path.basename(str(chmaintex)),
# name target as file name so can use --targets w/out full path
target = os.path.basename(str(chmaintex.change_ext('pdf','tex'))))
bld.install_files('${PREFIX}',chmaintex.change_ext('.pdf', '.tex'))
# bld(features='tex',
# type='pdflatex',
# source = tex,
# outs = 'pdf',
# )
# bld.install_files('${PREFIX}',tex.change_ext('.pdf', '.tex'))
return