buildtools/wafsamba: generate build options output with waf 2.0
authorAlexander Bokovoy <ab@samba.org>
Tue, 3 Jul 2018 09:48:39 +0000 (12:48 +0300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 5 Sep 2018 04:37:27 +0000 (06:37 +0200)
With WAF 2.0 we get all defines in environment at the same level.
Fix build options source code generator to handle this.

I felt uneasy at filtering out some defines so instead the code
is mangling generic defines to be correct for C compiler by
replacing '-', '.', and '()' with an underscore ('_').

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

index 00bedcda9c3b920aa1856c3f505e25321f652412..dc59c38b492cb11bd30bdf5ac665867a55fb64d4 100644 (file)
@@ -1,5 +1,6 @@
 # a waf tool to add extension based build patterns for Samba
 
+import sys
 from waflib import Build
 from wafsamba import samba_version_file
 
@@ -146,13 +147,19 @@ def write_build_options_section(fp, keys, section):
     fp.write("\n")
 
 def write_build_options(task):
-    tbl = task.env['defines']
+    tbl = task.env
     keys_option_with = []
     keys_option_utmp = []
     keys_option_have = []
     keys_header_sys = []
     keys_header_other = []
     keys_misc = []
+    if sys.hexversion>0x300000f:
+        trans_table = bytes.maketrans('.-()', '____')
+    else:
+        import string
+        trans_table = string.maketrans('.-()', '____')
+
     for key in tbl:
         if key.startswith("HAVE_UT_UT_") or key.find("UTMP") >= 0:
             keys_option_utmp.append(key)
@@ -169,7 +176,7 @@ def write_build_options(task):
             l = key.split("(")
             keys_misc.append(l[0])
         else:
-            keys_misc.append(key)
+            keys_misc.append(key.translate(trans_table))
 
     tgt = task.outputs[0].bldpath(task.env)
     f = open(tgt, 'w')