[Git][NTPsec/ntpsec][master] 12 commits: check_structfield.py: conform to pep8
Gary E. Miller
gitlab at mg.gitlab.com
Wed Jan 4 00:41:27 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
83b552f9 by Gary E. Miller at 2017-01-03T16:13:02-08:00
check_structfield.py: conform to pep8
- - - - -
ddbc1d6b by Gary E. Miller at 2017-01-03T16:14:48-08:00
check_sockaddr.py: conform to pep8
- - - - -
379ddf49 by Gary E. Miller at 2017-01-03T16:17:44-08:00
check_sizeof.py: conform to pep8
- - - - -
5f94339e by Gary E. Miller at 2017-01-03T16:21:49-08:00
check_pthread.py: confirm to pep8
- - - - -
08b5439d by Gary E. Miller at 2017-01-03T16:22:39-08:00
check_seccomp.py: conform to pep8
- - - - -
4668e379 by Gary E. Miller at 2017-01-03T16:25:30-08:00
check_openssl.py: conform to pep8
- - - - -
bc3e39b9 by Gary E. Miller at 2017-01-03T16:27:37-08:00
check_mdns.py: conform to pep8
- - - - -
c186e7b7 by Gary E. Miller at 2017-01-03T16:29:08-08:00
check_fortify.py: conform to pep8
- - - - -
752702b1 by Gary E. Miller at 2017-01-03T16:30:47-08:00
check_compiler.py: conform to pep8
- - - - -
4890b4b7 by Gary E. Miller at 2017-01-03T16:32:11-08:00
check_cap.py: confirm to pep8
- - - - -
726cf2f2 by Gary E. Miller at 2017-01-03T16:38:40-08:00
bin_test.py: conform to pep8
- - - - -
c5a9c1b2 by Gary E. Miller at 2017-01-03T16:40:27-08:00
asciidoc.py: conform to pep8
- - - - -
12 changed files:
- wafhelpers/asciidoc.py
- wafhelpers/bin_test.py
- wafhelpers/check_cap.py
- wafhelpers/check_compiler.py
- wafhelpers/check_fortify.py
- wafhelpers/check_mdns.py
- wafhelpers/check_openssl.py
- wafhelpers/check_pthread.py
- wafhelpers/check_seccomp.py
- wafhelpers/check_sizeof.py
- wafhelpers/check_sockaddr.py
- wafhelpers/check_structfield.py
Changes:
=====================================
wafhelpers/asciidoc.py
=====================================
--- a/wafhelpers/asciidoc.py
+++ b/wafhelpers/asciidoc.py
@@ -2,33 +2,36 @@ from waflib import Task
from waflib.TaskGen import extension
from wafhelpers.util import ascii_doc_scan
-# asciidoc -b html5 -a linkcss -a stylesdir=/mnt/devel/ntp/commit/docs -o asd driver32.txt
+# asciidoc -b html5 -a linkcss -a stylesdir=/mnt/devel/ntp/commit/docs \
+# -o asd driver32.txt
# ASCIIDOC_FLAGS are almost always needed and need to be set by the user.
class asciidoc(Task.Task):
- color = "BLUE"
- run_str = '${BIN_ASCIIDOC} -b html5 -a linkcss ${ASCIIDOC_FLAGS} -o ${TGT[0].name} ${SRC[0].abspath()}'
- ext_out = ".html"
+ color = "BLUE"
+ run_str = '${BIN_ASCIIDOC} -b html5 -a linkcss ${ASCIIDOC_FLAGS} ' \
+ '-o ${TGT[0].name} ${SRC[0].abspath()}'
+ ext_out = ".html"
@extension('.txt')
def run_asciidoc(self, node):
- out = node.change_ext(".html")
- tsk = self.create_task("asciidoc", node, [out])
- tsk.cwd = node.parent.get_bld().abspath()
+ out = node.change_ext(".html")
+ tsk = self.create_task("asciidoc", node, [out])
+ tsk.cwd = node.parent.get_bld().abspath()
class a2x(Task.Task):
- color = "YELLOW"
- shell = True
- run_str = '${BIN_A2X} ${A2X_FLAGS} ${SRC[0].abspath()}'
- scan = ascii_doc_scan
+ color = "YELLOW"
+ shell = True
+ run_str = '${BIN_A2X} ${A2X_FLAGS} ${SRC[0].abspath()}'
+ scan = ascii_doc_scan
+
@extension('.man-tmp')
def run_a2x(self, node):
- n_file = node.path_from(self.bld.bldnode)
- out = "%s.%s" % (n_file.replace("-man.txt.man-tmp", ""), self.section)
- out_n = self.bld.path.find_or_declare(out)
- tsk = self.create_task('a2x', node, out_n)
- self.bld.install_files("${PREFIX}/man/man%s/" % self.section, out_n)
+ n_file = node.path_from(self.bld.bldnode)
+ out = "%s.%s" % (n_file.replace("-man.txt.man-tmp", ""), self.section)
+ out_n = self.bld.path.find_or_declare(out)
+ tsk = self.create_task('a2x', node, out_n)
+ self.bld.install_files("${PREFIX}/man/man%s/" % self.section, out_n)
=====================================
wafhelpers/bin_test.py
=====================================
--- a/wafhelpers/bin_test.py
+++ b/wafhelpers/bin_test.py
@@ -5,63 +5,67 @@ from waflib.Utils import subprocess
from waflib.Logs import pprint
cmd_map = {
- ("main/ntpd/ntpd", "-invalid"): br'.*must be run as root, not uid.*',
- ("main/ntpclients/ntpdig", "time.apple.com"): br'.*time.apple.com.*',
- ("main/ntpfrob/ntpfrob", "-h"): br'.*illegal option.*',
- ("main/ntpfrob/ntpfrob", "-b 100000"): br".*Bumping clock by 100000 microseconds.*",
- ("main/ntpclients/ntpkeygen", "-M"): br'.*Generating new md5 file and link.*',
- ("main/ntpclients/ntpq", "-p"): br'.*remote.*jitter.*',
- ("main/ntptime/ntptime", None): br'.*ntp_gettime\(\) returns code 0 \(OK\).*',
- ("main/attic/sht", "2:r"): br'.*reader.*',
-
-# XXX: Need to figure out how to test this.
-# ("main/attic/hist", ""): br'',
-
-# Perl library
-# ("main/ntpclients/ntptrace", ""): br'',
-# ("main/ntpclients/ntpwait", ""): br'',
-# ("main/ntpclients/ntpsweep", ""): br'',
+ ("main/ntpd/ntpd", "-invalid"): br'.*must be run as root, not uid.*',
+ ("main/ntpclients/ntpdig", "time.apple.com"): br'.*time.apple.com.*',
+ ("main/ntpfrob/ntpfrob", "-h"): br'.*illegal option.*',
+ ("main/ntpfrob/ntpfrob", "-b 100000"):
+ br".*Bumping clock by 100000 microseconds.*",
+ ("main/ntpclients/ntpkeygen", "-M"):
+ br'.*Generating new md5 file and link.*',
+ ("main/ntpclients/ntpq", "-p"): br'.*remote.*jitter.*',
+ ("main/ntptime/ntptime", None):
+ br'.*ntp_gettime\(\) returns code 0 \(OK\).*',
+ ("main/attic/sht", "2:r"): br'.*reader.*',
+
+ # XXX: Need to figure out how to test this.
+ # ("main/attic/hist", ""): br'',
+ # Perl library
+ # ("main/ntpclients/ntptrace", ""): br'',
+ # ("main/ntpclients/ntpwait", ""): br'',
+ # ("main/ntpclients/ntpsweep", ""): br'',
}
# XXX: Needs to run in a thread with a timeout.
def run(cmd, reg):
- check = False
+ check = False
- if cmd[1] is None:
- cmd = [cmd[0]]
+ if cmd[1] is None:
+ cmd = [cmd[0]]
- print("running: ", " ".join(cmd), end="")
+ print("running: ", " ".join(cmd), end="")
- if not exists("build/%s" % cmd[0]):
- pprint("YELLOW", " SKIPPING (does not exist)")
- return False
+ if not exists("build/%s" % cmd[0]):
+ pprint("YELLOW", " SKIPPING (does not exist)")
+ return False
- p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=None, cwd="build")
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=None, cwd="build")
- stdout, stderr = p.communicate()
+ stdout, stderr = p.communicate()
- regex = re.compile(reg)
+ regex = re.compile(reg)
- if regex.match(stdout) or regex.match(stderr):
- check = True
+ if regex.match(stdout) or regex.match(stderr):
+ check = True
- if check:
- pprint("GREEN", " OK")
- return False
- else:
- pprint("RED", " FAILED")
- return True
+ if check:
+ pprint("GREEN", " OK")
+ return False
+ else:
+ pprint("RED", " FAILED")
+ return True
def cmd_bin_test(ctx, config):
- fail = True
+ fail = True
- for cmd in sorted(cmd_map):
- fail = run(cmd, cmd_map[cmd])
+ for cmd in sorted(cmd_map):
+ fail = run(cmd, cmd_map[cmd])
- if fail:
- pprint("RED", "Tests failed!")
-# ctx.fatal("Failed")
+ if fail:
+ pprint("RED", "Tests failed!")
+ # ctx.fatal("Failed")
-#cmd_bin_test(None, None)
+# cmd_bin_test(None, None)
=====================================
wafhelpers/check_cap.py
=====================================
--- a/wafhelpers/check_cap.py
+++ b/wafhelpers/check_cap.py
@@ -1,6 +1,7 @@
import sys
from waflib.Logs import pprint
+
def check_cap(ctx):
if ctx.options.disable_droproot:
@@ -12,9 +13,9 @@ def check_cap(ctx):
ctx.check_cc(header_name="sys/capability.h", mandatory=False)
ctx.check_cc(lib="cap", comment="Capability library", mandatory=False)
- if ctx.get_define("HAVE_SYS_CAPABILITY_H") and \
- ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_CAP:
- ctx.define("HAVE_LINUX_CAPABILITY", 1)
+ if ((ctx.get_define("HAVE_SYS_CAPABILITY_H")
+ and ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_CAP)):
+ ctx.define("HAVE_LINUX_CAPABILITY", 1)
else:
pprint("RED", "Warning libcap and headers not installed")
pprint("RED", "Fedora needs libcap-devel")
=====================================
wafhelpers/check_compiler.py
=====================================
--- a/wafhelpers/check_compiler.py
+++ b/wafhelpers/check_compiler.py
@@ -14,53 +14,54 @@ COMPILER_FRAG = """
int main(void) {
#ifdef __clang__
- printf("1");
+ printf("1");
#elif __INTEL_COMPILER
- printf("2");
+ printf("2");
#elif __GNUC__
- printf("3");
+ printf("3");
#elif __SUNPRO_C
- printf("4");
+ printf("4");
#else
- printf("255");
+ printf("255");
#endif
- return 0;
+ return 0;
}
"""
def check_compiler(ctx):
- if ctx.env.ENABLE_CROSS:
- return
+ if ctx.env.ENABLE_CROSS:
+ return
- defines = {
- 1: ("COMPILER_CLANG", "clang"),
- 2: ("COMPILER_ICC", "ICC"),
- 3: ("COMPILER_GCC", "GCC"),
- 4: ("COMPILER_SUNCC", "SUNCC"),
- 255: ("COMPILER_GCC", "Unknown (Defaulting to GCC)"),
- }
+ defines = {
+ 1: ("COMPILER_CLANG", "clang"),
+ 2: ("COMPILER_ICC", "ICC"),
+ 3: ("COMPILER_GCC", "GCC"),
+ 4: ("COMPILER_SUNCC", "SUNCC"),
+ 255: ("COMPILER_GCC", "Unknown (Defaulting to GCC)"),
+ }
- ctx.check_cc(
- fragment = COMPILER_FRAG,
- msg = "Checking compiler",
- define_name = "COMPILER_INT",
- quote = False,
- execute = True,
- define_ret = True,
- mandatory = True,
- )
+ ctx.check_cc(
+ fragment=COMPILER_FRAG,
+ msg="Checking compiler",
+ define_name="COMPILER_INT",
+ quote=False,
+ execute=True,
+ define_ret=True,
+ mandatory=True,
+ )
- compiler_int = int(ctx.get_define("COMPILER_INT"))
+ compiler_int = int(ctx.get_define("COMPILER_INT"))
- ctx.undefine("COMPILER_INT") # Not needed.
+ ctx.undefine("COMPILER_INT") # Not needed.
- define, name = defines[compiler_int]
+ define, name = defines[compiler_int]
- ctx.start_msg("Compiler found")
+ ctx.start_msg("Compiler found")
- ctx.define(define, 1, comment="Compiler detected during configure.") # config.h
- ctx.env[define] = True # Build system.
+ # config.h
+ ctx.define(define, 1, comment="Compiler detected during configure.")
+ ctx.env[define] = True # Build system.
- ctx.end_msg(name)
+ ctx.end_msg(name)
=====================================
wafhelpers/check_fortify.py
=====================================
--- a/wafhelpers/check_fortify.py
+++ b/wafhelpers/check_fortify.py
@@ -1,10 +1,15 @@
from shlex import split
+
def check_fortify(ctx):
- ctx.find_program("sourceanalyzer", var="BIN_SOURCEANALYZER", mandatory=True)
+ ctx.find_program("sourceanalyzer", var="BIN_SOURCEANALYZER",
+ mandatory=True)
- if not ctx.options.fortify_flags:
- ctx.fatal("You must supply --fortify-flags when using --enable-fortify.")
+ if not ctx.options.fortify_flags:
+ ctx.fatal(
+ "You must supply --fortify-flags when using --enable-fortify.")
- ctx.env.CC = ctx.env.BIN_SOURCEANALYZER + split(ctx.options.fortify_flags) + ctx.env.CC
- ctx.env.AR = ctx.env.BIN_SOURCEANALYZER + split(ctx.options.fortify_flags) + ctx.env.AR
+ ctx.env.CC = ctx.env.BIN_SOURCEANALYZER + \
+ split(ctx.options.fortify_flags) + ctx.env.CC
+ ctx.env.AR = ctx.env.BIN_SOURCEANALYZER + \
+ split(ctx.options.fortify_flags) + ctx.env.AR
=====================================
wafhelpers/check_mdns.py
=====================================
--- a/wafhelpers/check_mdns.py
+++ b/wafhelpers/check_mdns.py
@@ -2,38 +2,42 @@ MDNS_FRAG = """
# include <dns_sd.h>
int main(void) {
- DNSServiceRef mdns;
- DNSServiceRefDeallocate(mdns);
+ DNSServiceRef mdns;
+ DNSServiceRefDeallocate(mdns);
return 0;
}
"""
+
def check_mdns_header(ctx):
- ctx.check_cc(lib="dns_sd", libpath=ctx.env.PLATFORM_LIBPATH, mandatory=False)
- ctx.check_cc(header_name="dns_sd.h", includes=ctx.env.PLATFORM_INCLUDES, uselib_store="DNS_SD_INCLUDES", mandatory=False)
+ ctx.check_cc(lib="dns_sd", libpath=ctx.env.PLATFORM_LIBPATH,
+ mandatory=False)
+ ctx.check_cc(header_name="dns_sd.h", includes=ctx.env.PLATFORM_INCLUDES,
+ uselib_store="DNS_SD_INCLUDES", mandatory=False)
- if ctx.get_define("HAVE_DNS_SD_H") and ctx.env.LIB_LIBDNS_SD:
- ctx.env.DNS_SD_HEADER = True
+ if ctx.get_define("HAVE_DNS_SD_H") and ctx.env.LIB_LIBDNS_SD:
+ ctx.env.DNS_SD_HEADER = True
def check_mdns_run(ctx):
- if ctx.env.ENABLE_CROSS: # XXX Remove when variant builds exist
- if ctx.env.DNS_SD_HEADER:
- ctx.define("HAVE_MDNS", 1, comment="multicast dns support")
- return
-
- ctx.check_cc(
- fragment = MDNS_FRAG,
- define_name = "HAVE_MDNS",
- features = "c",
- includes = ctx.env.PLATFORM_INCLUDES,
- libpath = ctx.env.PLATFORM_LIBPATH,
- export_includes = ctx.env.PLATFORM_INCLUDES,
- msg = "Checking if mDNSResponder works",
- name = "MDNS_INCLUDES",
- mandatory = False,
- comment = "Multicast DNS support"
- )
-
- if ctx.get_define("HAVE_MDNS"):
- ctx.define("ENABLE_MDNS_REGISTRATION", 1, comment="Multicast DNS support")
+ if ctx.env.ENABLE_CROSS: # XXX Remove when variant builds exist
+ if ctx.env.DNS_SD_HEADER:
+ ctx.define("HAVE_MDNS", 1, comment="multicast dns support")
+ return
+
+ ctx.check_cc(
+ fragment=MDNS_FRAG,
+ define_name="HAVE_MDNS",
+ features="c",
+ includes=ctx.env.PLATFORM_INCLUDES,
+ libpath=ctx.env.PLATFORM_LIBPATH,
+ export_includes=ctx.env.PLATFORM_INCLUDES,
+ msg="Checking if mDNSResponder works",
+ name="MDNS_INCLUDES",
+ mandatory=False,
+ comment="Multicast DNS support"
+ )
+
+ if ctx.get_define("HAVE_MDNS"):
+ ctx.define("ENABLE_MDNS_REGISTRATION", 1,
+ comment="Multicast DNS support")
=====================================
wafhelpers/check_openssl.py
=====================================
--- a/wafhelpers/check_openssl.py
+++ b/wafhelpers/check_openssl.py
@@ -5,50 +5,54 @@ int main(void) {
#if OPENSSL_VERSION_NUMBER < 0x0090704fL
#error OpenSSL is too old.
#endif
- ERR_load_BIO_strings();
- OpenSSL_add_all_algorithms();
- return 0;
+ ERR_load_BIO_strings();
+ OpenSSL_add_all_algorithms();
+ return 0;
}
"""
+
def configure_ssl(ctx):
- OPENSSL_HEADERS=True
- OPENSSL_LIB=True
-
- headers = (
- "openssl/asn1_mac.h",
- "openssl/bn.h",
- "openssl/err.h",
- "openssl/evp.h",
- "openssl/pem.h",
- "openssl/rand.h",
- "openssl/objects.h",
- "openssl/x509v3.h",
- "openssl/ssl.h",
- )
-
- for hdr in headers:
- if not ctx.check_cc(header_name=hdr, mandatory=False, comment="<%s> header" % hdr):
- OPENSSL_HEADERS=False
-
- libs = ["ssl", "crypto"]
-
- for lib in libs:
- if not ctx.check_cc(lib=lib, mandatory=False):
- OPENSSL_LIB=False
-
- if OPENSSL_HEADERS and OPENSSL_LIB:
- ctx.check_cc(
- fragment = OPENSSL_FRAG % "\n".join(["#include <%s>" % x for x in headers]),
- define_name = "HAVE_OPENSSL",
- execute = True,
- mandatory = False,
- use = "SSL CRYPTO",
- msg = "Checking if OpenSSL works",
- comment = "OpenSSL support"
- )
-
- if ctx.get_define("HAVE_OPENSSL"):
- ctx.define("USE_OPENSSL_CRYPTO_RAND", 1, comment="Use OpenSSL pseudo-random number generator")
- ctx.define("USE_OPENSSL_HASH", 1, comment="Use OpenSSL for hashing")
+ OPENSSL_HEADERS = True
+ OPENSSL_LIB = True
+
+ headers = (
+ "openssl/asn1_mac.h",
+ "openssl/bn.h",
+ "openssl/err.h",
+ "openssl/evp.h",
+ "openssl/pem.h",
+ "openssl/rand.h",
+ "openssl/objects.h",
+ "openssl/x509v3.h",
+ "openssl/ssl.h",
+ )
+
+ for hdr in headers:
+ if not ctx.check_cc(header_name=hdr, mandatory=False,
+ comment="<%s> header" % hdr):
+ OPENSSL_HEADERS = False
+
+ libs = ["ssl", "crypto"]
+
+ for lib in libs:
+ if not ctx.check_cc(lib=lib, mandatory=False):
+ OPENSSL_LIB = False
+
+ if OPENSSL_HEADERS and OPENSSL_LIB:
+ ctx.check_cc(
+ fragment=OPENSSL_FRAG % "\n".join(["#include <%s>" % x
+ for x in headers]),
+ define_name="HAVE_OPENSSL",
+ execute=True,
+ mandatory=False,
+ use="SSL CRYPTO",
+ msg="Checking if OpenSSL works",
+ comment="OpenSSL support"
+ )
+
+ if ctx.get_define("HAVE_OPENSSL"):
+ ctx.define("USE_OPENSSL_CRYPTO_RAND", 1,
+ comment="Use OpenSSL pseudo-random number generator")
+ ctx.define("USE_OPENSSL_HASH", 1, comment="Use OpenSSL for hashing")
=====================================
wafhelpers/check_pthread.py
=====================================
--- a/wafhelpers/check_pthread.py
+++ b/wafhelpers/check_pthread.py
@@ -3,45 +3,54 @@ from wafhelpers.tool import check_sanity
PTHREAD_FRAG = """
#include <pthread.h>
int main(void) {
- pthread_mutex_t mutex;
- pthread_mutex_init(&mutex, NULL);
- pthread_mutex_destroy(&mutex);
- return 0;
+ pthread_mutex_t mutex;
+ pthread_mutex_init(&mutex, NULL);
+ pthread_mutex_destroy(&mutex);
+ return 0;
}
"""
+
def check_pthread_header_lib(ctx):
- ctx.check(header_name="pthread.h", includes=ctx.env.PLATFORM_INCLUDES, mandatory=False, comment="pthread header")
- ctx.check(feature="c cshlib", lib="pthread", libpath=ctx.env.PLATFORM_LIBPATH, mandatory=False, comment="pthread library")
- ctx.check_cc(lib="thr", mandatory=False, comment="thr library, required by some operating systems.")
+ ctx.check(header_name="pthread.h", includes=ctx.env.PLATFORM_INCLUDES,
+ mandatory=False, comment="pthread header")
+ ctx.check(feature="c cshlib", lib="pthread",
+ libpath=ctx.env.PLATFORM_LIBPATH, mandatory=False,
+ comment="pthread library")
+ ctx.check_cc(lib="thr", mandatory=False,
+ comment="thr library, required by some operating systems.")
+
+ if ((ctx.get_define("HAVE_PTHREAD_H")
+ and (ctx.env.LIB_PTHREAD or ctx.env.LIB_THR))):
+ ctx.env.PTHREAD_HEADER_LIB = True
- if ctx.get_define("HAVE_PTHREAD_H") and (ctx.env.LIB_PTHREAD or ctx.env.LIB_THR):
- ctx.env.PTHREAD_HEADER_LIB = True
def check_pthread_run(ctx):
- if ctx.env.ENABLE_CROSS:
- if ctx.env.PTHREAD_HEADER_LIB: # XXX Remove when variant builds exist
- ctx.define("HAVE_PTHREAD", 1, comment="pthread support")
- ctx.env.PTHREAD_ENABLE = True
- return
-
- ctx.check(
- fragment = PTHREAD_FRAG,
- define_name = "HAVE_PTHREAD",
- features = "c",
- use = "PTHREAD THR",
- msg = "Checking if pthread works",
- includes = ctx.env.PLATFORM_INCLUDES,
- export_includes = ctx.env.PLATFORM_INCLUDES,
- mandatory = False,
- comment = "pthread support"
- )
-
- check_sanity(ctx, ctx.env.PTHREAD_HEADER_LIB, "pthread")
-
- if not ctx.get_define("HAVE_PTHREAD"): # XXX if pthread is part of 'libc' this will pass even if the header isn't detected.
- ctx.fatal("Error: POSIX threads are required in order to build.")
- else:
- ctx.env.PTHREAD_ENABLE = True
- ctx.define("HAVE_PTHREAD", 1, comment="pthread support")
+ if ctx.env.ENABLE_CROSS:
+ if ctx.env.PTHREAD_HEADER_LIB: # XXX Remove when variant builds exist
+ ctx.define("HAVE_PTHREAD", 1, comment="pthread support")
+ ctx.env.PTHREAD_ENABLE = True
+ return
+
+ ctx.check(
+ fragment=PTHREAD_FRAG,
+ define_name="HAVE_PTHREAD",
+ features="c",
+ use="PTHREAD THR",
+ msg="Checking if pthread works",
+ includes=ctx.env.PLATFORM_INCLUDES,
+ export_includes=ctx.env.PLATFORM_INCLUDES,
+ mandatory=False,
+ comment="pthread support"
+ )
+
+ check_sanity(ctx, ctx.env.PTHREAD_HEADER_LIB, "pthread")
+
+ # XXX if pthread is part of 'libc' this will pass
+ # even if the header isn't detected.
+ if not ctx.get_define("HAVE_PTHREAD"):
+ ctx.fatal("Error: POSIX threads are required in order to build.")
+ else:
+ ctx.env.PTHREAD_ENABLE = True
+ ctx.define("HAVE_PTHREAD", 1, comment="pthread support")
=====================================
wafhelpers/check_seccomp.py
=====================================
--- a/wafhelpers/check_seccomp.py
+++ b/wafhelpers/check_seccomp.py
@@ -1,9 +1,10 @@
import sys
from waflib.Logs import pprint
+
def check_seccomp(ctx):
- if not ctx.options.enable_seccomp:
+ if not ctx.options.enable_seccomp:
return
if not sys.platform.startswith("linux"):
return
=====================================
wafhelpers/check_sizeof.py
=====================================
--- a/wafhelpers/check_sizeof.py
+++ b/wafhelpers/check_sizeof.py
@@ -5,32 +5,33 @@ SIZE_FRAG = """
%s
#include <stdio.h>
int main(void) {
- printf("%%lu", sizeof(%s));
- return 0;
+ printf("%%lu", sizeof(%s));
+ return 0;
}
"""
+
def check_sizeof_host(ctx, header, sizeof, mandatory=True):
- sizeof_ns = sizeof.replace(" ", "_")
- name = "NTP_SIZEOF_%s" % sizeof_ns.upper()
-
- header_snippet = ""
- if header:
- ctx.start_msg("Checking sizeof %s (%s)" % (sizeof, header))
- header_snippet = "#include <%s>" % header
- else:
- ctx.start_msg("Checking sizeof %s" % (sizeof))
-
- ctx.check_cc(
- fragment = SIZE_FRAG % (header_snippet, sizeof),
- define_name = name,
- execute = True,
- define_ret = True,
- quote = False,
- mandatory = mandatory,
- comment = "Size of %s from <%s>" % (sizeof, header)
- )
- ctx.end_msg(ctx.get_define(name))
+ sizeof_ns = sizeof.replace(" ", "_")
+ name = "NTP_SIZEOF_%s" % sizeof_ns.upper()
+
+ header_snippet = ""
+ if header:
+ ctx.start_msg("Checking sizeof %s (%s)" % (sizeof, header))
+ header_snippet = "#include <%s>" % header
+ else:
+ ctx.start_msg("Checking sizeof %s" % (sizeof))
+
+ ctx.check_cc(
+ fragment=SIZE_FRAG % (header_snippet, sizeof),
+ define_name=name,
+ execute=True,
+ define_ret=True,
+ quote=False,
+ mandatory=mandatory,
+ comment="Size of %s from <%s>" % (sizeof, header)
+ )
+ ctx.end_msg(ctx.get_define(name))
# Cross compile check. Much slower so we do not run it all the time.
@@ -45,37 +46,40 @@ int main(void) {
}
"""
+
def check_sizeof_cross(ctx, header, sizeof, mandatory=True):
- sizeof_ns = sizeof.replace(" ", "_")
- name = "NTP_SIZEOF_%s" % sizeof_ns.upper()
-
- header_snippet = ""
- if header:
- ctx.start_msg("Checking sizeof %s (%s)" % (sizeof, header))
- header_snippet = "#include <%s>" % header
- else:
- ctx.start_msg("Checking sizeof %s" % (sizeof))
-
- for size in range(2, 13):
-
- try:
- ctx.check_cc(
- fragment = SIZE_FRAG_CROSS % (header_snippet, sizeof, size),
- features = "c",
- execute = False,
- mandatory = mandatory,
- )
- ctx.define(name, size, comment="Size of %s from <%s>" % (sizeof, header))
- ctx.end_msg(ctx.get_define(name))
- return
- except Errors.ConfigurationError:
- pass
-
- raise # never reached.
+ sizeof_ns = sizeof.replace(" ", "_")
+ name = "NTP_SIZEOF_%s" % sizeof_ns.upper()
+
+ header_snippet = ""
+ if header:
+ ctx.start_msg("Checking sizeof %s (%s)" % (sizeof, header))
+ header_snippet = "#include <%s>" % header
+ else:
+ ctx.start_msg("Checking sizeof %s" % (sizeof))
+
+ for size in range(2, 13):
+
+ try:
+ ctx.check_cc(
+ fragment=SIZE_FRAG_CROSS % (header_snippet, sizeof, size),
+ features="c",
+ execute=False,
+ mandatory=mandatory,
+ )
+ ctx.define(name, size, comment="Size of %s from <%s>"
+ % (sizeof, header))
+ ctx.end_msg(ctx.get_define(name))
+ return
+ except Errors.ConfigurationError:
+ pass
+
+ raise # never reached.
+
@conf
def check_sizeof(*kwargs):
- if kwargs[0].env.ENABLE_CROSS:
- return check_sizeof_cross(*kwargs)
- else:
- return check_sizeof_host(*kwargs)
+ if kwargs[0].env.ENABLE_CROSS:
+ return check_sizeof_cross(*kwargs)
+ else:
+ return check_sizeof_host(*kwargs)
=====================================
wafhelpers/check_sockaddr.py
=====================================
--- a/wafhelpers/check_sockaddr.py
+++ b/wafhelpers/check_sockaddr.py
@@ -18,20 +18,20 @@ int main(void) {
def check_sockaddr(ctx):
- ctx.check_cc(
- fragment = SOCKADDR_STORAGE_FRAG,
- define_name = "HAVE_STRUCT_SOCKADDR_STORAGE",
- features = "c",
- msg = "Checking for type sockaddr_storage",
- mandatory = False,
- comment = "Whether sockaddr_storage exists"
- )
+ ctx.check_cc(
+ fragment=SOCKADDR_STORAGE_FRAG,
+ define_name="HAVE_STRUCT_SOCKADDR_STORAGE",
+ features="c",
+ msg="Checking for type sockaddr_storage",
+ mandatory=False,
+ comment="Whether sockaddr_storage exists"
+ )
- ctx.check_cc(
- fragment = SA_LEN_FRAG,
- define_name = "ISC_PLATFORM_HAVESALEN",
- features = "c",
- msg = "Checking for sockaddr->sa_len",
- mandatory = False,
- comment = "Whether sockaddr.sa_len exists"
- )
+ ctx.check_cc(
+ fragment=SA_LEN_FRAG,
+ define_name="ISC_PLATFORM_HAVESALEN",
+ features="c",
+ msg="Checking for sockaddr->sa_len",
+ mandatory=False,
+ comment="Whether sockaddr.sa_len exists"
+ )
=====================================
wafhelpers/check_structfield.py
=====================================
--- a/wafhelpers/check_structfield.py
+++ b/wafhelpers/check_structfield.py
@@ -12,17 +12,18 @@ int main(void) {
}
"""
+
@conf
def check_structfield(ctx, fld, type, hdrs, mandatory=False):
- name = "STRUCT_%s_HAS_%s" % (type.upper(), fld.upper().replace('.', '_'))
- src = ""
- for hdr in hdrs:
- src += "#include <%s>\n" % hdr
- ctx.check_cc(
- fragment = TYPE_FRAG % (src, type, fld),
- define_name = name,
- execute = False,
- msg = "Checking for %s in struct %s" % (fld, type),
- mandatory = mandatory,
- comment = "Whether struct '%s' has field '%s'" % (fld, type)
- )
+ name = "STRUCT_%s_HAS_%s" % (type.upper(), fld.upper().replace('.', '_'))
+ src = ""
+ for hdr in hdrs:
+ src += "#include <%s>\n" % hdr
+ ctx.check_cc(
+ fragment=TYPE_FRAG % (src, type, fld),
+ define_name=name,
+ execute=False,
+ msg="Checking for %s in struct %s" % (fld, type),
+ mandatory=mandatory,
+ comment="Whether struct '%s' has field '%s'" % (fld, type)
+ )
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/abf72ae0630979a0ec9475dcfb1620f2e58e886f...c5a9c1b26a0e8429a988f9e13d1b42b7b2bfff7e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170104/098bd8a8/attachment.html>
More information about the vc
mailing list