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 LILYPOND_BIN = 'lilypond-bin',
73 LILYOND_BOOK = 'lilypond-book',
76 #LILYPOND_BOOK_FORMAT = 'texi',
77 LILYPOND_BOOK_FORMAT = '',
78 LILYPOND_BOOK_FLAGS = ['--format=$LILYPOND_BOOK_FORMAT'],
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)} $)',
90 _TEXI2DVI_FLAGS = '$( ${_concat(" ", TEXI2DVI_FLAGS,)} $)',
94 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS\
95 --no-split --no-headers $SOURCE',
96 suffix = '.txt', src_suffix = '.texi')
97 env.Append (BUILDERS = {'TXT': TXT})
100 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS $SOURCE',
101 suffix = '.info', src_suffix = '.texi')
102 env.Append (BUILDERS = {'INFO': INFO})
105 Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCLUDES\
106 --html --no-split --no-headers $MAKEINFO_FLAGS $SOURCE',
107 suffix = '.html', src_suffix = '.texi')
108 env.Append (BUILDERS = {'HTML': HTML})
112 '$LILYPOND_BOOK --output=${TARGET.dir} \
113 --include=${TARGET.dir} $LILYPOND_INCFLAGS \
114 --process="$LILYPOND_BIN $LILYPOND_INCFLAGS" \
115 $LILYPOND_BOOK_FLAGS \
117 suffix = '.texi', src_suffix = '.tely')
118 env.Append (BUILDERS = {'TEXI': TEXI})
121 Builder (action = 'cd ${TARGET.dir} && \
122 texi2dvi --batch $_TEXI2DVI_FLAGS ${SOURCE.file}',
123 suffix = '.dvi', src_suffix = '.texi')
124 env.Append (BUILDERS = {'TEXIDVI': TEXIDVI})
127 Builder (action = 'dvips -o $TARGET $DVIPS_FLAGS $SOURCE',
128 suffix = '.ps', src_suffix = '.dvi')
129 env.Append (BUILDERS = {'DVIPS': DVIPS})
132 Builder (action = 'dvips -o $TARGET -Ppdf $DVIPS_FLAGS $SOURCE',
133 suffix = '.pdfps', src_suffix = '.dvi')
134 env.Append (BUILDERS = {'DVIPDF': DVIPDF})
137 Builder (action = 'ps2pdf $PSPDF_FLAGS $SOURCE $TARGET',
138 suffix = '.pdf', src_suffix = '.pdfps')
139 env.Append (BUILDERS = {'PSPDF': PSPDF})
142 Builder (action = 'convert $SOURCE $TARGET',
143 suffix = '.eps', src_suffix = '.png')
144 env.Append (BUILDERS = {'PNG2EPS': PNG2EPS})
150 # FIXME: cleanup, see above
156 BSTINPUTS = '${SOURCE.dir}:${TARGET.dir}:',
157 BIB2HTML = '$PYTHON $srcdir/buildscripts/bib2html.py',
161 def add_ps_target (target, source, env):
162 base = os.path.splitext (str (target[0]))[0]
163 return (target + [base + '.ps'], source)
166 # FIXME: INCLUDES, FLAGS, use LILYPOND_BIN for building ?
168 Builder (action = '$LILYPOND --output=${TARGET.base} --include=${TARGET.dir} $SOURCE',
169 suffix = '.pdf', src_suffix = '.ly')
170 ## emitter = add_ps_target)
171 env.Append (BUILDERS = {'LilyPond': lilypond})
173 ABC = Builder (action = '$ABC2LY --output=${TARGET} --strict $SOURCE',
174 suffix = '.ly', src_suffix = '.abc')
175 env.Append (BUILDERS = {'ABC': ABC})
177 def add_log_target (target, source, env):
178 base = os.path.splitext (str (target[0]))[0]
179 return (target + [base + '.log'], source)
181 def add_enc_ly_tex_target (target, source, env):
182 base = os.path.splitext (str (target[0]))[0]
183 return (target + [base + '.enc', base + '.tex', base + 'list.ly'],
185 a = 'cd ${TARGET.dir} && \
186 MFINPUTS=.:${SOURCE.dir}:$srcdir/${SOURCE.dir}: \
187 mf "\\mode:=$MFMODE; nonstopmode; input ${SOURCE.filebase};" \
189 tfm = Builder (action = a, suffix = '.tfm', src_suffix = '.mf',
190 # emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
191 emitter = add_log_target)
192 env.Append (BUILDERS = {'TFM': tfm})
194 a = '$PYTHON $MF_TO_TABLE_PY \
195 --outdir=${TARGET.dir} \
196 --afm=${TARGET.base}.afm \
197 --enc=${TARGET.base}.enc \
198 --tex=${TARGET.base}.tex \
199 --ly=${TARGET.base}list.ly \
201 afm = Builder (action = a, suffix = '.afm', src_suffix = '.log',
202 emitter = add_enc_ly_tex_target)
203 env.Append (BUILDERS = {'AFM': afm})
205 def add_enc_src (target, source, env):
206 base = os.path.splitext (str (target[0]))[0]
207 return (target, source + [base + '.enc'])
209 # UGH, should fix --output option for mftrace
210 # mftrace --verbose is too verbose
211 a = 'cd ${TARGET.dir} && \
212 if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi; \
213 MFINPUTS=$srcdir/mf:.: \
214 mftrace --pfa --simplify --keep-trying $$encoding $TOO__verbose \
215 --include=${TARGET.dir} \
218 pfa = Builder (action = a,
221 emitter = add_enc_src)
222 env.Append (BUILDERS = {'PFA': pfa})
226 # experiment: switch off for speed.
228 env['DIFF_PY'] = '$srcdir/stepmake/bin/package-diff.py'
229 a = '$PYTHON $DIFF_PY $__verbose --outdir=${TARGET.dir}'
230 patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
231 env.Append (BUILDERS = {'PATCH': patch})
243 'local_lilypond_datadir',
244 'local_lilypond_libdir',
260 def at_copy (target, source, env):
261 s = open (str (source[0])).read ()
264 s = string.replace (s, '@%s@'% i, env[i])
266 open (t, 'w').write (s)
268 if os.path.basename (os.path.dirname (str (target[0]))) == 'bin':
271 AT_COPY = Builder (action = at_copy, src_suffix = ['.in', '.py', '.sh',])
272 env.Append (BUILDERS = {'AT_COPY': AT_COPY})
274 MO = Builder (action = 'msgfmt -o $TARGET $SOURCE',
275 suffix = '.mo', src_suffix = '.po')
276 env.Append (BUILDERS = {'MO': MO})
279 ugh = 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po ; '
280 a = ugh + 'xgettext --default-domain=lilypond --join \
281 --output-dir=${TARGET.dir} --add-comments \
282 --keyword=_ --keyword=_f --keyword=_i $SOURCES'
283 PO = Builder (action = a, suffix = '.pot',
284 src_suffix = ['.cc', '.hh', '.py'], multi = 1)
285 env['potarget'] = os.path.join (env['absbuild'], 'po', env['out'],
289 ugh = '; mv ${TARGET} ${SOURCE}'
290 a = 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
291 POMERGE = Builder (action = a, suffix = '.pom', src_suffix = '.po')
292 env.Append (BUILDERS = {'POMERGE': POMERGE})
295 a = 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
296 BIB2HTML = Builder (action = a, suffix = '.html', src_suffix = '.bib')
297 env.Append (BUILDERS = {'BIB2HTML': BIB2HTML})
299 a = '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
300 --name=${TARGET.base} --title="$TITLE" $SOURCES'
301 LYS2TELY = Builder (action = a, suffix = '.tely', src_suffix = '.ly')
302 env.Append (BUILDERS = {'LYS2TELY': LYS2TELY})
305 def mutopia (ly = None, abc = None):
307 # FIXME: ugr, huh? The values from ../SConstruct get appended
308 # to the predefined values from this builder context:
310 # abc2ly/usr/bin/python ..../abc2.py
312 # Override them again to fix web build...
315 BUILD_ABC2LY = '${set__x}$PYTHON $srcdir/scripts/abc2ly.py'
316 BUILD_LILYPOND = '${set__x}$PYTHON $srcdir/scripts/lilypond.py${__verbose}'
318 LILYPOND = BUILD_LILYPOND,
319 ABC2LY = BUILD_ABC2LY,
323 abc = base_glob ('*.abc')
325 ly = base_glob ('*.ly') + map (e.ABC, abc)
326 pdf = map (e.LilyPond, ly)
328 # We need lily and mf to build these.
329 env.Depends (pdf, ['#/lily', '#/mf'])
330 env.Alias ('doc', pdf)
335 def collate (title = 'collated files'):
336 ly = base_glob ('*.ly')
340 LILYPOND_BOOK_FLAGS = '''--process="lilypond-bin --header=texidoc -I$srcdir/input/test -e '(ly:set-option (quote internal-type-checking) #t)'"''',
341 __verbose = ' --verbose',
344 tely = e.LYS2TELY ('collated-files', ly)
346 # We need lily and mf to build these.
347 env.Depends (texi, ['#/lily', '#/mf'])
348 dvi = e.TEXIDVI (texi)
349 pspdf = e.DVIPDF (dvi)
350 pdf = e.PSPDF (pspdf)
353 env.Alias ('doc', pdf)
354 env.Alias ('doc', html)