wafsamba/samba_autoconf: when setting undefined result, use empty tuple
authorAlexander Bokovoy <ab@samba.org>
Thu, 6 Sep 2018 07:51:00 +0000 (07:51 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 7 Sep 2018 09:37:23 +0000 (11:37 +0200)
A difference between waf 1.x and 2.x is that we gained 0 as an undefined
variable in the cache file. This does not allow to differentiate unset
and set to 0 defines.

Force to use empty tuple () to signify unset defines.

Also, fix handling of extra cflags in case of 'strict=True': if
extra_cflags were not defined, we'd append None to the cflags list and
it confuses conf.check() later. 'None' is added to the command line of a
tool executed by the conf.check() which, depending on a tool, may be
treated as an error and cause wrong test result.

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_waf18.py

index 02fbeecd75ed7f7b8113737e1bf7112fa6833e6a..6b940e53c00200de2b0f19f11951ae51c6eceafb 100644 (file)
@@ -402,7 +402,8 @@ def CHECK_CODE(conf, code, define,
             extra_cflags = "-Werror"
         elif conf.env["CC_NAME"] == "xlc":
             extra_cflags = "-qhalt=w"
-        cflags.append(extra_cflags)
+        if extra_cflags:
+            cflags.append(extra_cflags)
 
     if local_include:
         cflags.append('-I%s' % conf.path.abspath())
@@ -451,7 +452,13 @@ def CHECK_CODE(conf, code, define,
             raise
         return False
     else:
-        # success
+        # Success is indicated by ret but we should unset
+        # defines set by WAF's c_config.check() because it
+        # defines it to int(ret) and we want to undefine it
+        if not ret:
+            conf.undefine(define)
+            conf.COMPOUND_END(False)
+            return False
         if not define_ret:
             conf.DEFINE(define, 1)
             conf.COMPOUND_END(True)
index ff20bc20885bfa404c351eec3418b269b0b8de2d..282755c1fa68b939811da88a5289cc6f4c2a8889 100644 (file)
@@ -69,10 +69,10 @@ def apply_incpaths(self):
 def define(self, key, val, quote=True, comment=None):
    assert key and isinstance(key, str)
 
-   if val is True:
-           val = 1
-   elif val in (False, None):
-           val = 0
+   if val is None:
+       val = ()
+   elif isinstance(val, bool):
+       val = int(val)
 
    # waf 1.5
    self.env[key] = val