[Git][NTPsec/ntpsec][master] waf: a newer test for C compiler flags
Gary E. Miller
gitlab at mg.gitlab.com
Fri Feb 24 02:43:17 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
b392b7e5 by Gary E. Miller at 2017-02-23T18:41:23-08:00
waf: a newer test for C compiler flags
works on gcc 5 and LLVM version 8
- - - - -
1 changed file:
- wafhelpers/configure.py
Changes:
=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -5,6 +5,31 @@ from wafhelpers.probes \
import probe_header_with_prerequisites, probe_function_with_prerequisites
from wafhelpers.util import msg, msg_setting, parse_version
+from waflib.Errors import WafError
+from waflib import Build
+from waflib.Context import BOTH
+
+
+class oc(Build.BuildContext):
+ cmd = 'oc'
+
+ def exec_command(self, cmd, **kw):
+ kw['output'] = BOTH
+ try:
+ err, out = self.cmd_and_log(cmd, **kw)
+ except WafError as e:
+ self.logger.debug('WafError')
+ return e.returncode
+ if (len(out) and any(word in out for word
+ in ['ignored', 'illegal', 'unknown',
+ 'unrecognized', 'warning'])):
+ self.logger.debug('noooo %r' % out)
+ return 1
+ if err:
+ self.logger.debug('noooo %r' % err)
+ return 1
+ return 0
+
def cmd_configure(ctx, config):
srcnode = ctx.srcnode.abspath()
@@ -228,7 +253,7 @@ def cmd_configure(ctx, config):
("-z now", "-Wl,-z,now"), # no deferred symbol resolution
]
- FRAGMENT='''
+ FRAGMENT = '''
int main(int argc, char **argv) {
(void)argc; (void)argv;
return 0;
@@ -236,12 +261,17 @@ int main(int argc, char **argv) {
'''
# check if C compiler supports some flags
+ old_run_build_cls = ctx.run_build_cls
+ ctx.run_build_cls = 'oc'
for (name, ccflag) in cc_test_flags:
- ctx.check_cc(define_name='HAS_' + name,
- cflags=ccflag,
- fragment=FRAGMENT,
- mandatory=False,
- msg='Checking if C compiler supports ' + name,)
+ ctx.check(cflags=ccflag,
+ define_name='HAS_' + name,
+ fragment=FRAGMENT,
+ mandatory=False,
+ msg='Checking if C compiler supports ' + name,
+ run_build_cls='oc')
+
+ ctx.run_build_cls = old_run_build_cls
# We require some things that C99 doesn't enable, like pthreads.
# Thus -std=gnu99 rather than -std=c99 here, if the compiler supports
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b392b7e5923596b7f5827f55485a8e4a57b5da27
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170224/ae8ec6d5/attachment.html>
More information about the vc
mailing list