diff options
Diffstat (limited to 'common/waf.py')
-rw-r--r-- | common/waf.py | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/common/waf.py b/common/waf.py index fa9aecb..77a46ed 100644 --- a/common/waf.py +++ b/common/waf.py @@ -16,7 +16,9 @@ from waflib.Build import BuildContext import latex import conf +# If you do not want to check for a maximum version, set it to None. sphinx_min_version = (1, 3) +sphinx_max_version = None def version_cmdline(ctx): return '-Drelease="%s" -Dversion="%s" -Drtems_major="%s" ' \ @@ -84,7 +86,7 @@ class linkcheck(BuildContext): cmd = 'linkcheck' fun = 'cmd_linkcheck' -def check_sphinx_version(ctx, minver): +def check_sphinx_version(ctx, minver, maxver): try: import sphinx except: @@ -115,6 +117,9 @@ def check_sphinx_version(ctx, minver): ctx.fatal("Sphinx version cannot be checked or Sphinx is not installed") if ver < minver: ctx.fatal("Sphinx version is too old: %s" % ".".join(map(str, ver))) + if maxver is not None: + if ver > maxver: + ctx.fatal("Sphinx version is too new: %s" % ".".join(map(str, ver))) return ver def sphinx_options(ctx): @@ -200,14 +205,46 @@ def check_sphinx_extension(ctx, extension): ctx.fatal('The configuration failed') ctx.end_msg('found') +def check_sphinx_theme(ctx, theme): + def run_sphinx(bld): + rst_node = bld.srcnode.make_node('testbuild/contents.rst') + rst_node.parent.mkdir() + rst_node.write('.. COMMENT test sphinx' + os.linesep) + bib_node = bld.srcnode.make_node('testbuild/refs.bib') + bib_node.write(os.linesep) + conf_node = bld.srcnode.make_node('testbuild/conf.py') + conf_node.write(os.linesep.join(["master_doc='contents'", + "bibtex_bibfiles = ['refs.bib']"])) + bld(rule = bld.kw['rule'], source = rst_node) + + ctx.start_msg("Checking for '%s'" % (theme)) + try: + theme__ = theme.replace('-', '_') + bld_rule = '${BIN_SPHINX_BUILD} -b html -c . ' + bld_rule += '-D html_theme=%s ' % (theme__) + bld_rule += '-D "html_them_path=[%s.get_html_theme_path()]" ' % (theme__) + bld_rule += '. out' + ctx.run_build(fragment = 'xx', + rule = bld_rule, + build_fun = run_sphinx, + env = ctx.env) + except ctx.errors.ConfigurationError: + ctx.end_msg('not found (see README.txt)', 'RED') + ctx.fatal('The configuration failed') + ctx.end_msg('found') + def cmd_configure(ctx): check_sphinx = not ctx.env.BIN_SPHINX_BUILD if check_sphinx: ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True) ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False) - ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version) - ver = check_sphinx_version(ctx, sphinx_min_version) + if sphinx_max_version is None: + ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version) + else: + ctx.start_msg("Checking if Sphinx is between %s.%s and %s.%s" % (sphinx_min_version + sphinx_max_version)) + + ver = check_sphinx_version(ctx, sphinx_min_version, sphinx_max_version) ctx.end_msg("yes (%s)" % ".".join(map(str, ver))) ctx.start_msg("Checking Sphinx Options ") @@ -231,6 +268,7 @@ def cmd_configure(ctx): # # Check extensions. # + check_sphinx_theme(ctx, 'sphinx-rtd-theme') check_sphinx_extension(ctx, 'sphinx.ext.autodoc') check_sphinx_extension(ctx, 'sphinx.ext.coverage') check_sphinx_extension(ctx, 'sphinx.ext.doctest') @@ -238,6 +276,7 @@ def cmd_configure(ctx): check_sphinx_extension(ctx, 'sphinx.ext.intersphinx') check_sphinx_extension(ctx, 'sphinx.ext.mathjax') check_sphinx_extension(ctx, 'sphinxcontrib.bibtex') + check_sphinx_extension(ctx, 'sphinxcontrib.jquery') # # Optional builds. @@ -275,21 +314,21 @@ def cmd_configure(ctx): if ctx.options.singlehtml: check_inliner = not ctx.env.BIN_INLINER if check_inliner: - ctx.env.BUILD_SINGLEHTML = 'yes' ctx.find_program("inliner", var = "BIN_INLINER", mandatory = False) if not ctx.env.BIN_INLINER: ctx.fatal("Node.js inliner is required install with 'npm install -g inliner' " + "(https://github.com/remy/inliner)") + ctx.env.BUILD_SINGLEHTML = 'yes' ctx.env.BUILD_PLANTUML = 'no' if ctx.options.plantuml: check_plantuml = not ctx.env.BIN_PUML if check_plantuml: - ctx.env.BUILD_PLANTUML = 'yes' ctx.find_program("puml", var = "BIN_PUML", mandatory = False) if not ctx.env.BIN_PUML: ctx.fatal("Node.js puml is required install with 'npm install -g node-plantuml' " + "(https://www.npmjs.com/package/node-plantuml)") + ctx.env.BUILD_PLANTUML = 'yes' ctx.env.BUILD_DITAA = 'no' if ctx.options.ditaa: @@ -304,10 +343,10 @@ def cmd_configure(ctx): "(https://www.npmjs.com/package/node-plantuml)") check_ditaa = not ctx.env.BIN_DITAA if check_ditaa: - ctx.env.BUILD_DITAA = 'yes' ctx.find_program("ditaa", var = "BIN_DITAA", mandatory = False) if not ctx.env.BIN_DITAA: ctx.fatal("DITAA not found, plase install") + ctx.env.BUILD_DITAA = 'yes' def sources_exclude(ctx, sources): exclude = sources.get('exclude', []) @@ -340,12 +379,15 @@ def doc_pdf(ctx, source_dir, conf_dir, sources): target = ctx.path.find_or_declare("%s/%s.tex" % (buildtype, ctx.path.name)) ) + env_latex = ctx.env.derive() + env_latex.TEXINPUTS = output_dir + ':' ctx( features = 'tex', cwd = output_dir, type = ctx.env.LATEX_CMD, source = "%s/%s.tex" % (buildtype, ctx.path.name), - prompt = 0 + prompt = 0, + env = env_latex ) ctx.install_files('${PREFIX}', '%s/%s.pdf' % (buildtype, ctx.path.name), |