11 def add_suffixes (target, source, env, target_suffixes, src_suffixes):
12 base = os.path.splitext (str (target[0]))[0]
13 return (target + map (lambda x: base + x, target_suffixes),
14 source + map (lambda x: base + x, src_suffixes))
17 def join_path (path, infix=os.pathsep, prefix = ''):
20 return env['srcdir'] + x[1:]
22 return string.join (map (lambda x: prefix + dir (x), path), infix)
27 os.chdir (env.Dir ('.').srcnode ().abspath)
28 result = glob.glob (s)
35 return map (lambda x: os.path.splitext (x)[0], src_glob (s))
39 def install (target, dir):
40 dest = env['DESTDIR'] + dir
41 if type (target) == type ([]):
42 map (lambda x: env.Install (dir, x), target)
44 env.Install (dir, target)
45 env.Alias ('install', dir)
50 x = string.replace (s, '#', env['srcdir'])
51 x = string.replace (x, '@', env['absbuild'])
54 # Clean separation between generic action + flags and actual
55 # configuration and flags in environment for this build.
57 # Generic builders could/should be part of SCons.
60 HH = Builder (action = 'bison -d -o ${TARGET.base}.cc $SOURCE',
61 suffix = '.hh', src_suffix = '.yy')
62 env.Append (BUILDERS = {'HH' : HH})
65 # Setup LilyPond environment. For the LilyPond build, we override
66 # some of these commands in the ENVironment.
71 ##LILYPOND = 'lilypond',
72 LILYOND_BOOK = 'lilypond-book',
75 #LILYPOND_BOOK_FORMAT = 'texi',
76 LILYPOND_BOOK_FORMAT = '',
77 #LILYPOND_BOOK_FLAGS = ['--format=$LILYPOND_BOOK_FORMAT'],
78 LILYPOND_BOOK_FLAGS = '''--format=$LILYPOND_BOOK_FORMAT --process="lilypond --backend=eps --formats=ps,png --header=texidoc -I$srcdir/input/test -e '(ly:set-option (quote internal-type-checking) #t)'" ''',
81 # The SCons way around FOO_PATH:
82 ##LILYPOND_INCFLAGS = '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__, RDirs)} $)',
83 LILYPOND_INCFLAGS = '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__)} $)',
87 MAKEINFO_INCFLAGS = '$( ${_concat(INCPREFIX, MAKEINFO_PATH, INCSUFFIX, __env__, RDirs)} $)',
88 # should not be necessary
89 # PYTHONPATH = ['$absbuild/python/$out'],
91 _TEXI2DVI_FLAGS = '$( ${_concat(" ", TEXI2DVI_FLAGS,)} $)',
95 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS\
96 --no-split --no-headers $SOURCE',
97 suffix = '.txt', src_suffix = '.texi')
98 env.Append (BUILDERS = {'TXT': TXT})
101 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS $SOURCE',
102 suffix = '.info', src_suffix = '.texi')
103 env.Append (BUILDERS = {'INFO': INFO})
106 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCLUDES\
107 --html --no-split --no-headers $MAKEINFO_FLAGS $SOURCE',
108 suffix = '.html', src_suffix = '.texi')
109 env.Append (BUILDERS = {'HTML': HTML})
113 '$LILYPOND_BOOK --output=${TARGET.dir} \
114 --include=${TARGET.dir} $LILYPOND_INCFLAGS \
115 --process="$LILYPOND $LILYPOND_INCFLAGS" \
116 $LILYPOND_BOOK_FLAGS \
118 suffix = '.texi', src_suffix = '.tely')
119 env.Append (BUILDERS = {'TEXI': TEXI})
122 Builder (action = 'cd ${TARGET.dir} && \
123 texi2dvi --batch $_TEXI2DVI_FLAGS ${SOURCE.file}',
124 suffix = '.dvi', src_suffix = '.texi')
125 env.Append (BUILDERS = {'TEXIDVI': TEXIDVI})
128 Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET $DVIPS_FLAGS $SOURCE',
129 suffix = '.ps', src_suffix = '.dvi')
130 env.Append (BUILDERS = {'DVIPS': DVIPS})
133 Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET -Ppdf $DVIPS_FLAGS $SOURCE',
134 suffix = '.pdfps', src_suffix = '.dvi')
135 env.Append (BUILDERS = {'DVIPDF': DVIPDF})
138 Builder (action = 'ps2pdf $PSPDF_FLAGS $SOURCE $TARGET',
139 suffix = '.pdf', src_suffix = '.pdfps')
140 env.Append (BUILDERS = {'PSPDF': PSPDF})
143 Builder (action = 'convert $SOURCE $TARGET',
144 suffix = '.eps', src_suffix = '.png')
145 env.Append (BUILDERS = {'PNG2EPS': PNG2EPS})
149 # FIXME: cleanup, see above
155 BSTINPUTS = '${SOURCE.dir}:${TARGET.dir}:',
156 BIB2HTML = '$PYTHON $srcdir/buildscripts/bib2html.py',
160 def add_ps_target (target, source, env):
161 base = os.path.splitext (str (target[0]))[0]
162 return (target + [base + '.ps'], source)
165 Builder (action = '$LILYPOND --output=${TARGET.base} --include=${TARGET.dir} $SOURCE',
166 suffix = '.pdf', src_suffix = '.ly')
167 ## emitter = add_ps_target)
168 env.Append (BUILDERS = {'LilyPond': lilypond})
170 ABC = Builder (action = '$ABC2LY --output=${TARGET} --strict $SOURCE',
171 suffix = '.ly', src_suffix = '.abc')
172 env.Append (BUILDERS = {'ABC': ABC})
174 def add_log_target (target, source, env):
175 base = os.path.splitext (str (target[0]))[0]
176 return (target + [base + '.log'], source)
178 def add_tfm_target (target, source, env):
179 base = os.path.splitext (str (target[0]))[0]
180 return (target + [base + '.tfm'], source)
182 def add_lisp_enc_tex_ly_target (target, source, env):
183 base = os.path.splitext (str (target[0]))[0]
184 return (target + [base + '.lisp', base + '.enc', base + '.tex',
188 def add_cff_cffps_svg (target, source, env):
189 base = os.path.splitext (str (target[0]))[0]
190 return (target + [base + '.cff', base + '.cff.ps', base + '.svg'],
193 a = 'cd ${TARGET.dir} \
194 && MFINPUTS=.:${SOURCE.dir}:$srcdir/${SOURCE.dir}: \
195 $MF "\\mode:=$MFMODE; nonstopmode; input ${SOURCE.filebase};" \
196 | grep -v "@\|>>\|w:\|h:";'
197 tfm = Builder (action = a, suffix = '.tfm', src_suffix = '.mf',
198 # emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
199 emitter = add_log_target)
200 env.Append (BUILDERS = {'TFM': tfm})
202 a = '$PYTHON $MF_TO_TABLE_PY \
203 --outdir=${TARGET.dir} \
204 --global-lisp=${TARGET.base}.otf-gtable \
205 --lisp=${TARGET.base}.lisp \
206 --enc=${TARGET.base}.enc \
207 --tex=${TARGET.base}.tex \
208 --ly=${TARGET.base}list.ly \
210 gtable = Builder (action = a, suffix = '.otf-gtable', src_suffix = '.log',
211 emitter = add_lisp_enc_tex_ly_target)
212 env.Append (BUILDERS = {'GTABLE': gtable})
214 def add_enc_src (target, source, env):
215 base = os.path.splitext (str (target[0]))[0]
216 return (target, source + [base + '.enc'])
218 # FIXME UGH, should fix --output option for mftrace
219 a = 'cd ${TARGET.dir} && \
220 if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi; \
221 MFINPUTS=$srcdir/mf:.: \
222 $MFTRACE --formats=pfa --simplify --keep-trying --no-afm \
223 $$encoding $__verbose \
224 --include=${TARGET.dir} \
227 pfa = Builder (action = a,
230 emitter = add_enc_src)
231 env.Append (BUILDERS = {'PFA': pfa})
233 a = ['(cd ${TARGET.dir} && $FONTFORGE -script ${SOURCE.file})',
234 # '$PYTHON $srcdir/buildscripts/ps-embed-cff.py ${SOURCE.base}.cff $$(cat ${SOURCE.base}.fontname) ${SOURCE.base}.cff.ps',
235 'rm -f ${TARGET.dir}/*.scale.pfa']
236 otf = Builder (action = a,
239 # emitter = add_cff_cffps_svg
241 env.Append (BUILDERS = {'OTF': otf})
246 env['DIFF_PY'] = '$srcdir/stepmake/bin/package-diff.py'
247 a = '$PYTHON $DIFF_PY $NO__verbose --outdir=${TARGET.dir}'
248 patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
249 env.Append (BUILDERS = {'PATCH': patch})
261 'local_lilypond_datadir',
262 'local_lilypond_libdir',
278 def at_copy (target, source, env):
283 s = string.replace (s, '@%s@'% i, env[i])
285 open (t, 'w').write (s)
287 if os.path.basename (os.path.dirname (str (target[0]))) == 'bin':
290 AT_COPY = Builder (action = at_copy, src_suffix = ['.in', '.py', '.sh',])
291 env.Append (BUILDERS = {'AT_COPY': AT_COPY})
294 def at_copy_ext (target, source, env):
299 s = string.replace (s, '@%s@'% i, env[i])
301 e = os.path.splitext (n)[1]
302 t = str (target[0]) + e
303 open (t, 'w').write (s)
305 AT_COPY_EXT = Builder (action = at_copy_ext, src_suffix = ['.py', '.sh',])
306 env.Append (BUILDERS = {'AT_COPY_EXT': AT_COPY_EXT})
309 MO = Builder (action = 'msgfmt -o $TARGET $SOURCE',
310 suffix = '.mo', src_suffix = '.po')
311 env.Append (BUILDERS = {'MO': MO})
314 ugh = 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po ; '
315 a = ugh + 'xgettext --default-domain=lilypond --join \
316 --output-dir=${TARGET.dir} --add-comments \
317 --keyword=_ --keyword=_f --keyword=_i $SOURCES'
318 PO = Builder (action = a, suffix = '.pot',
319 src_suffix = ['.cc', '.hh', '.py'], multi = 1)
320 env['potarget'] = os.path.join (env['absbuild'], 'po', env['out'],
324 ugh = '; mv ${TARGET} ${SOURCE}'
325 a = 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
326 POMERGE = Builder (action = a, suffix = '.pom', src_suffix = '.po')
327 env.Append (BUILDERS = {'POMERGE': POMERGE})
330 a = 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
331 BIB2HTML = Builder (action = a, suffix = '.html', src_suffix = '.bib')
332 env.Append (BUILDERS = {'BIB2HTML': BIB2HTML})
334 a = '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
335 --name=${TARGET.base} --title="$TITLE" $SOURCES'
336 LYS2TELY = Builder (action = a, suffix = '.tely', src_suffix = '.ly')
337 env.Append (BUILDERS = {'LYS2TELY': LYS2TELY})
340 def mutopia (ly = None, abc = None):
342 # FIXME: ugr, huh? The values from ../SConstruct get appended
343 # to the predefined values from this builder context:
345 # abc2ly/usr/bin/python ..../abc2.py
347 # Override them again to fix web build...
350 #BUILD_ABC2LY = '${set__x}$PYTHON $srcdir/scripts/abc2ly.py'
351 #BUILD_LILYPOND = '$absbuild/$out/lilypond ${__verbose}'
353 #LILYPOND = BUILD_LILYPOND,
354 #ABC2LY = BUILD_ABC2LY,
358 abc = base_glob ('*.abc')
360 ly = base_glob ('*.ly') + map (e.ABC, abc)
361 pdf = map (e.LilyPond, ly)
363 # We need lily and mf to build these.
364 env.Depends (pdf, ['#/lily', '#/mf'])
365 env.Alias ('doc', pdf)
370 def collate (title = 'collated files'):
371 ly = base_glob ('*.ly')
375 LILYPOND_BOOK_FLAGS = '''--process="lilypond --backend=eps --formats=ps,png --header=texidoc -I$srcdir/input/test -e '(ly:set-option (quote internal-type-checking) #t)'" ''',
376 __verbose = ' --verbose',
379 tely = e.LYS2TELY ('collated-files', ly)
381 # We need lily and mf to build these.
382 env.Depends (texi, ['#/lily', '#/mf'])
383 dvi = e.TEXIDVI (texi)
384 pspdf = e.DVIPDF (dvi)
385 pdf = e.PSPDF (pspdf)
388 env.Alias ('doc', pdf)
389 env.Alias ('doc', html)