[Git][NTPsec/ntpsec][master] 2 commits: Reorganize and clean up the build recipe.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Sep 26 16:09:43 UTC 2016


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


Commits:
b7ead636 by Eric S. Raymond at 2016-09-26T12:06:42-04:00
Reorganize and clean up the build recipe.

- - - - -
bd336ee3 by Eric S. Raymond at 2016-09-26T12:08:36-04:00
Belatedly add check_multicast.py - should have gone with last commit.

- - - - -


7 changed files:

- devel/TODO
- devel/tour.txt
- wafhelpers/compiler.py → wafhelpers/check_compiler.py
- + wafhelpers/check_multicast.py
- + wafhelpers/check_vsprintfm.py
- wafhelpers/configure.py
- wafhelpers/probes.py


Changes:

=====================================
devel/TODO
=====================================
--- a/devel/TODO
+++ b/devel/TODO
@@ -2,12 +2,6 @@
 
 == Checklist for a quality 1.0 release ==
 
-=== Build system ===
-
-* Cleanup and separate features in wafhelpers/*
-
-* Add support for enabling all conditional checks to ensure none are broken.
-
 === Code ===
 
 * Can the KERNEL_PLL code be removed?  Hal thinks it may no longer


=====================================
devel/tour.txt
=====================================
--- a/devel/tour.txt
+++ b/devel/tour.txt
@@ -284,8 +284,8 @@ a loadable Python module.  Here are a few useful generalizations:
 * The main sequence of the configuration logic, and most of the simpler
   checks, lives in configure.py.
 
-* For historical reasons, a few of the simpler checks outside
-  configure.py live in probes.py.
+* Some generic but bulky helper functions git push
+live in probes.py.
 
 * The check_*.py files isolate checks for individual capabilities;
   you can generally figure out which ones by looking at the name.


=====================================
wafhelpers/compiler.py → wafhelpers/check_compiler.py
=====================================
--- a/wafhelpers/compiler.py
+++ b/wafhelpers/check_compiler.py


=====================================
wafhelpers/check_multicast.py
=====================================
--- /dev/null
+++ b/wafhelpers/check_multicast.py
@@ -0,0 +1,19 @@
+import sys
+from waflib.Logs import pprint
+
+def check_multicast(ctx):
+        "Probe for IP multicast capability."
+        ctx.check_cc(
+                fragment="""
+#include <netinet/in.h>
+int main() {
+        struct ip_mreq ipmr;
+        ipmr.imr_interface.s_addr = 0;
+        return 0;
+}
+""",
+                define_name="MCAST",
+                msg = "Checking for multicast capability",
+                mandatory = False,
+                comment = "IP multicast capability")
+


=====================================
wafhelpers/check_vsprintfm.py
=====================================
--- /dev/null
+++ b/wafhelpers/check_vsprintfm.py
@@ -0,0 +1,54 @@
+import sys
+from waflib.Logs import pprint
+
+# What we really want to do here is test to see if the following program
+# compiles *and exits with 9 status*.  Because we don't know how to check
+# the return status we must settle for a simpler test.
+'''
+#include <stdarg.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+int call_vsnprintf(char *dst, size_t sz, const char *fmt,...)
+{
+        va_list ap;
+        int             rc;
+
+        va_start(ap, fmt);
+        rc = vsnprintf(dst, sz, fmt, ap);
+        va_end(ap);
+
+        return rc;
+}
+
+int main()
+{
+        char    sbuf[512];
+        char    pbuf[512];
+        int             slen;
+
+        strcpy(sbuf, strerror(ENOENT));
+        errno = ENOENT;
+        slen = call_vsnprintf(pbuf, sizeof(pbuf), "%m",
+                          "wrong");
+        return strcmp(sbuf, pbuf);
+}
+'''
+
+def check_vsprintfm(ctx):
+        "Check for %m expanding to strerror(error) in glibc style."
+        ctx.check_cc(
+                fragment='''
+#include <features.h>
+int main()
+{
+#ifndef __GLIBC__
+# error __GLIBC__ is not defined
+#endif
+}
+''',
+                define_name="VSNPRINTF_PERCENT_M",
+                msg = "Checking for %m expansion in vsnprintf(3)",
+                mandatory = False,
+                comment="%m expanding to strerror(error) in glibc style")


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -54,7 +54,7 @@ def cmd_configure(ctx, config):
         for opt in opt_map:
                 ctx.env[opt] = opt_map[opt]
 
-        from wafhelpers.compiler import check_compiler
+        from wafhelpers.check_compiler import check_compiler
         check_compiler(ctx)
 
         if ctx.options.enable_rtems_trace:
@@ -260,7 +260,8 @@ def cmd_configure(ctx, config):
         ctx.define("GETSOCKNAME_SOCKLEN_TYPE", "socklen_t", quote=False, comment="socklen type")
         ctx.define("DFLT_RLIMIT_STACK", 50, comment="Default stack size")
 
-        probe_multicast(ctx, "MCAST", "Checking for multicast capability")
+        from wafhelpers.check_multicast import check_multicast
+        check_multicast(ctx)
 
         ctx.define("TYPEOF_IP_MULTICAST_LOOP", "u_char", quote=False, comment="Multicast loop type") #XXX: check for mcast type
 
@@ -453,8 +454,8 @@ def cmd_configure(ctx, config):
         else:
                 print("Can't determine byte order!")
 
-        probe_vsprintfm(ctx, "VSNPRINTF_PERCENT_M",
-                            "Checking for %m expansion in vsnprintf(3)")
+        from wafhelpers.check_vsprintfm import check_vsprintfm
+        check_vsprintfm(ctx)
 
         # Define CFLAGS/LDCFLAGS for -vv support.
         ctx.define("NTPS_CFLAGS", " ".join(ctx.env.CFLAGS).replace("\"", "\\\""), comment="CFLAGS used when compiled")


=====================================
wafhelpers/probes.py
=====================================
--- a/wafhelpers/probes.py
+++ b/wafhelpers/probes.py
@@ -39,71 +39,6 @@ def probe_function_with_prerequisites(ctx, function, prerequisites, use=None):
                 comment = "Whether %s() exists" % function)
         return ctx.get_define(have_name)
 
-def probe_multicast(ctx, symbol, legend):
-        "Probe for IP multicast capability."
-        ctx.check_cc(
-                fragment="""
-#include <netinet/in.h>
-int main() {
-        struct ip_mreq ipmr;
-        ipmr.imr_interface.s_addr = 0;
-        return 0;
-}
-""",
-                define_name=symbol,
-                msg = legend,
-                mandatory = False,
-                comment = "IP multicast capability")
-
-# What we really want to do here is test to see if the following program
-# compiles *and exits with 9 status*.  Because we don't know how to check
-# the return status we must settle for a simpler test.
-'''
-#include <stdarg.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-int call_vsnprintf(char *dst, size_t sz, const char *fmt,...)
-{
-        va_list ap;
-        int             rc;
-
-        va_start(ap, fmt);
-        rc = vsnprintf(dst, sz, fmt, ap);
-        va_end(ap);
-
-        return rc;
-}
-
-int main()
-{
-        char    sbuf[512];
-        char    pbuf[512];
-        int             slen;
-
-        strcpy(sbuf, strerror(ENOENT));
-        errno = ENOENT;
-        slen = call_vsnprintf(pbuf, sizeof(pbuf), "%m",
-                          "wrong");
-        return strcmp(sbuf, pbuf);
-}
-'''
+# end
 
 
-def probe_vsprintfm(ctx, symbol, legend):
-        "Probe for %m expanding to strerror(error) in glibc style."
-        ctx.check_cc(
-                fragment='''
-#include <features.h>
-int main()
-{
-#ifndef __GLIBC__
-# error __GLIBC__ is not defined
-#endif
-}
-''',
-                define_name=symbol,
-                msg = legend,
-                mandatory = False,
-                comment="%m expanding to strerror(error) in glibc style")



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/44a99f7c3bcafe37d57e212896e5d3f3b74c4e41...bd336ee384820e9be3de47016f2286be0356957b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160926/a6eebad4/attachment.html>


More information about the vc mailing list