summaryrefslogtreecommitdiffstats
path: root/doc/user/SConstruct
blob: 69792ae3e63e09c965fa838063560aca27e830c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
# SPDX-License-Identifier: MIT

"""
SConstruct file for building SCons User Guide..

This is usually invoked as a separate build by the top-level SCons build.

If invoked directly, can add SKIP_PDF=1 to avoid pdf and epub generation.
"""

import os

env = Environment(
    ENV={'PATH': os.environ['PATH']},
    tools=['docbook', 'gs', 'zip'],
    toolpath=['../../SCons/Tool'],
    # DOCBOOK_XSLTPROCFLAGS="--stringparam  fop.extensions  1",
    DOCBOOK_DEFAULT_XSL_HTML='html.xsl',
    DOCBOOK_DEFAULT_XSL_HTMLCHUNKED='chtml.xsl',
    DOCBOOK_DEFAULT_XSL_PDF='pdf.xsl',
)

skip_pdf = ARGUMENTS.get('SKIP_PDF', False)
has_pdf = False
if not skip_pdf and any((env.WhereIs('fop'), env.WhereIs('xep'))):
    has_pdf = True

#
# UserGuide for SCons
#
env.DocbookXInclude('scons_xi.xml', 'main.xml')
env.DocbookXslt('scons_ex.xml', 'scons_xi.xml', xsl='../xslt/xinclude_examples.xslt')
env.DocbookXInclude('scons_exi.xml', 'scons_ex.xml')
env.DocbookXslt('scons_db.xml', 'scons_exi.xml', xsl='../xslt/to_docbook.xslt')
env.DocbookHtml('index.html', 'scons_db.xml')
env.DocbookHtmlChunked('index.html', 'scons_db.xml', base_dir='scons-user/')
if has_pdf:
    env.DocbookPdf('scons-user.pdf', 'scons_db.xml')

has_gs = False
if env.WhereIs('gs'):
    has_gs = True

#
# Create the EPUB format
#
if has_gs and has_pdf:
    jpg = env.Gs(
        'OEBPS/cover.jpg',
        'scons-user.pdf',
        GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=100 -r72x72 -q',
    )
    epub = env.DocbookEpub('scons-user.epub', 'scons_db.xml', xsl='epub.xsl')
    env.Depends(epub, jpg)