diff options
Diffstat (limited to 'common/waf.py')
-rw-r--r-- | common/waf.py | 79 |
1 files changed, 66 insertions, 13 deletions
diff --git a/common/waf.py b/common/waf.py index 066048d..77a46ed 100644 --- a/common/waf.py +++ b/common/waf.py @@ -16,10 +16,15 @@ 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"' % (ctx.env.RELEASE, ctx.env.VERSION) + return '-Drelease="%s" -Dversion="%s" -Drtems_major="%s" ' \ + '-Drtems_minor="%s" -D rtems_revision="%s"' \ + % (ctx.env.RELEASE, ctx.env.VERSION, ctx.env.RTEMS_MAJOR, + ctx.env.RTEMS_MINOR, ctx.env.RTEMS_REVISION) def sphinx_cmdline(ctx, build_type, conf_dir, doctrees, source_dir, output_dir, configs = []): @@ -81,9 +86,12 @@ 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: + ctx.fatal('no sphinx support found; please install') + try: # sphinx.version_info was introduced in sphinx ver 1.2 version = sphinx.version_info # version looks like (1, 7, 0, 'final', 0)) @@ -109,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): @@ -175,13 +186,46 @@ def check_sphinx_extension(ctx, extension): def run_sphinx(bld): rst_node = bld.srcnode.make_node('testbuild/contents.rst') rst_node.parent.mkdir() - rst_node.write('.. COMMENT test sphinx\n') + 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'" % (extension)) try: ctx.run_build(fragment = 'xx', - rule = "${BIN_SPHINX_BUILD} -b html -D extensions=%s -C . out" % (extension), + rule = "${BIN_SPHINX_BUILD} -b html -D extensions=%s -c . . out" % (extension), + 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 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: @@ -195,8 +239,12 @@ def cmd_configure(ctx): 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 ") @@ -220,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') @@ -227,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. @@ -260,27 +310,27 @@ def cmd_configure(ctx): ctx.fatal('Unsupported latex engine: %s' % (conf.latex_engine)) ctx.env.BUILD_PDF = 'yes' - ctx.envBUILD_SINGLEHTML = 'no' + ctx.env.BUILD_SINGLEHTML = 'no' 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.envBUILD_PLANTUML = 'no' + 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.envBUILD_DITAA = 'no' + ctx.env.BUILD_DITAA = 'no' if ctx.options.ditaa: # # We use DITAA via PlantUML @@ -293,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', []) @@ -329,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), |