mirror of
https://git.rtems.org/rtems-docs/
synced 2025-05-14 12:49:18 +08:00
waf: Add an install command.
This commit is contained in:
parent
47aad7a5c3
commit
dd43d0b0f8
110
common/waf.py
110
common/waf.py
@ -79,39 +79,70 @@ def cmd_configure(ctx):
|
|||||||
ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
|
ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
|
||||||
|
|
||||||
|
|
||||||
|
def html_resources(ctx):
|
||||||
|
for dir_name in ["_static", "_templates"]:
|
||||||
|
files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir_name)
|
||||||
|
fnode = ctx.path.get_bld().make_node(os.path.join('html', dir_name))
|
||||||
|
fnode.mkdir() # dirs
|
||||||
|
ctx(
|
||||||
|
features = "subst",
|
||||||
|
is_copy = True,
|
||||||
|
source = files,
|
||||||
|
target = [fnode.make_node(x.name) for x in files]
|
||||||
|
)
|
||||||
|
|
||||||
|
# copy images
|
||||||
|
# ctx.path.get_bld().make_node("images").mkdir()
|
||||||
|
# files = ctx.path.parent.ant_glob("images/**")
|
||||||
|
# ctx(
|
||||||
|
# features = "subst",
|
||||||
|
# is_copy = True,
|
||||||
|
# source = files,
|
||||||
|
# target = [x.srcpath().replace("../", "") for x in files]
|
||||||
|
# )
|
||||||
|
|
||||||
def doc_pdf(ctx, source_dir, conf_dir):
|
def doc_pdf(ctx, source_dir, conf_dir):
|
||||||
if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
|
if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
|
||||||
ctx.fatal('The programs pdflatex and makeindex are required')
|
ctx.fatal('The programs pdflatex and makeindex are required')
|
||||||
|
|
||||||
build_dir = ctx.path.get_bld().relpath()
|
build_dir = ctx.path.get_bld().relpath()
|
||||||
output_dir = os.path.join(ctx.path.get_bld().abspath(), 'latex')
|
output_node = ctx.path.get_bld().make_node('latex')
|
||||||
|
output_dir = output_node.abspath()
|
||||||
|
|
||||||
ctx(
|
ctx(
|
||||||
rule = "${BIN_SPHINX_BUILD} %s -b latex -c %s -d build/%s/doctrees %s %s" % (sphinx_verbose(ctx), conf_dir, build_dir, source_dir, output_dir),
|
rule = "${BIN_SPHINX_BUILD} %s -b latex -c %s -d build/%s/doctrees %s %s" % (sphinx_verbose(ctx), conf_dir, build_dir, source_dir, output_dir),
|
||||||
cwd = ctx.path,
|
cwd = ctx.path,
|
||||||
source = ctx.path.ant_glob('**/*.rst'),
|
source = ctx.path.ant_glob('**/*.rst'),
|
||||||
target = ctx.path.find_or_declare("latex/%s.tex" % (ctx.path.name))
|
target = ctx.path.find_or_declare("latex/%s.tex" % (ctx.path.name))
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.add_group()
|
ctx.add_group()
|
||||||
|
|
||||||
ctx(
|
ctx(
|
||||||
features = 'tex',
|
features = 'tex',
|
||||||
cwd = output_dir,
|
cwd = output_dir,
|
||||||
type = 'pdflatex',
|
type = 'pdflatex',
|
||||||
source = "latex/%s.tex" % ctx.path.name,
|
source = "latex/%s.tex" % ctx.path.name,
|
||||||
prompt = 0
|
prompt = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ctx.install_files('${PREFIX}/%s' % (ctx.path.name),
|
||||||
|
'latex/%s.pdf' % (ctx.path.name),
|
||||||
|
cwd = output_node,
|
||||||
|
quiet = True)
|
||||||
|
|
||||||
def doc_singlehtml(ctx, source_dir, conf_dir):
|
def doc_singlehtml(ctx, source_dir, conf_dir):
|
||||||
if not ctx.env.BIN_INLINER:
|
if not ctx.env.BIN_INLINER:
|
||||||
ctx.fatal("Node inliner is required install with 'npm install -g inliner' (https://github.com/remy/inliner)")
|
ctx.fatal("Node inliner is required install with 'npm install -g inliner' (https://github.com/remy/inliner)")
|
||||||
|
|
||||||
|
html_resources(ctx)
|
||||||
|
|
||||||
ctx(
|
ctx(
|
||||||
rule = "${BIN_SPHINX_BUILD} -b singlehtml -c %s -j %d -d build/doctrees %s build/singlehtml" % (conf_dir, ctx.options.jobs, source_dir),
|
rule = "${BIN_SPHINX_BUILD} -b singlehtml -c %s -j %d -d build/doctrees %s build/singlehtml" % (conf_dir, ctx.options.jobs, source_dir),
|
||||||
cwd = ctx.path.abspath(),
|
cwd = ctx.path.abspath(),
|
||||||
source = ctx.path.ant_glob('**/*.rst'),
|
source = ctx.path.ant_glob('**/*.rst'),
|
||||||
target = "singlehtml/index.html"
|
target = "singlehtml/index.html",
|
||||||
|
install_path = None
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.add_group()
|
ctx.add_group()
|
||||||
@ -119,9 +150,32 @@ def doc_singlehtml(ctx, source_dir, conf_dir):
|
|||||||
ctx(
|
ctx(
|
||||||
rule = "${BIN_INLINER} ${SRC} > ${TGT}",
|
rule = "${BIN_INLINER} ${SRC} > ${TGT}",
|
||||||
source = "singlehtml/index.html",
|
source = "singlehtml/index.html",
|
||||||
target = "singlehtml/%s.html" % ctx.path.name
|
target = "singlehtml/%s.html" % ctx.path.name,
|
||||||
|
install_path = None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def doc_html(ctx, conf_dir, source_dir):
|
||||||
|
|
||||||
|
html_resources(ctx)
|
||||||
|
|
||||||
|
build_dir = ctx.path.get_bld().relpath()
|
||||||
|
output_node = ctx.path.get_bld().make_node('html')
|
||||||
|
output_dir = output_node.abspath()
|
||||||
|
|
||||||
|
ctx(
|
||||||
|
rule = "${BIN_SPHINX_BUILD} %s -b html -c %s -d build/%s/doctrees %s %s" % (sphinx_verbose(ctx), conf_dir, build_dir, source_dir, output_dir),
|
||||||
|
cwd = ctx.path,
|
||||||
|
source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'),
|
||||||
|
target = ctx.path.find_or_declare('html/index.html'),
|
||||||
|
install_path = None
|
||||||
|
)
|
||||||
|
|
||||||
|
ctx.install_files('${PREFIX}/%s' % (ctx.path.name),
|
||||||
|
output_node.ant_glob('**/*'),
|
||||||
|
cwd = output_node,
|
||||||
|
relative_trick = True,
|
||||||
|
quiet = True)
|
||||||
|
|
||||||
def is_top_build(ctx):
|
def is_top_build(ctx):
|
||||||
from_top = False
|
from_top = False
|
||||||
if ctx.env['BUILD_FROM_TOP'] and ctx.env['BUILD_FROM_TOP'] == 'yes':
|
if ctx.env['BUILD_FROM_TOP'] and ctx.env['BUILD_FROM_TOP'] == 'yes':
|
||||||
@ -144,28 +198,6 @@ def build_dir_setup(ctx):
|
|||||||
ctx.bldnode.make_node(where).mkdir()
|
ctx.bldnode.make_node(where).mkdir()
|
||||||
return where
|
return where
|
||||||
|
|
||||||
def html_resources(ctx):
|
|
||||||
for dir_name in ["_static", "_templates"]:
|
|
||||||
files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir_name)
|
|
||||||
fnode = ctx.path.get_bld().make_node(os.path.join('html', dir_name))
|
|
||||||
fnode.mkdir() # dirs
|
|
||||||
ctx(
|
|
||||||
features = "subst",
|
|
||||||
is_copy = True,
|
|
||||||
source = files,
|
|
||||||
target = [fnode.make_node(x.name) for x in files]
|
|
||||||
)
|
|
||||||
|
|
||||||
# copy images
|
|
||||||
# ctx.path.get_bld().make_node("images").mkdir()
|
|
||||||
# files = ctx.path.parent.ant_glob("images/**")
|
|
||||||
# ctx(
|
|
||||||
# features = "subst",
|
|
||||||
# is_copy = True,
|
|
||||||
# source = files,
|
|
||||||
# target = [x.srcpath().replace("../", "") for x in files]
|
|
||||||
# )
|
|
||||||
|
|
||||||
def cmd_build(ctx, conf_dir = ".", source_dir = "."):
|
def cmd_build(ctx, conf_dir = ".", source_dir = "."):
|
||||||
build_dir_setup(ctx)
|
build_dir_setup(ctx)
|
||||||
|
|
||||||
@ -177,15 +209,7 @@ def cmd_build(ctx, conf_dir = ".", source_dir = "."):
|
|||||||
html_resources(ctx)
|
html_resources(ctx)
|
||||||
doc_singlehtml(ctx, source_dir, conf_dir)
|
doc_singlehtml(ctx, source_dir, conf_dir)
|
||||||
else:
|
else:
|
||||||
html_resources(ctx)
|
doc_html(ctx, source_dir, conf_dir)
|
||||||
build_dir = ctx.path.get_bld().relpath()
|
|
||||||
output_dir = os.path.join(ctx.path.get_bld().abspath(), 'html')
|
|
||||||
ctx(
|
|
||||||
rule = "${BIN_SPHINX_BUILD} %s -b html -c %s -d build/%s/doctrees %s %s" % (sphinx_verbose(ctx), conf_dir, build_dir, source_dir, output_dir),
|
|
||||||
cwd = ctx.path,
|
|
||||||
source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'),
|
|
||||||
target = ctx.path.find_or_declare('html/index.html')
|
|
||||||
)
|
|
||||||
|
|
||||||
def cmd_options(ctx):
|
def cmd_options(ctx):
|
||||||
ctx.add_option('--sphinx-verbose', action='store', default="-Q", help="Sphinx verbose.")
|
ctx.add_option('--sphinx-verbose', action='store', default="-Q", help="Sphinx verbose.")
|
||||||
|
@ -2,5 +2,9 @@ from sys import path
|
|||||||
from os.path import abspath
|
from os.path import abspath
|
||||||
path.append(abspath('../common/'))
|
path.append(abspath('../common/'))
|
||||||
|
|
||||||
from waf import cmd_configure as configure, cmd_build as build, \
|
from waf import cmd_configure as configure, \
|
||||||
spell, cmd_spell, cmd_options as options, linkcheck, cmd_linkcheck
|
cmd_build as build, \
|
||||||
|
spell, \
|
||||||
|
cmd_spell, \
|
||||||
|
cmd_options as options, \
|
||||||
|
linkcheck, cmd_linkcheck
|
||||||
|
5
wscript
5
wscript
@ -27,9 +27,12 @@ def options(opt):
|
|||||||
def configure(conf):
|
def configure(conf):
|
||||||
for b in building:
|
for b in building:
|
||||||
conf.recurse(b)
|
conf.recurse(b)
|
||||||
|
|
||||||
conf.env['BUILD_FROM_TOP'] = 'yes'
|
conf.env['BUILD_FROM_TOP'] = 'yes'
|
||||||
|
|
||||||
def build(ctx):
|
def build(ctx):
|
||||||
for b in building:
|
for b in building:
|
||||||
ctx.recurse(b)
|
ctx.recurse(b)
|
||||||
|
|
||||||
|
def install(ctx):
|
||||||
|
for b in building:
|
||||||
|
ctx.recurse(b)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user