1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
|
# -*-python-*-
import glob
import os
import string
Import ('env')
# utility
def add_suffixes (target, source, env, target_suffixes, src_suffixes):
base = os.path.splitext (str (target[0]))[0]
return (target + map (lambda x: base + x, target_suffixes),
source + map (lambda x: base + x, src_suffixes))
# junkme; see _concat
def join_path (path, infix=os.pathsep, prefix = ''):
def dir (x):
if x and x[0] == '#':
return env['srcdir'] + x[1:]
return x
return string.join (map (lambda x: prefix + dir (x), path), infix)
def src_glob (s):
here = os.getcwd ()
os.chdir (env.Dir ('.').srcnode ().abspath)
result = glob.glob (s)
os.chdir (here)
return result
Export ('src_glob')
def base_glob (s):
return map (lambda x: os.path.splitext (x)[0], src_glob (s))
Export ('base_glob')
def install (target, dir):
dest = env['DESTDIR'] + dir
if type (target) == type ([]):
map (lambda x: env.Install (dir, x), target)
else:
env.Install (dir, target)
env.Alias ('install', dir)
Export ('install')
def _fixme (s):
x = string.replace (s, '#', env['srcdir'])
x = string.replace (x, '@', env['absbuild'])
return x
# Clean separation between generic action + flags and actual
# configuration and flags in environment for this build.
# Generic builders could/should be part of SCons.
HH = Builder (action = 'bison -d -o ${TARGET.base}.cc $SOURCE',
suffix = '.hh', src_suffix = '.yy')
env.Append (BUILDERS = {'HH' : HH})
# Setup LilyPond environment. For the LilyPond build, we override
# some of these commands in the ENVironment.
env.Append (
_fixme = _fixme,
##ABC2LY = 'abc2ly',
##LILYPOND = 'lilypond',
LILYOND_BOOK = 'lilypond-book',
#ugr
#LILYPOND_BOOK_FORMAT = 'texi',
LILYPOND_BOOK_FORMAT = '',
#LILYPOND_BOOK_FLAGS = ['--format=$LILYPOND_BOOK_FORMAT'],
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)'" ''',
LILYPOND_PATH = [],
# The SCons way around FOO_PATH:
##LILYPOND_INCFLAGS = '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__, RDirs)} $)',
LILYPOND_INCFLAGS = '$( ${_concat(INCPREFIX, LILYPOND_PATH, INCSUFFIX, __env__)} $)',
MAKEINFO_PATH = [],
MAKEINFO_FLAGS = [],
MAKEINFO_INCFLAGS = '$( ${_concat(INCPREFIX, MAKEINFO_PATH, INCSUFFIX, __env__, RDirs)} $)',
# should not be necessary
# PYTHONPATH = ['$absbuild/python/$out'],
TEXI2DVI_FLAGS = [],
_TEXI2DVI_FLAGS = '$( ${_concat(" ", TEXI2DVI_FLAGS,)} $)',
)
TXT =\
Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS\
--no-split --no-headers $SOURCE',
suffix = '.txt', src_suffix = '.texi')
env.Append (BUILDERS = {'TXT': TXT})
INFO =\
Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCFLAGS $SOURCE',
suffix = '.info', src_suffix = '.texi')
env.Append (BUILDERS = {'INFO': INFO})
HTML =\
Builder (action = '$MAKEINFO --output=$TARGET $MAKEINFO_INCLUDES\
--html --no-split --no-headers $MAKEINFO_FLAGS $SOURCE',
suffix = '.html', src_suffix = '.texi')
env.Append (BUILDERS = {'HTML': HTML})
TEXI =\
Builder (action =
'$LILYPOND_BOOK --output=${TARGET.dir} \
--include=${TARGET.dir} $LILYPOND_INCFLAGS \
--process="$LILYPOND $LILYPOND_INCFLAGS" \
$LILYPOND_BOOK_FLAGS \
$SOURCE',
suffix = '.texi', src_suffix = '.tely')
env.Append (BUILDERS = {'TEXI': TEXI})
TEXIDVI =\
Builder (action = 'cd ${TARGET.dir} && \
texi2dvi --batch $_TEXI2DVI_FLAGS ${SOURCE.file}',
suffix = '.dvi', src_suffix = '.texi')
env.Append (BUILDERS = {'TEXIDVI': TEXIDVI})
DVIPS =\
Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET $DVIPS_FLAGS $SOURCE',
suffix = '.ps', src_suffix = '.dvi')
env.Append (BUILDERS = {'DVIPS': DVIPS})
DVIPDF =\
Builder (action = 'TEXINPUTS=${TARGET.dir}:$$TEXINPUTS $DVIPS -o $TARGET -Ppdf $DVIPS_FLAGS $SOURCE',
suffix = '.pdfps', src_suffix = '.dvi')
env.Append (BUILDERS = {'DVIPDF': DVIPDF})
PSPDF =\
Builder (action = 'ps2pdf $PSPDF_FLAGS $SOURCE $TARGET',
suffix = '.pdf', src_suffix = '.pdfps')
env.Append (BUILDERS = {'PSPDF': PSPDF})
PNG2EPS =\
Builder (action = 'convert $SOURCE $TARGET',
suffix = '.eps', src_suffix = '.png')
env.Append (BUILDERS = {'PNG2EPS': PNG2EPS})
# FIXME: cleanup, see above
env.Append (
#urg
BSTINPUTS = '${SOURCE.dir}:${TARGET.dir}:',
BIB2HTML = '$PYTHON $srcdir/buildscripts/bib2html.py',
)
def add_ps_target (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target + [base + '.ps'], source)
lilypond =\
Builder (action = '$LILYPOND --output=${TARGET.base} --include=${TARGET.dir} $SOURCE',
suffix = '.pdf', src_suffix = '.ly')
## emitter = add_ps_target)
env.Append (BUILDERS = {'LilyPond': lilypond})
ABC = Builder (action = '$ABC2LY --output=${TARGET} --strict $SOURCE',
suffix = '.ly', src_suffix = '.abc')
env.Append (BUILDERS = {'ABC': ABC})
def add_log_target (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target + [base + '.log'], source)
def add_tfm_target (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target + [base + '.tfm'], source)
def add_lisp_enc_tex_ly_target (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target + [base + '.lisp', base + '.enc', base + '.tex',
base + 'list.ly'],
source)
def add_cff_cffps_svg (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target + [base + '.cff', base + '.cff.ps', base + '.svg'],
source)
a = 'cd ${TARGET.dir} \
&& MFINPUTS=.:${SOURCE.dir}:$srcdir/${SOURCE.dir}: \
$MF "\\mode:=$MFMODE; nonstopmode; input ${SOURCE.filebase};" \
| grep -v "@\|>>\|w:\|h:";'
tfm = Builder (action = a, suffix = '.tfm', src_suffix = '.mf',
# emitter = lambda t, s, e: add_suffixes (t, s, e, ['.log'], []))
emitter = add_log_target)
env.Append (BUILDERS = {'TFM': tfm})
a = '$PYTHON $MF_TO_TABLE_PY \
--outdir=${TARGET.dir} \
--global-lisp=${TARGET.base}.otf-gtable \
--lisp=${TARGET.base}.lisp \
--enc=${TARGET.base}.enc \
--tex=${TARGET.base}.tex \
--ly=${TARGET.base}list.ly \
${TARGET.base}.log'
gtable = Builder (action = a, suffix = '.otf-gtable', src_suffix = '.log',
emitter = add_lisp_enc_tex_ly_target)
env.Append (BUILDERS = {'GTABLE': gtable})
def add_enc_src (target, source, env):
base = os.path.splitext (str (target[0]))[0]
return (target, source + [base + '.enc'])
# FIXME UGH, should fix --output option for mftrace
a = 'cd ${TARGET.dir} && \
if test -e ${SOURCE.filebase}.enc; then encoding="--encoding=${SOURCE.filebase}.enc"; fi; \
MFINPUTS=$srcdir/mf:.: \
$MFTRACE --formats=pfa --simplify --keep-trying --no-afm \
$$encoding $__verbose \
--include=${TARGET.dir} \
${SOURCE.file}'
pfa = Builder (action = a,
suffix = '.pfa',
src_suffix = '.mf',
emitter = add_enc_src)
env.Append (BUILDERS = {'PFA': pfa})
a = ['(cd ${TARGET.dir} && $FONTFORGE -script ${SOURCE.file})',
# '$PYTHON $srcdir/buildscripts/ps-embed-cff.py ${SOURCE.base}.cff $$(cat ${SOURCE.base}.fontname) ${SOURCE.base}.cff.ps',
'rm -f ${TARGET.dir}/*.scale.pfa']
otf = Builder (action = a,
suffix = '.otf',
src_suffix = '.pe',
# emitter = add_cff_cffps_svg
)
env.Append (BUILDERS = {'OTF': otf})
# Specific builders
env['DIFF_PY'] = '$srcdir/stepmake/bin/package-diff.py'
a = '$PYTHON $DIFF_PY $NO__verbose --outdir=${TARGET.dir}'
patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
env.Append (BUILDERS = {'PATCH': patch})
atvars = [
'BASH',
'DATE',
'sharedstatedir',
'GUILE',
'bindir',
'date',
'datadir',
'lilypond_datadir',
'lilypond_libdir',
'local_lilypond_datadir',
'local_lilypond_libdir',
'localedir',
'PACKAGE',
'package',
'PATHSEP',
'PERL',
'prefix',
'program_prefix',
'program_suffix',
'PYTHON',
'SHELL',
'TOPLEVEL_VERSION',
'step-bindir',
]
# naming
def at_copy (target, source, env):
n = str (source[0])
s = open (n).read ()
for i in atvars:
if env.has_key (i):
s = string.replace (s, '@%s@'% i, env[i])
t = str (target[0])
open (t, 'w').write (s)
# wugh
if os.path.basename (os.path.dirname (str (target[0]))) == 'bin':
os.chmod (t, 0755)
AT_COPY = Builder (action = at_copy, src_suffix = ['.in', '.py', '.sh',])
env.Append (BUILDERS = {'AT_COPY': AT_COPY})
# naming
def at_copy_ext (target, source, env):
n = str (source[0])
s = open (n).read ()
for i in atvars:
if env.has_key (i):
s = string.replace (s, '@%s@'% i, env[i])
# whugh
e = os.path.splitext (n)[1]
t = str (target[0]) + e
open (t, 'w').write (s)
AT_COPY_EXT = Builder (action = at_copy_ext, src_suffix = ['.py', '.sh',])
env.Append (BUILDERS = {'AT_COPY_EXT': AT_COPY_EXT})
MO = Builder (action = 'msgfmt -o $TARGET $SOURCE',
suffix = '.mo', src_suffix = '.po')
env.Append (BUILDERS = {'MO': MO})
# ' '; ?
ugh = 'ln -f po/lilypond.pot ${TARGET.dir}/lilypond.po ; '
a = ugh + 'xgettext --default-domain=lilypond --join \
--output-dir=${TARGET.dir} --add-comments \
--keyword=_ --keyword=_f --keyword=_i $SOURCES'
PO = Builder (action = a, suffix = '.pot',
src_suffix = ['.cc', '.hh', '.py'], multi = 1)
env['potarget'] = os.path.join (env['absbuild'], 'po', env['out'],
'lilypond.pot')
env['pocommand'] = a
ugh = '; mv ${TARGET} ${SOURCE}'
a = 'msgmerge ${SOURCE} ${SOURCE.dir}/lilypond.pot -o ${TARGET}' + ugh
POMERGE = Builder (action = a, suffix = '.pom', src_suffix = '.po')
env.Append (BUILDERS = {'POMERGE': POMERGE})
#UGRr
a = 'BSTINPUTS=$BSTINPUTS $BIB2HTML -o $TARGET $SOURCE'
BIB2HTML = Builder (action = a, suffix = '.html', src_suffix = '.bib')
env.Append (BUILDERS = {'BIB2HTML': BIB2HTML})
a = '$PYTHON $srcdir/buildscripts/lys-to-tely.py \
--name=${TARGET.base} --title="$TITLE" $SOURCES'
LYS2TELY = Builder (action = a, suffix = '.tely', src_suffix = '.ly')
env.Append (BUILDERS = {'LYS2TELY': LYS2TELY})
def mutopia (ly = None, abc = None):
# FIXME: ugr, huh? The values from ../SConstruct get appended
# to the predefined values from this builder context:
# abc2ly/usr/bin/python ..../abc2.py
# Override them again to fix web build...
#BUILD_ABC2LY = '${set__x}$PYTHON $srcdir/scripts/abc2ly.py'
#BUILD_LILYPOND = '$absbuild/$out/lilypond ${__verbose}'
e = env.Copy (
#LILYPOND = BUILD_LILYPOND,
#ABC2LY = BUILD_ABC2LY,
)
if not abc:
abc = base_glob ('*.abc')
if not ly:
ly = base_glob ('*.ly') + map (e.ABC, abc)
pdf = map (e.LilyPond, ly)
# We need lily and mf to build these.
env.Depends (pdf, ['#/lily', '#/mf'])
env.Alias ('doc', pdf)
Export ('mutopia')
def collate (title = 'collated files'):
ly = base_glob ('*.ly')
e = env.Copy (
TITLE = title,
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)'" ''',
__verbose = ' --verbose',
)
#
tely = e.LYS2TELY ('collated-files', ly)
texi = e.TEXI (tely)
# We need lily and mf to build these.
env.Depends (texi, ['#/lily', '#/mf'])
dvi = e.TEXIDVI (texi)
pspdf = e.DVIPDF (dvi)
pdf = e.PSPDF (pspdf)
html = e.HTML (texi)
env.Alias ('doc', pdf)
env.Alias ('doc', html)
Export ('collate')
Export ('env')
|