CMake: pro2cmake.py: Simplify condition generation

There is no need to try and avoid extra () and NOTs: Those will be
removed by sympy later anyway.

Change-Id: I39d3e4d1d829579e532bfbbf6c69e0f1e06e9a22
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
This commit is contained in:
Tobias Hunger 2019-02-11 17:53:54 +01:00
parent f18db41f85
commit 3726b58d3b

View File

@ -1000,29 +1000,13 @@ def recursive_evaluate_scope(scope: Scope, parent_condition: str = '',
if total_condition == 'else':
assert previous_condition, \
"Else branch without previous condition in: %s" % scope.file
if previous_condition.startswith('NOT '):
total_condition = previous_condition[4:]
elif is_simple_condition(previous_condition):
total_condition = 'NOT {}'.format(previous_condition)
else:
total_condition = 'NOT ({})'.format(previous_condition)
total_condition = 'NOT ({})'.format(previous_condition)
if parent_condition:
if not total_condition:
total_condition = parent_condition
else:
if is_simple_condition(parent_condition) \
and is_simple_condition(total_condition):
total_condition = '{} AND {}'.format(parent_condition,
total_condition = '({}) AND ({})'.format(parent_condition,
total_condition)
elif is_simple_condition(total_condition):
total_condition = '({}) AND {}'.format(parent_condition,
total_condition)
elif is_simple_condition(parent_condition):
total_condition = '{} AND ({})'.format(parent_condition,
total_condition)
else:
total_condition = '({}) AND ({})'.format(parent_condition,
total_condition)
scope.total_condition = simplify_condition(total_condition)