Changeset a316b1f in rtems-docs for common/waf.py
- Timestamp:
- 01/20/16 01:37:04 (7 years ago)
- Branches:
- 4.11, 5, am, master
- Children:
- 7c1f215
- Parents:
- 89f2347
- git-author:
- Amar Takhar <amar@…> (01/20/16 01:37:04)
- git-committer:
- Amar Takhar <verm@…> (05/03/16 00:51:25)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/waf.py
r89f2347 ra316b1f 2 2 from waflib.Build import BuildContext 3 3 4 sphinx_min_version = (1,3) 4 5 5 sphinx_min_version = (1,3)6 6 7 7 def cmd_spell(ctx): … … 36 36 37 37 38 39 38 def check_sphinx_version(ctx, minver): 40 # try:41 39 version = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD + ['--version']).split(" ")[-1:][0] 42 40 ver = tuple(map(int, version.split("."))) 43 # except Exception:44 # ctx.fatal("Version check failed please report")45 41 46 42 if ver < minver: … … 49 45 return ver 50 46 47 51 48 def cmd_configure(ctx): 52 49 ctx.load('tex') 53 54 50 55 51 if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX: … … 58 54 ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory=True) 59 55 ctx.find_program("aspell", var="BIN_ASPELL", mandatory=False) 60 56 ctx.find_program("inliner", var="BIN_INLINER", mandatory=False) 61 57 62 58 ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version) … … 66 62 67 63 64 def doc_pdf(ctx, source_dir, conf_dir): 65 ctx( 66 rule = "${BIN_SPHINX_BUILD} -b latex -c %s -j %d -d build/doctrees %s build/latex" % (conf_dir, ctx.options.jobs, source_dir), 67 cwd = ctx.path.abspath(), 68 source = ctx.path.ant_glob('**/*.rst'), 69 target = "latex/%s.tex" % ctx.path.name 70 ) 71 72 ctx.add_group() 73 74 ctx( 75 features = 'tex', 76 cwd = "%s/latex/" % ctx.path.get_bld().abspath(), 77 type = 'pdflatex', 78 source = ctx.bldnode.find_or_declare("latex/%s.tex" % ctx.path.name), 79 prompt = 0 80 ) 81 82 83 def doc_singlehtml(ctx, source_dir, conf_dir): 84 if not ctx.env.BIN_INLINER: 85 ctx.fatal("Node inliner is required install with 'npm install -g inliner' (https://github.com/remy/inliner)") 86 87 ctx( 88 rule = "${BIN_SPHINX_BUILD} -b singlehtml -c %s -j %d -d build/doctrees %s build/singlehtml" % (conf_dir, ctx.options.jobs, source_dir), 89 cwd = ctx.path.abspath(), 90 source = ctx.path.ant_glob('**/*.rst'), 91 target = "singlehtml/index.html" 92 ) 93 94 ctx.add_group() 95 96 ctx( 97 rule = "${BIN_INLINER} ${SRC} > ${TGT}", 98 source = "singlehtml/index.html", 99 target = "singlehtml/%s.html" % ctx.path.name 100 ) 101 102 103 def html_resources(ctx): 104 for dir in ["_static", "_templates"]: 105 files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir) 106 ctx.path.get_bld().make_node(dir).mkdir() # dirs 107 108 ctx( 109 features = "subst", 110 is_copy = True, 111 source = files, 112 target = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files] 113 ) 114 68 115 69 116 def cmd_build(ctx, conf_dir=".", source_dir="."): 70 117 srcnode = ctx.srcnode.abspath() 71 118 119 if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX: 120 ctx.fatal('The programs pdflatex and makeindex are required') 121 122 72 123 if ctx.options.pdf: 73 74 ctx( 75 rule = "${BIN_SPHINX_BUILD} -b latex -c %s -j %d -d build/doctrees %s build/latex" % (conf_dir, ctx.options.jobs, source_dir), 76 cwd = ctx.path.abspath(), 77 source = ctx.path.ant_glob('**/*.rst'), 78 target = "latex/%s.tex" % ctx.path.name 79 ) 80 81 ctx.add_group() 82 83 ctx( 84 features = 'tex', 85 cwd = "%s/latex/" % ctx.path.get_bld().abspath(), 86 type = 'pdflatex', 87 source = ctx.bldnode.find_or_declare("latex/%s.tex" % ctx.path.name), 88 prompt = 0 89 ) 90 124 doc_pdf(ctx, source_dir, conf_dir) 125 elif ctx.options.singlehtml: 126 html_resources(ctx) 127 doc_singlehtml(ctx, source_dir, conf_dir) 91 128 else: 92 # Copy HTML resources. 93 for dir in ["_static", "_templates"]: 94 files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir) 95 ctx.path.get_bld().make_node(dir).mkdir() # dirs 96 97 ctx( 98 features = "subst", 99 is_copy = True, 100 source = files, 101 target = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files] 102 ) 103 129 html_resources(ctx) 104 130 ctx( 105 131 rule = "${BIN_SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir), … … 111 137 def cmd_options(ctx): 112 138 ctx.add_option('--pdf', action='store_true', default=False, help="Build PDF.") 139 ctx.add_option('--singlehtml', action='store_true', default=False, help="Build Single HTML file, requires Node Inliner") 140 113 141 114 142 def cmd_options_path(ctx): … … 152 180 153 181 cmd_build(ctx, conf_dir="build", source_dir="build") 154 155
Note: See TracChangeset
for help on using the changeset viewer.