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