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.
68 lilypond_book_flags
= '''--format=$LILYPOND_BOOK_FORMAT --process="lilypond -I$srcdir -I$srcdir/input/test $__verbose --backend=eps --formats=ps,png --header=texidoc -dinternal-type-checking -ddump-signatures -danti-alias-factor=2 -dgs-font-load" '''
71 BSTINPUTS
= '${SOURCE.dir}:${TARGET.dir}:',
72 BIB2HTML
= '$PYTHON $srcdir/buildscripts/bib2html.py',
73 LILYOND_BOOK
= 'lilypond-book',
74 LILYPOND_BOOK_FORMAT
= '',
75 LILYPOND_BOOK_FLAGS
= lilypond_book_flags
,
77 # The SCons way around FOO_PATH:
78 LILYPOND_INCFLAGS
= '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__)} $)',
82 MAKEINFO_INCFLAGS
= '$( ${_concat(INCPREFIX, MAKEINFO_PATH, INCSUFFIX, __env__, RDirs)} $)',
84 _TEXI2DVI_FLAGS
= '$( ${_concat(" ", TEXI2DVI_FLAGS,)} $)',
88 Builder (action
= '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS\
89 --no-split --no-headers $SOURCE',
90 suffix
= '.txt', src_suffix
= '.texi')
91 env
.Append (BUILDERS
= {'TXT': TXT
})
94 Builder (action
= '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS $SOURCE',
95 suffix
= '.info', src_suffix
= '.texi')
96 env
.Append (BUILDERS
= {'INFO': INFO
})
99 Builder (action
= '$MAKEINFO --output=$TARGET $MAKEINFO_INCLUDES\
100 --html --no-split --no-headers $MAKEINFO_FLAGS $SOURCE',
101 suffix
= '.html', src_suffix
= '.texi')
102 env
.Append (BUILDERS
= {'HTML': HTML
})
106 '$LILYPOND_BOOK --output=${TARGET.dir} \
107 --include=${TARGET.dir} $LILYPOND_INCFLAGS \
108 --process="$LILYPOND $LILYPOND_INCFLAGS" \
109 $LILYPOND_BOOK_FLAGS \
111 suffix
= '.texi', src_suffix
= '.tely')
112 env
.Append (BUILDERS
= {'TEXI': TEXI
})
115 Builder (action
= 'cd ${TARGET.dir} && \
116 texi2dvi --batch -I $srcdir/Documentation/user $_TEXI2DVI_FLAGS ${SOURCE.file}',
117 suffix
= '.dvi', src_suffix
= '.texi')
118 env
.Append (BUILDERS
= {'TEXIDVI': TEXIDVI
})
121 Builder (action
= 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET $DVIPS_FLAGS $SOURCE',
122 suffix
= '.ps', src_suffix
= '.dvi')
123 env
.Append (BUILDERS
= {'DVIPS': DVIPS
})
126 Builder (action
= 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET -Ppdf $DVIPS_FLAGS $SOURCE',
127 suffix
= '.pdfps', src_suffix
= '.dvi')
128 env
.Append (BUILDERS
= {'DVIPDF': DVIPDF
})
131 Builder (action
= 'ps2pdf $PSPDF_FLAGS $SOURCE $TARGET',
132 suffix
= '.pdf', src_suffix
= '.pdfps')
133 env
.Append (BUILDERS
= {'PSPDF': PSPDF
})
136 Builder (action
= 'convert $SOURCE $TARGET',
137 suffix
= '.eps', src_suffix
= '.png')
138 env
.Append (BUILDERS
= {'PNG2EPS': PNG2EPS
})
141 Builder (action
= 'convert $SOURCE $TARGET',
142 suffix
= '.png', src_suffix
= '.eps')
143 env
.Append (BUILDERS
= {'EPS2PNG': EPS2PNG
})
145 def add_ps_target (target
, source
, env
):
146 base
= os
.path
.splitext (str (target
[0]))[0]
147 return (target
+ [base
+ '.ps'], source
)
150 Builder (action
= '$LILYPOND --output=${TARGET.base} --include=${TARGET.dir} $SOURCE',
151 suffix
= '.pdf', src_suffix
= '.ly')
152 ## emitter = add_ps_target)
153 env
.Append (BUILDERS
= {'LilyPond': lilypond
})
155 ABC
= Builder (action
= '$ABC2LY --output=${TARGET} --strict $SOURCE',
156 suffix
= '.ly', src_suffix
= '.abc')
157 env
.Append (BUILDERS
= {'ABC': ABC
})
159 def add_log_target (target
, source
, env
):
160 base
= os
.path
.splitext (str (target
[0]))[0]
161 return (target
+ [base
+ '.log'], source
)
163 def add_tfm_target (target
, source
, env
):
164 base
= os
.path
.splitext (str (target
[0]))[0]
165 return (target
+ [base
+ '.tfm'], source
)
167 def add_lisp_enc_target (target
, source
, env
):
168 base
= os
.path
.splitext (str (target
[0]))[0]
169 return (target
+ [base
+ '.lisp', base
+ '.enc'],
172 def add_cff_cffps_svg (target
, source
, env
):
173 base
= os
.path
.splitext (str (target
[0]))[0]
174 return (target
+ [base
+ '.cff', base
+ '.cff.ps', base
+ '.svg'],
177 a
= 'cd ${TARGET.dir} \
178 && MFINPUTS=.:${SOURCE.dir}:$srcdir/${SOURCE.dir}: \
179 $MF "\\mode:=$MFMODE; nonstopmode; input ${SOURCE.filebase};" \
180 | grep -v "@\|>>\|w:\|h:";'
181 tfm
= Builder (action
= a
, suffix
= '.tfm', src_suffix
= '.mf',
182 # emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
183 emitter
= add_log_target
)
184 env
.Append (BUILDERS
= {'TFM': tfm
})
186 a
= '$PYTHON $MF_TO_TABLE_PY \
187 --outdir=${TARGET.dir} \
188 --global-lisp=${TARGET.base}.otf-gtable \
189 --lisp=${TARGET.base}.lisp \
190 --enc=${TARGET.base}.enc \
192 gtable
= Builder (action
= a
, suffix
= '.otf-gtable', src_suffix
= '.log',
193 emitter
= add_lisp_enc_target
)
194 env
.Append (BUILDERS
= {'GTABLE': gtable
})
196 def add_enc_src (target
, source
, env
):
197 base
= os
.path
.splitext (str (target
[0]))[0]
198 #return (target, source + [base + '.enc'])
199 return (target
+ [base
+ '.pfb', base
+ '.svg'], source
+ [base
+ '.enc'])
201 def add_svg (target
, source
, env
):
202 base
= os
.path
.splitext (str (target
[0]))[0]
203 return (target
+ [base
+ '.svg'], source
)
205 # FIXME UGH, should fix --output option for mftrace
206 a
= 'cd ${TARGET.dir} && \
207 if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi; \
208 MFINPUTS=$srcdir/mf:.: \
209 $MFTRACE --formats=pfa,pfb,svg --simplify --keep-trying --no-afm \
210 $$encoding $__verbose \
211 --include=${TARGET.dir} \
214 pfa
= Builder (action
= a
,
217 emitter
= add_enc_src
)
218 env
.Append (BUILDERS
= {'PFA': pfa
})
220 a
= ['(cd ${TARGET.dir} && $FONTFORGE -script ${SOURCE.file})',
221 # '$PYTHON $srcdir/buildscripts/ps-embed-cff.py ${SOURCE.base}.cff $$(cat ${SOURCE.base}.fontname) ${SOURCE.base}.cff.ps',
222 'rm -f ${TARGET.dir}/*.scale.pfa']
223 otf
= Builder (action
= a
,
226 # emitter = add_cff_cffps_svg
229 env
.Append (BUILDERS
= {'OTF': otf
})
234 env
['DIFF_PY'] = '$srcdir/stepmake/bin/package-diff.py'
235 a
= '$PYTHON $DIFF_PY $NO__verbose --outdir=${TARGET.dir}'
236 patch
= Builder (action
= a
, suffix
= '.diff', src_suffix
= '.tar.gz')
237 env
.Append (BUILDERS
= {'PATCH': patch
})
249 'local_lilypond_datadir',
250 'local_lilypond_libdir',
265 def at_copy (target
, source
, env
):
270 s
= string
.replace (s
, '@%s@'% i
, env
[i
])
272 open (t
, 'w').write (s
)
274 if os
.path
.basename (os
.path
.dirname (str (target
[0]))) == 'bin':
277 AT_COPY
= Builder (action
= at_copy
, src_suffix
= ['.in', '.py', '.sh',])
278 env
.Append (BUILDERS
= {'AT_COPY': AT_COPY
})
280 MO
= Builder (action
= 'msgfmt -o $TARGET $SOURCE',
281 suffix
= '.mo', src_suffix
= '.po')
282 env
.Append (BUILDERS
= {'MO': MO
})
284 ugh
= 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po ; '
285 a
= ugh
+ 'xgettext --default-domain=lilypond --join \
286 --output-dir=${TARGET.dir} --add-comments \
287 --keyword=_ --keyword=_f --keyword=_i $SOURCES'
288 PO
= Builder (action
= a
, suffix
= '.pot',
289 src_suffix
= ['.cc', '.hh', '.py'], multi
= 1)
290 env
['potarget'] = os
.path
.join (env
['absbuild'], 'po', env
['out'],
294 ugh
= '; mv ${TARGET} ${SOURCE}'
295 a
= 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
296 POMERGE
= Builder (action
= a
, suffix
= '.pom', src_suffix
= '.po')
297 env
.Append (BUILDERS
= {'POMERGE': POMERGE
})
299 a
= 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
300 BIB2HTML
= Builder (action
= a
, suffix
= '.html', src_suffix
= '.bib')
301 env
.Append (BUILDERS
= {'BIB2HTML': BIB2HTML
})
303 a
= '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
304 --name=${TARGET.base} --title="$TITLE" $SOURCES'
305 LYS2TELY
= Builder (action
= a
, suffix
= '.tely', src_suffix
= '.ly')
306 env
.Append (BUILDERS
= {'LYS2TELY': LYS2TELY
})
309 def mutopia (ly
=None, abc
=None):
311 LILYPOND_BOOK_FLAGS
= lilypond_book_flags
,
315 abc
= base_glob ('*.abc')
317 ly
= base_glob ('*.ly') + map (e
.ABC
, abc
)
318 pdf
= map (e
.LilyPond
, ly
)
319 env
.Depends (pdf
, ['#/lily', '#/mf'])
320 env
.Alias ('doc', pdf
)
324 def collate (title
= 'collated files'):
325 ly
= base_glob ('*.ly')
329 LILYPOND_BOOK_FLAGS
= lilypond_book_flags
,
330 # __verbose = ' --verbose',
332 tely
= e
.LYS2TELY ('collated-files', ly
)
334 env
.Depends (texi
, ['#/lily', '#/mf'])
335 dvi
= e
.TEXIDVI (texi
)
336 pspdf
= e
.DVIPDF (dvi
)
337 pdf
= e
.PSPDF (pspdf
)
340 env
.Alias ('doc', pdf
)
341 env
.Alias ('doc', html
)