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
})
225 env
['DIFF_PY'] = '$srcdir/stepmake/bin/package-diff.py'
226 a
= '$PYTHON $DIFF_PY $__verbose --outdir=${TARGET.dir}'
227 patch
= Builder (action
= a
, suffix
= '.diff', src_suffix
= '.tar.gz')
228 env
.Append (BUILDERS
= {'PATCH': patch
})
240 'local_lilypond_datadir',
241 'local_lilypond_libdir',
257 def at_copy (target
, source
, env
):
258 s
= open (str (source
[0])).read ()
261 s
= string
.replace (s
, '@%s@'% i
, env
[i
])
263 open (t
, 'w').write (s
)
265 if os
.path
.basename (os
.path
.dirname (str (target
[0]))) == 'bin':
268 AT_COPY
= Builder (action
= at_copy
, src_suffix
= ['.in', '.py', '.sh',])
269 env
.Append (BUILDERS
= {'AT_COPY': AT_COPY
})
271 MO
= Builder (action
= 'msgfmt -o $TARGET $SOURCE',
272 suffix
= '.mo', src_suffix
= '.po')
273 env
.Append (BUILDERS
= {'MO': MO
})
275 ugh
= 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po; '
276 a
= ugh
+ 'xgettext --default-domain=lilypond --join \
277 --output-dir=${TARGET.dir} --add-comments \
278 --keyword=_ --keyword=_f --keyword=_i $SOURCES'
279 PO
= Builder (action
= a
, suffix
= '.pot',
280 src_suffix
= ['.cc', '.hh', '.py'], multi
= 1)
281 env
['potarget'] = os
.path
.join (env
['absbuild'], 'po', env
['out'],
285 ugh
= '; mv ${TARGET} ${SOURCE}'
286 a
= 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
287 POMERGE
= Builder (action
= a
, suffix
= '.pom', src_suffix
= '.po')
288 env
.Append (BUILDERS
= {'POMERGE': POMERGE
})
291 a
= 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
292 BIB2HTML
= Builder (action
= a
, suffix
= '.html', src_suffix
= '.bib')
293 env
.Append (BUILDERS
= {'BIB2HTML': BIB2HTML
})
295 a
= '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
296 --name=${TARGET.base} --title="$TITLE" $SOURCES'
297 LYS2TELY
= Builder (action
= a
, suffix
= '.tely', src_suffix
= '.ly')
298 env
.Append (BUILDERS
= {'LYS2TELY': LYS2TELY
})
301 def mutopia (ly
= None, abc
= None):
303 # FIXME: ugr, huh? The values from ../SConstruct get appended
304 # to the predefined values from this builder context:
306 # abc2ly/usr/bin/python ..../abc2.py
308 # Override them again to fix web build...
311 BUILD_ABC2LY
= '${set__x}$PYTHON $srcdir/scripts/abc2ly.py'
312 BUILD_LILYPOND
= '${set__x}$PYTHON $srcdir/scripts/lilypond.py${__verbose}'
314 LILYPOND
= BUILD_LILYPOND
,
315 ABC2LY
= BUILD_ABC2LY
,
319 abc
= base_glob ('*.abc')
321 ly
= base_glob ('*.ly') + map (e
.ABC
, abc
)
322 pdf
= map (e
.LilyPond
, ly
)
324 # We need lily and mf to build these.
325 env
.Depends (pdf
, ['#/lily', '#/mf'])
326 env
.Alias ('doc', pdf
)
331 def collate (title
= 'collated files'):
332 ly
= base_glob ('*.ly')
336 LILYPOND_BOOK_FLAGS
= '''--process="lilypond-bin --header=texidoc -I$srcdir/input/test -e '(ly:set-option (quote internal-type-checking) #t)'"''',
337 __verbose
= ' --verbose',
340 tely
= e
.LYS2TELY ('collated-files', ly
)
342 # We need lily and mf to build these.
343 env
.Depends (texi
, ['#/lily', '#/mf'])
344 dvi
= e
.TEXIDVI (texi
)
345 pspdf
= e
.DVIPDF (dvi
)
346 pdf
= e
.PSPDF (pspdf
)
349 env
.Alias ('doc', pdf
)
350 env
.Alias ('doc', html
)