]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/SConscript
* SConstruct:
[lilypond.git] / Documentation / user / SConscript
1 # -*-python-*-
2
3 import glob
4 import os
5 import re
6 import sys
7
8 here = os.getcwd ()
9 reldir = str (Dir ('.').srcnode ())
10 os.chdir (reldir)
11 sources = glob.glob ('*.tely')
12 pngs = glob.glob ('*.png')
13 os.chdir (here)
14
15 Import ('env')
16 e = env.Copy ()
17 outdir = os.path.join (env['build'], reldir, env['out'])
18
19 # Too late
20 e.Append (LILYPOND_BOOK_PATH = [os.path.join (env['srcdir'], reldir, 'user')])
21 e['LILYPOND_BOOK_PATH'].append (os.path.join (env['srcdir'], reldir, 'user'))
22
23 def verbose_opt (env, opt):
24         if env['verbose']:
25                 return opt
26         return ''
27
28 LILYPOND_BIN = env['LILYPOND_BIN']
29 LILYPONDPREFIX = env['LILYPONDPREFIX']
30
31 mfbuild = os.path.join (env['absbuild'], 'mf', env['out'])
32 lilybuild = os.path.join (env['absbuild'], 'lily', env['out'])
33 userbuild = os.path.join (env['absbuild'], 'Documentation/user', env['out'])
34
35 # more of these? -- howto?
36 e.Depends ('lilypond.texi', os.path.join (mfbuild, 'feta16list.ly'))
37 e.Depends ('lilypond.texi', os.path.join (mfbuild, 'parmesan16list.ly'))
38 # or these
39 e.Depends ('doc', os.path.join (mfbuild, 'feta20.enc'))
40 e.Depends ('doc', os.path.join (mfbuild, 'feta20.enc'))
41
42 e.Depends ('lilypond.texi', LILYPOND_BIN)
43 e.Depends ('lilypond.texi', 'lilypond-internals.texi')
44
45 e.Depends ('lilypond.texi', 'fonts')
46
47 png_stems = map (lambda x: os.path.splitext (x)[0], pngs)
48 epss = map (e.Png2eps, png_stems)
49 e.Depends ('lilypond.texi', epss)
50
51 e.Command ('lilypond-internals.texi', LILYPOND_BIN,
52            ('(cd ${TARGET.dir} && \
53            LILYPONDPREFIX=%(LILYPONDPREFIX)s %(LILYPOND_BIN)s ' \
54             + verbose_opt (env, ' --verbose') \
55             + ' ' + os.path.join (env['srcdir'], 'ly/generate-documentation')\
56             + ')') % vars ())
57
58 doc_stems = map (lambda x: os.path.splitext (x)[0], sources)
59 texis = map (e.Tely2texi, doc_stems)
60 dvis = map (e.Texi2dvi, doc_stems)
61 pss = map (e.PostScript, map (lambda x: x + '.dvi', doc_stems))
62 pdfs = map (e.Dvi2pdf, doc_stems)
63
64
65 def file_subst (file_name, find, subst):
66         find_re = re.compile (find, re.MULTILINE)
67         s = open (file_name).read ()
68         t = re.sub (find_re, subst, s)
69         if s != t:
70                 os.rename (file_name, file_name + '~')
71                 h = open (file_name, "w")
72                 h.write (t)
73                 h.close ()
74
75 docdir = os.path.join (env['srcdir'], 'Documentation')
76 out = env['out']
77 srcdir = env['srcdir']
78 verbose = verbose_opt (env, ' --verbose')
79 a = ('makeinfo -I%(reldir)s -I${SOURCE.dir}'\
80      + ' --output=${TARGET.dir}'\
81      + ' --css-include=%(docdir)s/texinfo.css'\
82      + ' --html%(verbose)s'\
83      + ' $SOURCE &&' \
84      + ' makeinfo -I%(reldir)s -I${SOURCE.dir}' \
85      + ' --output=$TARGET' \
86      + ' --css-include=%(docdir)s/texinfo.css' \
87      + ' --html --no-split --no-headers %(verbose)s' \
88      + ' $SOURCE') % vars ()
89 def url_fixup (target, source, env):
90         file_subst (str (target[0]),
91                     '\.\./lilypond-internals', 'lilypond-internals/')
92 c = 'pwd; ln -f %(userbuild)s/*.png %(userbuild)s/*.ly ${TARGET.dir}/' % vars ()
93 e.Command ('lilypond/lilypond.html', 'lilypond.texi', [a, url_fixup, c])
94 e.Command ('lilypond-internals/lilypond-internals.html',
95            'lilypond-internals.texi', a)
96
97 e.Alias ('doc', texis)
98 e.Alias ('doc', dvis)
99 e.Alias ('doc', pss)
100 e.Alias ('doc', pdfs)
101
102 e.Alias ('doc', 'lilypond-internals/lilypond.html')
103 e.Alias ('doc', 'lilypond-internals/lilypond-internals.html')
104
105 #testing
106 all_sources = ['SConscript',] + sources + pngs
107 x = env.Tar (env['tarball'], all_sources)