CMake: pro2cmake.py: Handle complex conditions
Change-Id: Ifb047e5736f1831ddbd65b210e760c2729378334 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
951e297362
commit
eb832cb00a
@ -546,9 +546,9 @@ class QmakeParser:
|
|||||||
= pp.Combine(pp.OneOrMore(Substitution | LiteralValuePart
|
= pp.Combine(pp.OneOrMore(Substitution | LiteralValuePart
|
||||||
| pp.Literal('$')))
|
| pp.Literal('$')))
|
||||||
Value = pp.NotAny(Else | pp.Literal('}') | EOL | pp.Literal('\\')) \
|
Value = pp.NotAny(Else | pp.Literal('}') | EOL | pp.Literal('\\')) \
|
||||||
+ (pp.QuotedString(quoteChar='"', escChar='\\')
|
+ (pp.QuotedString(quoteChar='"', escChar='\\')
|
||||||
| SubstitutionValue
|
| SubstitutionValue
|
||||||
| BracedValue)
|
| BracedValue)
|
||||||
|
|
||||||
Values = pp.ZeroOrMore(Value + pp.Optional(LC))('value')
|
Values = pp.ZeroOrMore(Value + pp.Optional(LC))('value')
|
||||||
|
|
||||||
@ -584,10 +584,12 @@ class QmakeParser:
|
|||||||
+ StatementGroup + pp.Optional(LC | EOL) \
|
+ StatementGroup + pp.Optional(LC | EOL) \
|
||||||
+ pp.Suppress('}') + pp.Optional(LC | EOL)
|
+ pp.Suppress('}') + pp.Optional(LC | EOL)
|
||||||
|
|
||||||
ConditionEnd = pp.FollowedBy((pp.Optional(LC) + (pp.Literal(':') \
|
ConditionEnd = pp.FollowedBy((pp.Optional(pp.White())
|
||||||
| pp.Literal('{') \
|
+ pp.Optional(LC) + (pp.Literal(':') \
|
||||||
| pp.Literal('|'))))
|
| pp.Literal('{') \
|
||||||
ConditionPart = pp.CharsNotIn('#{}|:=\\\n') + pp.Optional(LC) + ConditionEnd
|
| pp.Literal('|'))))
|
||||||
|
ConditionPart = ((pp.Optional('!') + Identifier + pp.Optional(BracedValue)) \
|
||||||
|
^ pp.CharsNotIn('#{}|:=\\\n')) + pp.Optional(LC) + ConditionEnd
|
||||||
Condition = pp.Combine(ConditionPart \
|
Condition = pp.Combine(ConditionPart \
|
||||||
+ pp.ZeroOrMore((pp.Literal('|') ^ pp.Literal(':')) \
|
+ pp.ZeroOrMore((pp.Literal('|') ^ pp.Literal(':')) \
|
||||||
+ ConditionPart))
|
+ ConditionPart))
|
||||||
@ -1172,7 +1174,8 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str,
|
|||||||
def write_module(cm_fh: typing.IO[str], scope: Scope, *,
|
def write_module(cm_fh: typing.IO[str], scope: Scope, *,
|
||||||
indent: int = 0) -> None:
|
indent: int = 0) -> None:
|
||||||
module_name = scope.TARGET
|
module_name = scope.TARGET
|
||||||
assert module_name.startswith('Qt')
|
if not module_name.startswith('Qt'):
|
||||||
|
print('XXXXXX Module name {} does not start with Qt!'.format(module_name))
|
||||||
|
|
||||||
extra = []
|
extra = []
|
||||||
if 'static' in scope.get('CONFIG'):
|
if 'static' in scope.get('CONFIG'):
|
||||||
|
4
util/cmake/tests/data/complex_condition.pro
Normal file
4
util/cmake/tests/data/complex_condition.pro
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
!system("dbus-send --session --type=signal / local.AutotestCheck.Hello >$$QMAKE_SYSTEM_NULL_DEVICE 2>&1") {
|
||||||
|
SOURCES = dbus.cpp
|
||||||
|
}
|
||||||
|
|
@ -260,3 +260,17 @@ def test_realworld_complex_assign():
|
|||||||
assert len(result) == 1
|
assert len(result) == 1
|
||||||
validate_op('qmake-clean.commands', '+=', '( cd qmake && $(MAKE) clean ":-(==)-:" \'(Foo)\' )'.split(),
|
validate_op('qmake-clean.commands', '+=', '( cd qmake && $(MAKE) clean ":-(==)-:" \'(Foo)\' )'.split(),
|
||||||
result[0])
|
result[0])
|
||||||
|
|
||||||
|
|
||||||
|
def test_realworld_complex_condition():
|
||||||
|
result = parse_file(_tests_path + '/data/complex_condition.pro')
|
||||||
|
assert len(result) == 1
|
||||||
|
(cond, if_branch, else_branch) = evaluate_condition(result[0])
|
||||||
|
assert cond == '!system("dbus-send --session --type=signal / ' \
|
||||||
|
'local.AutotestCheck.Hello >$$QMAKE_SYSTEM_NULL_DEVICE ' \
|
||||||
|
'2>&1")'
|
||||||
|
assert len(if_branch) == 1
|
||||||
|
validate_op('SOURCES', '=', ['dbus.cpp'], if_branch[0])
|
||||||
|
|
||||||
|
assert len(else_branch) == 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user