8 def verbose_opt (env, opt):
13 srcdir = env['srcdir']
15 def join_path (path, infix=os.pathsep, prefix = ''):
20 return string.join (map (lambda x: prefix + dir (x), path), infix)
22 verbose = verbose_opt (env, ' --verbose')
23 MAKEINFO_INCLUDES = join_path (env['MAKEINFO_PATH'], '', ' -I')
24 MAKEINFO = env['MAKEINFO']
25 a = ('%(MAKEINFO)s%(verbose)s %(MAKEINFO_INCLUDES)s'\
26 ' --no-split --no-headers --output=$TARGET $SOURCE') % vars ()
27 texi2txt = Builder (action = a, suffix = '.txt', src_suffix = '.texi')
28 env.Append (BUILDERS = {'Texi2txt': texi2txt})
31 PYTHON = env['PYTHON']
32 ABC2LY_PY = env['ABC2LY_PY']
33 LILYPOND_PY = env['LILYPOND_PY']
34 LILYPOND_BIN = env['LILYPOND_BIN']
35 LILYPOND_BOOK = env['LILYPOND_BOOK']
36 LILYPOND_BOOK_FLAGS = env['LILYPOND_BOOK_FLAGS']
37 LILYPOND_BOOK_FORMAT = env['LILYPOND_BOOK_FORMAT']
38 LILYPOND_BOOK_INCLUDES = join_path (env['LILYPOND_BOOK_PATH'], '',
40 LILYPONDPREFIX = env['LILYPONDPREFIX']
42 # UGHR, lilypond.py uses lilypond-bin from PATH
43 #env.Append (ENV = {'PATH' : os.environ['PATH']})
44 env.PrependENVPath ('PATH',
45 os.path.join (env['absbuild'], env['out'], 'usr/bin'))
47 if os.environ.has_key ('TEXMF'):
48 env.Append (ENV = {'TEXMF' : os.environ['TEXMF']})
49 env.Append (ENV = {'TEXMF' : '{' + LILYPONDPREFIX + ',' \
50 + os.popen ('kpsexpand \$TEXMF').read ()[:-1] + '}' })
52 if os.environ.has_key ('LD_LIBRARY_PATH'):
53 env.Append (ENV = {'LD_LIBRARY_PATH' : os.environ['LD_LIBRARY_PATH']})
54 if os.environ.has_key ('GUILE_LOAD_PATH'):
55 env.Append (ENV = {'GUILE_LOAD_PATH' : os.environ['GUILE_LOAD_PATH']})
57 env.Append (PYTHONPATH = [os.path.join (env['absbuild'], env['out'],
59 os.path.join (srcdir, 'buildscripts'),
60 os.path.join (srcdir, 'python')])
61 env.Append (ENV = { 'PYTHONPATH' : string.join (env['PYTHONPATH'],
64 verbose = verbose_opt (env, ' --verbose')
65 a = (r'''rm -f $$(grep -LF '\lilypondend' ${TARGET.dir}/lily-*.tex 2>/dev/null); ''' \
66 + 'LILYPONDPREFIX=%(LILYPONDPREFIX)s '\
67 + '%(PYTHON)s %(LILYPOND_BOOK)s%(verbose)s'\
68 + ' --include=${TARGET.dir} %(LILYPOND_BOOK_INCLUDES)s'\
69 + r""" --process='%(LILYPOND_BIN)s %(LILYPOND_BOOK_INCLUDES)s'"""\
70 + ' --output=${TARGET.dir} --format=%(LILYPOND_BOOK_FORMAT)s\
71 %(LILYPOND_BOOK_FLAGS)s\
73 tely2texi = Builder (action = a, suffix = '.texi', src_suffix = '.tely')
74 env.Append (BUILDERS = {'Tely2texi': tely2texi})
76 TEXINFO_PAPERSIZE_OPTION = env['TEXINFO_PAPERSIZE_OPTION']
77 a = '(cd ${TARGET.dir} &&\
78 texi2dvi --batch %(TEXINFO_PAPERSIZE_OPTION)s ${SOURCE.file})' % vars ()
79 texi2dvi = Builder (action = a, suffix = '.dvi', src_suffix = '.texi')
80 env.Append (BUILDERS = {'Texi2dvi': texi2dvi})
82 env.Append (DVIPSFLAGS = '-Ppdf -u+lilypond.map -u+ec-mftrace.map')
84 DVIPS_PAPERSIZE = 'a4'
85 DVIPSFLAGS = env['DVIPSFLAGS']
86 a = ('set -x; dvips %(DVIPSFLAGS)s' \
87 + ' -o ${TARGET}.pdfps'\
88 + ' -t %(DVIPS_PAPERSIZE)s $SOURCE &&'\
89 + ' ps2pdf -sPAPERSIZE=%(DVIPS_PAPERSIZE)s ${TARGET}.pdfps $TARGET') \
91 dvi2pdf = Builder (action = a, suffix = '.pdf', src_suffix = '.dvi')
92 env.Append (BUILDERS = {'Dvi2pdf': dvi2pdf})
94 a = 'convert $SOURCE $TARGET'
95 png2eps = Builder (action = a, suffix = '.eps', src_suffix = '.png')
96 env.Append (BUILDERS = {'Png2eps': png2eps})
98 def add_ps_target (target, source, env):
99 base = os.path.splitext (str (target[0]))[0]
100 return (target + [base + '.ps'], source)
102 #a = ('echo "PATH=$$PATH"; echo "TEXMF=$$TEXMF"; which lilypond-bin;'\
103 a = (' LILYPONDPREFIX=%(LILYPONDPREFIX)s '\
104 + '%(PYTHON)s %(LILYPOND_PY)s%(verbose)s'\
105 + ' --include=${TARGET.dir}'\
106 + ' --output=${TARGET.base}'\
107 + ' $SOURCE') % vars ()
108 lilypond = Builder (action = a, suffix = '.pdf', src_suffix = '.ly')
109 ## emitter = add_ps_target)
110 env.Append (BUILDERS = {'LilyPond': lilypond})
112 #verbose = verbose_opt (env, ' --verbose')
114 a = ('LILYPONDPREFIX=%(LILYPONDPREFIX)s '\
115 + '%(PYTHON)s %(ABC2LY_PY)s%(verbose)s'\
116 # + ' --include=${TARGET.dir}'\
118 + ' --output=${TARGET.base}'\
119 + ' $SOURCE') % vars ()
120 abc2ly = Builder (action = a, suffix = '.ly', src_suffix = '.abc')
121 env.Append (BUILDERS = {'Abc2ly': abc2ly})
124 MFMODE = env['MFMODE']
125 def add_log_target (target, source, env):
126 base = os.path.splitext (str (target[0]))[0]
127 return (target + [base + '.log'], source)
129 def add_enc_ly_tex_target (target, source, env):
130 base = os.path.splitext (str (target[0]))[0]
131 return (target + [base + '.enc', base + '.tex', base + 'list.ly'],
134 def add_suffixes (target, source, env, target_suffixes, src_suffixes):
135 base = os.path.splitext (str (target[0]))[0]
136 return (target + map (lambda x: base + x, target_suffixes),
137 source + map (lambda x: base + x, src_suffixes))
139 scrdir = env['srcdir']
140 a = ('(cd ${TARGET.dir} &&'\
141 + ' MFINPUTS=.:${SOURCE.dir}:%(srcdir)s/${SOURCE.dir}'\
142 + ' mf "\\mode:=%(MFMODE)s; nonstopmode;'\
143 + ' input ${SOURCE.filebase};" ' \
144 + ' | grep -v "@\|>>")') % vars ()
145 tfm = Builder (action = a, suffix = '.tfm', src_suffix = '.mf',
146 # emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
147 emitter = add_log_target)
148 env.Append (BUILDERS = {'TFM': tfm})
150 MF_TO_TABLE_PY = env['MF_TO_TABLE_PY']
151 #verbose = verbose_opt (env, ' --verbose')
153 a = ('%(PYTHON)s %(MF_TO_TABLE_PY)s%(verbose)s'\
154 + ' --outdir=${TARGET.dir}'\
155 + ' --afm=${TARGET.base}.afm' \
156 + ' --enc=${TARGET.base}.enc' \
157 + ' --tex=${TARGET.base}.tex' \
158 + ' --ly=${TARGET.base}list.ly'\
159 + ' ${TARGET.base}.log') % vars ()
160 afm = Builder (action = a, suffix = '.afm', src_suffix = '.log',
161 emitter = add_enc_ly_tex_target)
162 env.Append (BUILDERS = {'AFM': afm})
164 def add_enc_src (target, source, env):
165 base = os.path.splitext (str (target[0]))[0]
166 return (target, source + [base + '.enc'])
168 def encoding_opt (target):
169 base = os.path.splitext (os.path.basename (str (target[0])))[0]
171 if os.path.exists (os.path.join (outdir, enc)):
172 return ' --encoding=' + enc
175 # UGH, should fix --output option for mftrace
176 verbose = verbose_opt (env, ' --verbose')
177 a = ('(cd ${TARGET.dir} && '
178 + ' if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi;' \
179 # + ' MFINPUTS=.:${TARGET.dir}:${SOURCE.dir}'\
181 + ' MFINPUTS=%(srcdir)s/mf}:.:'\
182 + ' mftrace --pfa --simplify --keep-trying $$encoding%(verbose)s'\
183 + ' --include=${TARGET.dir}'\
184 + ' ${SOURCE.file})') % vars ()
186 pfa = Builder (action = a,
189 emitter = add_enc_src)
190 env.Append (BUILDERS = {'PFA': pfa})
193 #verbose = verbose_opt (env, ' --verbose')
195 DIFF_PY = os.path.join (srcdir, 'stepmake/bin/package-diff.py')
197 a = ('%(PYTHON)s %(DIFF_PY)s%(verbose)s'\
198 + ' --outdir=${TARGET.dir}') % vars ()
199 patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
200 env.Append (BUILDERS = {'PATCH': patch})
202 # Ugh, how to make a sane tarball with scons?
203 ball = Builder (prefix = env['ballprefix'], action = 'ln $SOURCE $TARGET')
204 env.Append (BUILDERS = {'BALL': ball})