# -*-python-*- import glob import os import re import sys here = os.getcwd () reldir = str (Dir ('.').srcnode ()) os.chdir (reldir) sources = glob.glob ('*.tely') pngs = glob.glob ('*.png') os.chdir (here) Import ('env') outdir = os.path.join (env['build'], reldir, env['out']) def verbose_opt (env, opt): if env['verbose']: return opt return '' LILYPOND_BIN = env['LILYPOND_BIN'] LILYPONDPREFIX = env['LILYPONDPREFIX'] mfbuild = os.path.join (env['absbuild'], 'mf', env['out']) lilybuild = os.path.join (env['absbuild'], 'lily', env['out']) userbuild = os.path.join (env['absbuild'], 'Documentation/user', env['out']) # more of these? -- howto? env.Depends ('lilypond.texi', os.path.join (mfbuild, 'feta16list.ly')) env.Depends ('lilypond.texi', os.path.join (mfbuild, 'parmesan16list.ly')) # or these env.Depends ('doc', os.path.join (mfbuild, 'feta20.enc')) env.Depends ('doc', os.path.join (mfbuild, 'feta20.enc')) env.Depends ('lilypond.texi', LILYPOND_BIN) env.Depends ('lilypond.texi', 'lilypond-internals.texi') ##env.Depends ('lilypond.texi', 'fonts') # simple: env.Depends ('doc', mfbuild) png_stems = map (lambda x: os.path.splitext (x)[0], pngs) epss = map (env.Png2eps, png_stems) env.Depends ('lilypond.texi', epss) env.Command ('lilypond-internals.texi', LILYPOND_BIN, ('(cd ${TARGET.dir} && \ LILYPONDPREFIX=%(LILYPONDPREFIX)s %(LILYPOND_BIN)s ' \ + verbose_opt (env, ' --verbose') \ + ' ' + os.path.join (env['srcdir'], 'ly/generate-documentation')\ + ')') % vars ()) doc_stems = map (lambda x: os.path.splitext (x)[0], sources) texis = map (env.Tely2texi, doc_stems) dvis = map (env.Texi2dvi, doc_stems) pss = map (env.PostScript, map (lambda x: x + '.dvi', doc_stems)) pdfs = map (env.Dvi2pdf, doc_stems) def file_subst (file_name, find, subst): find_re = re.compile (find, re.MULTILINE) s = open (file_name).read () t = re.sub (find_re, subst, s) if s != t: os.rename (file_name, file_name + '~') h = open (file_name, "w") h.write (t) h.close () docdir = os.path.join (env['srcdir'], 'Documentation') out = env['out'] srcdir = env['srcdir'] verbose = verbose_opt (env, ' --verbose') a = ('makeinfo -I%(reldir)s -I${SOURCE.dir}'\ + ' --output=${TARGET.dir}'\ + ' --css-include=%(docdir)s/texinfo.css'\ + ' --html%(verbose)s'\ + ' $SOURCE &&' \ + ' makeinfo -I%(reldir)s -I${SOURCE.dir}' \ + ' --output=$TARGET' \ + ' --css-include=%(docdir)s/texinfo.css' \ + ' --html --no-split --no-headers %(verbose)s' \ + ' $SOURCE') % vars () def url_fixup (target, source, env): file_subst (str (target[0]), '\.\./lilypond-internals', 'lilypond-internals/') c = 'pwd; ln -f %(userbuild)s/*.png %(userbuild)s/*.ly ${TARGET.dir}/' % vars () e = env.Copy () e.Command ('lilypond/lilypond.html', 'lilypond.texi', [a, url_fixup, c]) e.Command ('lilypond-internals/lilypond-internals.html', 'lilypond-internals.texi', a) env.Alias ('doc', texis) env.Alias ('doc', dvis) env.Alias ('doc', pss) env.Alias ('doc', pdfs) env.Alias ('doc', 'lilypond-internals/lilypond.html') env.Alias ('doc', 'lilypond-internals/lilypond-internals.html') #testing all_sources = ['SConscript',] + sources + pngs x = env.Tar (env['tarball'], all_sources)