waf: add a script that compares configurations
authorUri Simchoni <urisimchoni@gmail.com>
Tue, 19 May 2015 08:50:41 +0000 (11:50 +0300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 20 May 2015 09:19:11 +0000 (11:19 +0200)
This script is intended for use with the cross-build infrastructure
self-test during autobuild.

The script takes two or more "default.cache.py" files which are the
result of the waf configure process, and performs an intelligent
comparison - allowing for a limited set of variables to be different.

If the configurations are identical (apart from allowed differences) then
the script exit with 0 code.
If there are differences, the script outputs them to standard output
in unified diff format.

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
script/compare_cc_results.py [new file with mode: 0755]

diff --git a/script/compare_cc_results.py b/script/compare_cc_results.py
new file mode 100755 (executable)
index 0000000..b8ed399
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+
+#
+# Compare the results of native and cross-compiled configure tests
+#
+
+import sys
+import difflib
+
+exceptions = ['BUILD_DIRECTORY', 'CROSS_COMPILE', 'CROSS_ANSWERS',
+              'CROSS_EXECUTE', 'SELFTEST_PREFIX']
+
+base_lines = list()
+base_fname = ''
+
+found_diff = False
+
+for fname in sys.argv[1:]:
+    lines = list()
+    f = open(fname, 'r')
+    for line in f:
+        if len(line.split('=', 1)) == 2:
+            key = line.split('=', 1)[0].strip()
+            if key in exceptions:
+                continue
+        lines.append(line)
+    f.close()
+    if base_fname:
+        diff = list(difflib.unified_diff(base_lines,lines,base_fname,fname))
+        if diff:
+            print 'configuration files %s and %s do not match' % (base_fname, fname)
+            for l in diff:
+                sys.stdout.write(l)
+            found_diff = True
+    else:
+        base_fname = fname
+        base_lines = lines
+
+if found_diff:
+    sys.exit(1)