summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xutil/cmake/pro2cmake.py11
-rw-r--r--util/cmake/tests/data/complex_assign.pro2
-rwxr-xr-xutil/cmake/tests/test_parsing.py6
3 files changed, 17 insertions, 2 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 1d48d2ba58a..1f85e977aac 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -515,6 +515,12 @@ class QmakeParser:
Else = pp.Keyword('else')
DefineTest = pp.Keyword('defineTest')
Identifier = pp.Word(pp.alphas + '_', bodyChars=pp.alphanums+'_-./')
+ BracedValue = pp.nestedExpr(ignoreExpr=pp.quotedString \
+ | pp.QuotedString(quoteChar='$(',
+ endQuoteChar=')',
+ escQuote='\\',
+ unquoteResults=False)
+ ).setParseAction(lambda s, l, t: ['(', *t[0], ')'])
Substitution \
= pp.Combine(pp.Literal('$')
@@ -534,7 +540,8 @@ class QmakeParser:
| pp.Literal('$')))
Value = pp.NotAny(Else | pp.Literal('}') | EOL | pp.Literal('\\')) \
+ (pp.QuotedString(quoteChar='"', escChar='\\')
- | SubstitutionValue)
+ | SubstitutionValue
+ | BracedValue)
Values = pp.ZeroOrMore(Value + pp.Optional(LC))('value')
@@ -598,7 +605,7 @@ class QmakeParser:
'Else ElseBranch SingleLineElse MultiLineElse ' \
'SingleLineScope MultiLineScope ' \
'Identifier ' \
- 'Key Op Values Value ' \
+ 'Key Op Values Value BracedValue ' \
'Scope Block ' \
'StatementGroup StatementLine Statement '\
'Load Include Option DefineTest ForLoop ' \
diff --git a/util/cmake/tests/data/complex_assign.pro b/util/cmake/tests/data/complex_assign.pro
new file mode 100644
index 00000000000..d251afcdd58
--- /dev/null
+++ b/util/cmake/tests/data/complex_assign.pro
@@ -0,0 +1,2 @@
+qmake-clean.commands += (cd qmake && $(MAKE) clean ":-(==)-:" '(Foo)' )
+
diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py
index e4f9680f603..c238c80c084 100755
--- a/util/cmake/tests/test_parsing.py
+++ b/util/cmake/tests/test_parsing.py
@@ -254,3 +254,9 @@ def test_realworld_contains_scope():
result = parse_file(_tests_path + '/data/contains_scope.pro')
assert len(result) == 2
+
+def test_realworld_complex_assign():
+ result = parse_file(_tests_path + '/data/complex_assign.pro')
+ assert len(result) == 1
+ validate_op('qmake-clean.commands', '+=', '( cd qmake && $(MAKE) clean ":-(==)-:" \'(Foo)\' )'.split(),
+ result[0])