[Git][NTPsec/ntpsec][master] Use waf's built-in type existence checks

Matt Selsky gitlab at mg.gitlab.com
Tue Feb 7 07:24:56 UTC 2017


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
b5fb7f17 by Matt Selsky at 2017-02-07T02:20:20-05:00
Use waf's built-in type existence checks

- - - - -


2 changed files:

- − wafhelpers/check_type.py
- wafhelpers/configure.py


Changes:

=====================================
wafhelpers/check_type.py deleted
=====================================
--- a/wafhelpers/check_type.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from waflib.Configure import conf
-
-TYPE_FRAG = """
-int main(void) {
-        if (sizeof (%s))
-                return 0;
-        return 0;
-}
-"""
-
-
- at conf
-def check_type(ctx, typename, headers=[], mandatory=False):
-    name = "HAVE_%s" % typename.upper().replace(" ", "_")
-    src = ""
-    for hdr in headers:
-        src += "#include <%s>\n" % hdr
-    ctx.check_cc(
-        fragment=src + TYPE_FRAG % (typename),
-        define_name=name,
-        execute=False,
-        msg="Checking for type %s" % (typename),
-        mandatory=mandatory,
-        comment="Whether type '%s' exists." % typename
-    )


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -161,7 +161,6 @@ def cmd_configure(ctx, config):
     msg("--- Configuring main ---")
     ctx.setenv("main", ctx.env.derive())
 
-    from wafhelpers.check_type import check_type
     from wafhelpers.check_sizeof import check_sizeof
     from wafhelpers.check_structfield import check_structfield
 
@@ -246,21 +245,16 @@ def cmd_configure(ctx, config):
     types = ["uint64_t"]
 
     for inttype in sorted(types):
-        check_type(ctx, inttype, ["stdint.h", "sys/types.h"])
+        ctx.check_cc(type_name=inttype, header_name=["stdint.h", "sys/types.h"], mandatory=False)
 
-    net_types = (
+    structures = (
         ("struct if_laddrconf", ["sys/types.h", "net/if6.h"]),
         ("struct if_laddrreq", ["sys/types.h", "net/if6.h"]),
-    )
-    for (f, h) in net_types:
-        check_type(ctx, f, h)
-
-    structures = (
         ("struct timex", ["sys/time.h", "sys/timex.h"]),
         ("struct ntptimeval", ["sys/time.h", "sys/timex.h"]),
     )
     for (s, h) in structures:
-        check_type(ctx, s, h)
+        ctx.check_cc(type_name=s, header_name=h, mandatory=False)
 
     structure_fields = (
         ("time_tick", "timex", ["sys/time.h", "sys/timex.h"]),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b5fb7f17f1dfd0fba0d4f472306692571e6486e1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170207/2efbda18/attachment.html>


More information about the vc mailing list