summaryrefslogtreecommitdiffstats
path: root/common/waf.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/waf.py')
-rw-r--r--common/waf.py45
1 files changed, 42 insertions, 3 deletions
diff --git a/common/waf.py b/common/waf.py
index 0bd166a..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.