[rtems commit] waf: Add an install command.

Chris Johns chrisj at rtems.org
Sun Oct 30 21:48:49 UTC 2016


Module:    rtems
Branch:    master
Commit:    dd43d0b0f86c277bcd33b1f76e41209c23af6c49
Changeset: http://git.rtems.org/rtems/commit/?id=dd43d0b0f86c277bcd33b1f76e41209c23af6c49

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Oct 31 08:48:21 2016 +1100

waf: Add an install command.

---

 common/waf.py | 110 +++++++++++++++++++++++++++++++++++-----------------------
 user/wscript  |   8 +++--
 wscript       |   5 ++-
 3 files changed, 77 insertions(+), 46 deletions(-)

diff --git a/common/waf.py b/common/waf.py
index 4fb2fa6..3036939 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -79,39 +79,70 @@ def cmd_configure(ctx):
 	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):
 	if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
 		ctx.fatal('The programs pdflatex and makeindex are required')
 
         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(
-		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,
-		source = ctx.path.ant_glob('**/*.rst'),
-		target = ctx.path.find_or_declare("latex/%s.tex" % (ctx.path.name))
+		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,
+		source       = ctx.path.ant_glob('**/*.rst'),
+		target       = ctx.path.find_or_declare("latex/%s.tex" % (ctx.path.name))
 	)
 
 	ctx.add_group()
 
 	ctx(
-		features	= 'tex',
-		cwd             = output_dir,
-		type		= 'pdflatex',
-		source		= "latex/%s.tex" % ctx.path.name,
-		prompt		= 0
+		features     = 'tex',
+		cwd          = output_dir,
+		type         = 'pdflatex',
+		source       = "latex/%s.tex" % ctx.path.name,
+		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):
 	if not ctx.env.BIN_INLINER:
 		ctx.fatal("Node inliner is required install with 'npm install -g inliner' (https://github.com/remy/inliner)")
 
+	html_resources(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),
 		cwd		= ctx.path.abspath(),
 		source	= ctx.path.ant_glob('**/*.rst'),
-		target	= "singlehtml/index.html"
+		target	= "singlehtml/index.html",
+                install_path = None
 	)
 
 	ctx.add_group()
@@ -119,9 +150,32 @@ def doc_singlehtml(ctx, source_dir, conf_dir):
 	ctx(
 		rule	= "${BIN_INLINER} ${SRC} > ${TGT}",
 		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):
         from_top = False
         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()
         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 = "."):
         build_dir_setup(ctx)
 
@@ -177,15 +209,7 @@ def cmd_build(ctx, conf_dir = ".", source_dir = "."):
 		html_resources(ctx)
 		doc_singlehtml(ctx, source_dir, conf_dir)
 	else:
-		html_resources(ctx)
-                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')
-		)
+		doc_html(ctx, source_dir, conf_dir)
 
 def cmd_options(ctx):
 	ctx.add_option('--sphinx-verbose', action='store', default="-Q", help="Sphinx verbose.")
diff --git a/user/wscript b/user/wscript
index bd0035f..245a229 100644
--- a/user/wscript
+++ b/user/wscript
@@ -2,5 +2,9 @@ from sys import path
 from os.path import abspath
 path.append(abspath('../common/'))
 
-from waf import cmd_configure as configure, cmd_build as build, \
-                spell, cmd_spell, cmd_options as options, linkcheck, cmd_linkcheck
+from waf import cmd_configure as configure, \
+                cmd_build as build, \
+                spell, \
+		cmd_spell, \
+		cmd_options as options, \
+		linkcheck, cmd_linkcheck
diff --git a/wscript b/wscript
index 955c66e..3e35dc9 100644
--- a/wscript
+++ b/wscript
@@ -27,9 +27,12 @@ def options(opt):
 def configure(conf):
     for b in building:
         conf.recurse(b)
-
     conf.env['BUILD_FROM_TOP'] = 'yes'
 
 def build(ctx):
     for b in building:
         ctx.recurse(b)
+
+def install(ctx):
+    for b in building:
+        ctx.recurse(b)




More information about the vc mailing list