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