summaryrefslogtreecommitdiffstats
path: root/common/waf.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/waf.py')
-rw-r--r--common/waf.py112
1 files changed, 106 insertions, 6 deletions
diff --git a/common/waf.py b/common/waf.py
index 80e8b28..25f3d74 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -108,6 +108,101 @@ 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)
ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False)
@@ -129,13 +224,18 @@ def cmd_configure(ctx):
#
ctx.env.BUILD_PDF = 'no'
if ctx.options.pdf:
+ check_tex = not ctx.env.PDFLATEX
+ if check_tex:
+ ctx.load('tex')
+ if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
+ ctx.fatal('The programs pdflatex and makeindex are required for PDF output')
+ 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)
+ else:
+ ctx.msg('Check for Tex packages', 'skipping, already checked')
ctx.env.BUILD_PDF = 'yes'
- ctx.load('tex')
- if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
- ctx.fatal('The programs pdflatex and makeindex are required for PDF output')
- if 'PDFLATEXFLAGS' not in ctx.env or \
- '-shell-escape' not in ctx.env['PDFLATEXFLAGS']:
- ctx.env.append_value('PDFLATEXFLAGS', '-shell-escape')
ctx.envBUILD_SINGLEHTML = 'no'
if ctx.options.singlehtml: