[Git][NTPsec/ntpsec][master] Add support for a 'Release mode'

Amar Takhar gitlab at mg.gitlab.com
Tue Jan 26 20:47:02 UTC 2016


Amar Takhar pushed to branch master at NTPsec / ntpsec


Commits:
10a79acc by Amar Takhar at 2016-01-26T15:44:01-05:00
Add support for a 'Release mode'

Steps to use:
  1. Build as normal with manpages enabled.
  2. Edit wscript and change NTPS_RELEASE to True
  3. run 'make dist'

This will do a two things:

  1. Remove dependency on Bison and include generated files
  2. Include prebuilt manpages and remove dependency on asciidoc

This is most important for #1 as we can ship our pretested generated files
removing users using the tarball from having a buggy version of Bison.

Having prebuilt manpages is good for those who don't want to deal with asciidoc
on smaller systems.  It also makes things easier for packaging on some systems.

- - - - -


4 changed files:

- ntpd/wscript
- pylib/configure.py
- pylib/waf.py
- wscript


Changes:

=====================================
ntpd/wscript
=====================================
--- a/ntpd/wscript
+++ b/ntpd/wscript
@@ -3,29 +3,29 @@ def build(ctx):
 	srcnode = ctx.srcnode.abspath()
 	bldnode = ctx.bldnode.abspath()
 
-
 	if ctx.variant == "host":
 
-		bison_source = [
-			"ntp_parser.y"
-		]
-
-		ctx(
-			target		= "bison_obj",
-			features	= "c src_include bld_include libisc_include",
-			source		= bison_source,
-			includes    = [
-							"%s/ntpd/" % srcnode,
-							"%s/" % ctx.bldnode.parent.abspath()
+		if not ctx.env.NTPS_RELEASE:
+			bison_source = [
+				"ntp_parser.y"
 			]
-		)
 
-		ctx.add_group() # Generate Bison files first.
+			ctx(
+				target		= "bison_obj",
+				features	= "c src_include bld_include libisc_include",
+				source		= bison_source,
+				includes    = [
+								"%s/ntpd/" % srcnode,
+								"%s/" % ctx.bldnode.parent.abspath()
+				]
+			)
+
+			ctx.add_group() # Generate Bison files first.
 
 
 		keyword_gen_source = [
 			"keyword-gen.c",
-   	 ]
+		]
 
 		ctx(
 			target      = "keyword-gen",
@@ -81,7 +81,8 @@ def build(ctx):
 	ctx(
 		target		= "ntpd_lib",
 		features	= "c cstlib",
-		use			= "libntpd_obj bison_obj",
+		use			= "libntpd_obj",
+#		use			= "libntpd_obj bison_obj",
 	)
 
 
@@ -116,10 +117,11 @@ def build(ctx):
 		"ntp_io.c",
 		"ntp_scanner.c",
 		"ntpd.c",
-		ctx.bldnode.parent.find_node("host/ntpd/ntp_parser.tab.c")
+		ctx.bldnode.parent.find_node("host/ntpd/ntp_parser.tab.c") if not ctx.env.NTPS_RELEASE else "ntp_parser.tab.c"
 	]
 
 
+
 	# XXX: This really sucks, we need to get rid of all these refclock
 	#      defines littered everywhere and segment it to their own source files.
 	refclock_define = []
@@ -137,7 +139,8 @@ def build(ctx):
 		target		= "ntpd",
 		features	= "c rtems_trace cprogram bld_include src_include libisc_include libisc_pthread_include ntp_version",
 		source		= ntpd_source,
-		use			= "libntpd_obj bison_obj isc ntp sodium opts OSSAUDIO M parse GCC_S RT CAP THR PTHREAD CRYPTO DNS_SD DNS_SD_INCLUDES %s" % use_refclock,
+		use			= "libntpd_obj isc ntp sodium opts OSSAUDIO M parse GCC_S RT CAP THR PTHREAD CRYPTO DNS_SD DNS_SD_INCLUDES %s" % use_refclock,
+#		use			= "libntpd_obj bison_obj isc ntp sodium opts OSSAUDIO M parse GCC_S RT CAP THR PTHREAD CRYPTO DNS_SD DNS_SD_INCLUDES %s" % use_refclock,
 		includes	= [
 						"%s/host/ntpd/" % ctx.bldnode.parent.abspath(),
 						"%s/ntpd/" % srcnode,


=====================================
pylib/configure.py
=====================================
--- a/pylib/configure.py
+++ b/pylib/configure.py
@@ -18,7 +18,9 @@ def cmd_configure(ctx):
 	ctx.setenv('host', ctx.env.derive())
 
 	ctx.load('compiler_c')
-	ctx.load('bison')
+
+	if not ctx.env.NTPS_RELEASE:
+		ctx.load('bison')
 
 	for opt in opt_map:
 		ctx.env[opt] = opt_map[opt]


=====================================
pylib/waf.py
=====================================
--- a/pylib/waf.py
+++ b/pylib/waf.py
@@ -56,6 +56,10 @@ def manpage_subst_fun(task, text):
 @conf
 def manpage(ctx, section, source):
 
+	if ctx.env.NTPS_RELEASE:
+		ctx.install_files("${PREFIX}/man%s/" % section, source.replace("-man.txt", ".%s" % section))
+		return
+
 	if (not ctx.env.BIN_A2X) or ctx.env.DISABLE_MANPAGE:
 		return
 


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -4,6 +4,10 @@ from waflib import Context, Errors
 from waflib import Scripting
 from waflib.Logs import pprint
 
+config = {
+	"NTPS_RELEASE": False # Set to 'True' if this is a release
+}
+
 out="build"
 
 from pylib.configure import cmd_configure
@@ -23,16 +27,49 @@ def parse_version():
                 "NTPS_VERSION_REV" : int(rev)
         }
 
-config = parse_version()
+config.update(parse_version())
 
 def dist(ctx):
-        ctx.base_name = "ntpsec-%d.%d.%d" % \
-                        (config["NTPS_VERSION_MAJOR"], \
-                         config["NTPS_VERSION_MINOR"], \
-                         config["NTPS_VERSION_REV"])
-        if ctx.options.build_version_tag:
-                ctx.base_name = ctx.base_name + "-" + \
-                                ctx.options.build_version_tag
+		from os import path
+		from shutil import copyfile
+		files_man = []
+
+		if not config["NTPS_RELEASE"]:
+			ctx.fatal("NTPS_RELEASE must be set to True")
+
+
+		# XXX: Redo to not use globs.
+		bldnode = ctx.path.make_node(out)
+		for section in [1, 5, 8]:
+			files_man += bldnode.ant_glob("**/*.%d" % section)
+
+		# Need a more reliable check.
+		if not files_man:
+			ctx.fatal("You must configure and build first with NTPS_RELEASE set to false")
+
+		for man in files_man:
+			src = man.abspath()
+			dst = src.replace("%s/main/" % bldnode.abspath(), "")
+			print "Copying %s -> %s" % (src, dst)
+			copyfile(src, dst)
+
+		files = [
+			("build/host/ntpd/ntp_parser.tab.c", "ntpd/ntp_parser.tab.c"),
+			("build/host/ntpd/ntp_parser.tab.h", "ntpd/ntp_parser.tab.h")
+		]
+
+		for src, dst in files:
+			if not path.exists(src):
+				ctx.fatal("%s doesn't exist please configure and build first.  NTPS_RELEASE must be set to False" % src)
+			print "Copying %s -> %s" % (src, dst)
+			copyfile(src, dst)
+
+		ctx.base_name = "ntpsec-%d.%d.%d" % \
+						(config["NTPS_VERSION_MAJOR"], \
+						config["NTPS_VERSION_MINOR"], \
+						config["NTPS_VERSION_REV"])
+		if ctx.options.build_version_tag:
+			ctx.base_name = "%s-%s" % (ctx.base_name, ctx.options.build_version_tag)
 
 def options(ctx):
 	ctx.load("compiler_c")
@@ -86,6 +123,7 @@ def options(ctx):
 
 
 def configure(ctx):
+	ctx.env.NTPS_RELEASE = config["NTPS_RELEASE"]
 	ctx.env.NTPS_VERSION_MAJOR = config["NTPS_VERSION_MAJOR"]
 	ctx.env.NTPS_VERSION_MINOR = config["NTPS_VERSION_MINOR"]
 	ctx.env.NTPS_VERSION_REV = config["NTPS_VERSION_REV"]



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/10a79acccc19a11932760764d87de0f16d3a96b3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160126/6d787d99/attachment.html>


More information about the vc mailing list