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