[Git][NTPsec/ntpsec][master] Implement --define and --undefine options in waf.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Sep 23 18:21:11 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
97ea8324 by Eric S. Raymond at 2016-09-23T14:18:39-04:00
Implement --define and --undefine options in waf.

Eliminates a longstanding to-do item.  Note that if you say --define=FOO=23
the integer literal 23 will be generated into the config file, whereas
--define=FOO=qux will #define FOO to the string literal "qux".

- - - - -


3 changed files:

- devel/TODO
- wafhelpers/configure.py
- wafhelpers/options.py


Changes:

=====================================
devel/TODO
=====================================
--- a/devel/TODO
+++ b/devel/TODO
@@ -13,14 +13,6 @@
 
 * Add support for enabling all conditional checks to ensure none are broken.
 
-* Add support for disabling specific conditional tests to ensure nothing is
-  compiled into the base in a surprising fashion, e.g. --undefine=FOO should
-  suppress generation of any FOO #define into config.h.
-
-* Add support for enabling hidden features and/or
-  internal symbols for testing, e.g --define FOO=BAR generates #define
-  FOO BAR into config.h.
-
 === Code ===
 
 * Can the KERNEL_PLL code be removed?  Hal thinks it may no longer


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -29,8 +29,19 @@ def cmd_configure(ctx, config):
         opt_map = {}
         # Wipe out and override flags with those from the commandline
         for flag in ctx.env.OPT_STORE:
-                opt = flag.replace("--", "").upper() # XXX: find a better way.
-                opt_map[opt] = ctx.env.OPT_STORE[flag]
+                if flag == "--undefine":
+			for sym in ctx.env.OPT_STORE[flag]:
+				ctx.undefine(sym)
+                elif flag == "--define":
+			for symval in ctx.env.OPT_STORE[flag]:
+				(sym, val) = symval.split("=")
+				try:
+					ctx.define(sym, int(val))
+				except ValueError:
+					ctx.define(sym, val)
+                else:
+                        opt = flag.replace("--", "").upper()
+                        opt_map[opt] = ctx.env.OPT_STORE[flag]
 
         msg("--- Configuring host ---")
         ctx.setenv('host', ctx.env.derive())


=====================================
wafhelpers/options.py
=====================================
--- a/wafhelpers/options.py
+++ b/wafhelpers/options.py
@@ -44,6 +44,8 @@ def options_cmd(ctx, config):
 	grp.add_option('--check', action='store_true', default=False, help="Run tests")
 	grp.add_option('--enable-rtems-trace', action='store_true', default=False, help="Enable RTEMS Trace.")
 	grp.add_option('--rtems-trace-path', type='string', default="", help="Path to rtems-tld.")
+	grp.add_option('--define', type='string', action="callback", callback=callback_flags, help="Force definition of symbol, wants value of form SYM=VAL.")
+	grp.add_option('--undefine', type='string', action="callback", callback=callback_flags, help="Force undefinition of symbol.")
 
 	grp = ctx.add_option_group("NTP documentation configure options")
 	grp.add_option('--enable-doc', action='store_true', default=False, help="Build NTP documentation")



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/97ea8324065820387d5b02b0d3890a0d13175390
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160923/85fe9800/attachment.html>


More information about the vc mailing list