summaryrefslogtreecommitdiffstats
path: root/common/waf.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-11-06 12:02:47 +1100
committerChris Johns <chrisj@rtems.org>2016-11-06 12:02:47 +1100
commit8330198edc3ec08021f358c3030266194278c5a2 (patch)
treedfab1a147e46f0bc95abfd1d75863da52c1c4e15 /common/waf.py
parentwaf: note about tex noise when running configure. (diff)
downloadrtems-docs-8330198edc3ec08021f358c3030266194278c5a2.tar.bz2
waf: Add support to handle missing Latex packages on hosts they are not available on.
It appears the support for texlive packages on some hosts is variable. This patch lets us add missing packages to our source tree so a PDF can be built on those hosts. The quality of the PDFs created may vary as some short cuts may have been take. For example lato is a font and only the sty file as been added and not the actual font which means it's use will default to another font.
Diffstat (limited to 'common/waf.py')
-rw-r--r--common/waf.py116
1 files changed, 21 insertions, 95 deletions
diff --git a/common/waf.py b/common/waf.py
index 25f3d74..0086be0 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -1,6 +1,8 @@
import sys, os, re
from waflib.Build import BuildContext
+import latex
+
sphinx_min_version = (1, 3)
def cmd_spell(ctx):
@@ -86,6 +88,23 @@ def build_dir_setup(ctx, buildtype):
doctrees = os.path.join(os.path.dirname(output_dir), 'doctrees', buildtype)
return build_dir, output_node, output_dir, doctrees
+def pdf_resources(ctx, buildtype):
+ local_packages = latex.local_packages()
+ if local_packages is not None:
+ packages_base = ctx.path.parent.find_dir('common/latex')
+ if packages_base is None:
+ ctx.fatal('Latex package directory not found')
+ base = packages_base.path_from(ctx.path)
+ srcs = [os.path.join(base, p) for p in local_packages]
+ fnode = ctx.path.get_bld().make_node(buildtype)
+ fnode.mkdir()
+ ctx(
+ features = "subst",
+ is_copy = True,
+ source = srcs,
+ target = [fnode.make_node(p) for p in local_packages]
+ )
+
def html_resources(ctx, buildtype):
for dir_name in ["_static", "_templates"]:
files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir_name)
@@ -108,100 +127,6 @@ def html_resources(ctx, buildtype):
# target = [x.srcpath().replace("../", "") for x in files]
# )
-def latex_configure_tests(conf):
-
- #
- # Using a hint from ita (thank you) :
- # https://github.com/waf-project/waf/blob/master/demos/tex/wscript
- #
- latex_test_preamble = ['\\newif\\ifsphinxKeepOldNames \\sphinxKeepOldNamestrue',
- '\documentclass[a4paper,11pt,english]{report}']
- latex_test_postamble = ['\\begin{document} test \\end{document}']
- latex_tests = {
- 'Bjarne' : ['\\usepackage[Bjarne]{fncychap}'],
- 'alltt' : ['\\usepackage{alltt}'],
- 'amsmath' : ['\\usepackage{amsmath}'],
- 'amssymb' : ['\\usepackage{amssymb}'],
- 'amstext' : ['\\usepackage{amstext}'],
- 'array' : ['\\usepackage{array}'],
- 'atbegshi' : ['\\usepackage{atbegshi}'],
- 'babel' : ['\\usepackage{babel}'],
- 'babel' : ['\\usepackage{babel}'],
- 'calc' : ['\\usepackage{calc}'],
- 'capt-of' : ['\\usepackage{capt-of}'],
- 'charter' : ['\\usepackage{charter}'],
- 'cmap' : ['\\usepackage{cmap}'],
- 'color' : ['\\usepackage{color}'],
- 'eqparbox' : ['\\usepackage{eqparbox}'],
- 'etoolbox' : ['\\usepackage{etoolbox}'],
- 'fancybox' : ['\\usepackage{fancybox}'],
- 'fancyhdr' : ['\\usepackage{fancyhdr}'],
- 'fancyvrb' : ['\\usepackage{fancyvrb}'],
- 'float' : ['\\usepackage{float}'],
- 'fncychap' : ['\\usepackage{fncychap}'],
- 'fontenc' : ['\\usepackage[T1]{fontenc}'],
- 'footnote' : ['\\usepackage{footnote}'],
- 'framed' : ['\\usepackage{framed}'],
- 'graphicx' : ['\\usepackage{graphicx}'],
- 'hypcap' : ['\\usepackage{hyperref}',
- '\\usepackage{hypcap}'],
- 'hyperref' : ['\\usepackage{hyperref}'],
- 'ifplatform' : ['\\usepackage{ifplatform}'],
- 'ifthen' : ['\\usepackage{ifthen}'],
- 'inconsolata' : ['\\usepackage{inconsolata}'],
- 'inputenc' : ['\\usepackage{inputenc}'],
- 'keyval' : ['\\usepackage{keyval}'],
- 'kvoptions' : ['\\usepackage{kvoptions}'],
- 'lato' : ['\\usepackage{lato}'],
- 'lineno' : ['\\usepackage{lineno}'],
- 'longtable' : ['\\usepackage{longtable}'],
- 'makeidx' : ['\\usepackage{makeidx}'],
- 'multirow' : ['\\usepackage{multirow}'],
- 'parskip' : ['\\usepackage{parskip}'],
- 'pdftexcmds' : ['\\usepackage{pdftexcmds}'],
- 'textcomp' : ['\\usepackage{textcomp}'],
- 'threeparttable' : ['\\usepackage{threeparttable}'],
- 'times' : ['\\usepackage{times}'],
- 'titlesec' : ['\\usepackage{titlesec}'],
- 'upquote' : ['\\usepackage{upquote}'],
- 'utf8' : ['\\usepackage[utf8]{inputenc}'],
- 'wrapfig' : ['\\usepackage{wrapfig}'],
- 'xcolor' : ['\\usepackage{xcolor}'],
- 'xstring' : ['\\usepackage{xstring}'],
- }
-
- def build_latex_test(bld):
- def create_tex(test_data):
- return os.linesep.join(latex_test_preamble +
- test_data +
- latex_test_postamble)
- def write_tex_test(tsk):
- tex = create_tex(tsk.env.TEST_DATA)
- tsk.outputs[0].write(tex)
-
- test = bld.kw['tex_test']
- bld.env.TEST = test
- bld.env.TEST_DATA = latex_tests[test]
-
- bld.to_log('%s.tex %s' % (test, '=' * (40 - len(test) + 5)))
- bld.to_log(create_tex(latex_tests[test]))
- bld.to_log('=' * 40)
-
- bld(rule = write_tex_test, target = 'main.tex')
- bld(features = 'tex', type = 'pdflatex', source = 'main.tex', prompt = 0)
-
- fails = 0
- for t in sorted(latex_tests.keys()):
- r = conf.test(build_fun = build_latex_test,
- msg = "Checking for Tex package '%s'" % (t),
- tex_test = t,
- okmsg = 'ok',
- errmsg = 'not found (please install)',
- mandatory = False)
- if r is None:
- fails += 1
- if fails > 0:
- conf.fatal('There are %d Tex package failures. Please fix.' % (fails))
def cmd_configure(ctx):
ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True)
@@ -232,7 +157,7 @@ def cmd_configure(ctx):
if 'PDFLATEXFLAGS' not in ctx.env or \
'-shell-escape' not in ctx.env['PDFLATEXFLAGS']:
ctx.env.append_value('PDFLATEXFLAGS', '-shell-escape')
- latex_configure_tests(ctx)
+ latex.configure_tests(ctx)
else:
ctx.msg('Check for Tex packages', 'skipping, already checked')
ctx.env.BUILD_PDF = 'yes'
@@ -248,6 +173,7 @@ def cmd_configure(ctx):
def doc_pdf(ctx, source_dir, conf_dir):
buildtype = 'latex'
build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
+ pdf_resources(ctx, buildtype)
rule = "${BIN_SPHINX_BUILD} %s -b %s -c %s -d %s %s %s" % \
(sphinx_verbose(ctx), buildtype, conf_dir,
doctrees, source_dir, output_dir)