summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index ea68b57a19..fbf153b057 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -794,13 +794,26 @@ class QmakeParser:
+ pp.Optional(LC) + (pp.Literal(':') \
| pp.Literal('{') \
| pp.Literal('|'))))
- ConditionPart = ((pp.Optional('!') + Identifier + pp.Optional(BracedValue)) \
- ^ pp.CharsNotIn('#{}|:=\\\n')) + pp.Optional(LC) + ConditionEnd
- Condition = pp.Combine(ConditionPart \
- + pp.ZeroOrMore((pp.Literal('|') ^ pp.Literal(':')) \
- + ConditionPart))
+
+ ConditionPart1 = (pp.Optional('!') + Identifier + pp.Optional(BracedValue))
+ ConditionPart2 = pp.CharsNotIn('#{}|:=\\\n')
+ ConditionPart = (ConditionPart1 ^ ConditionPart2) + pp.Optional(LC) + ConditionEnd
+
+ ConditionOp = pp.Literal('|') ^ pp.Literal(':')
+ ConditionLC = pp.Suppress(pp.Optional(pp.White(' ') + LC + pp.White(' ')))
+
+ ConditionRepeated = pp.ZeroOrMore((ConditionOp) + ConditionLC + ConditionPart)
+
+ Condition = pp.Combine(ConditionPart + ConditionRepeated)
Condition.setParseAction(lambda x: ' '.join(x).strip().replace(':', ' && ').strip(' && '))
+ # Weird thing like write_file(a)|error() where error() is the alternative condition
+ # which happens to be a function call. In this case there is no scope, but our code expects
+ # a scope with a list of statements, so create a fake empty statement.
+ ConditionEndingInFunctionCall = pp.Suppress(ConditionOp) + FunctionCall \
+ + pp.Empty().setParseAction(lambda x: [[]])\
+ .setResultsName('statements')
+
SingleLineScope = pp.Suppress(pp.Literal(':')) + pp.Optional(LC) \
+ pp.Group(Block | (Statement + EOL))('statements')
MultiLineScope = pp.Optional(LC) + Block('statements')
@@ -811,7 +824,7 @@ class QmakeParser:
ElseBranch = pp.Suppress(Else) + (SingleLineElse | MultiLineElse)
Scope <<= pp.Optional(LC) \
+ pp.Group(Condition('condition') \
- + (SingleLineScope | MultiLineScope) \
+ + (SingleLineScope | MultiLineScope | ConditionEndingInFunctionCall) \
+ pp.Optional(ElseBranch)('else_statements'))
if debug: