From 754ba287999e0d1681f77d12f6d7c3ae0362745a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 27 Feb 2019 13:58:00 +0100 Subject: [PATCH] CMake: pro2cmake.py: Fix parsing of Line continuation before end of file ... and add a test case for this. Change-Id: If20d737b54ecb3f9e128e59070b238c840acad6c Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 2 +- util/cmake/tests/data/sql.pro | 3 +++ util/cmake/tests/test_parsing.py | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 util/cmake/tests/data/sql.pro diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 6002f780376..5d161a139ab 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -518,7 +518,7 @@ class QmakeParser: pp.ParserElement.setDefaultWhitespaceChars(' \t') LC = pp.Suppress(pp.Literal('\\\n')) - EOL = pp.Suppress(pp.Literal('\n')) + EOL = pp.Suppress(pp.Literal('\n') ^ pp.LineEnd()) Else = pp.Keyword('else') Identifier = pp.Word(pp.alphas + '_', bodyChars=pp.alphanums+'_-./') BracedValue = pp.nestedExpr(ignoreExpr=pp.quotedString \ diff --git a/util/cmake/tests/data/sql.pro b/util/cmake/tests/data/sql.pro new file mode 100644 index 00000000000..a9d7fc7c5a4 --- /dev/null +++ b/util/cmake/tests/data/sql.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + kernel \ diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py index d0a9960dc7f..1f50fc87ab3 100755 --- a/util/cmake/tests/test_parsing.py +++ b/util/cmake/tests/test_parsing.py @@ -281,3 +281,9 @@ def test_realworld_complex_condition(): assert len(else_branch) == 0 + +def test_realworld_sql(): + result = parse_file(_tests_path + '/data/sql.pro') + assert len(result) == 2 + validate_op('TEMPLATE', '=', ['subdirs'], result[0]) + validate_op('SUBDIRS', '=', ['kernel'], result[1])