summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-09-27 01:51:12 +0200
committerRichard Braun <rbraun@sceen.net>2017-09-27 01:51:12 +0200
commit379e4f61fed78469caf16635b394bf128d11b6b0 (patch)
treef2903cbef8d8c8c327534d8043e4d4b3c54abc60
parentc03429cf76e47a44711abe36a17fb0c72afdaefc (diff)
tools/build_configs.py: fix exclusive boolean filter generation
-rwxr-xr-xtools/build_configs.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/build_configs.py b/tools/build_configs.py
index a525fb16..15a03f4e 100755
--- a/tools/build_configs.py
+++ b/tools/build_configs.py
@@ -31,26 +31,28 @@ def gen_configs_list(options_dict):
def gen_configs_values_str(options_dict):
return map(lambda x: ' '.join(x.values()), gen_configs_list(options_dict))
+def gen_cc_options_list(options_dict):
+ return map(lambda x: x + ' -Werror', gen_configs_values_str(options_dict))
+
# Check whether a filter prototype is valid.
#
# A filter prototype is a list of (name, value) pairs used to build a filter.
# Keep in mind that a valid filter must match invalid configurations. As a
-# result, a filter prototype is valid if and only if the number of enabled
-# options is not 1.
-def check_exclusive_boolean_filter(filter_prototype):
- return len(filter(lambda x: x[1] == 'y', filter_prototype)) != 1
+# result, a filter prototype is valid if and only if
+# - all options are included in the given list, and
+# - the number of enabled options is not 1
+def check_exclusive_boolean_filter(prototype):
+ return (len(set(map(lambda x: x[0], prototype))) == len(prototype)
+ and len(filter(lambda x: x[1][1] == 'y', prototype)) != 1)
# Generate a list of filters on a list of boolean options.
#
# The resulting filters match configurations that don't have one and only
# one of the given options enabled.
def gen_exclusive_boolean_filters_list(options_list):
- product = itertools.product(options_list, ['y', 'n'])
- filters_prototypes = itertools.combinations(product, len(options_list))
- return map(dict, filter(check_exclusive_boolean_filter, filters_prototypes))
-
-def gen_cc_options_list(options_dict):
- return map(lambda x: x + ' -Werror', gen_configs_values_str(options_dict))
+ product = itertools.product(options_list, [[True, 'y'], [True, 'n']])
+ prototypes = list(itertools.combinations(product, len(options_list)))
+ return map(dict, filter(check_exclusive_boolean_filter, prototypes))
# Dictionary of compiler options.
#