pro2cmake: Fix regressions introduced by reformat change

Sympy uses eval() inside its code, and that can raise an
AttributeError exception, so we have to catch that.
This happened when converting qml.pro in qtdeclarative.

Also the formatting change removed the raising of an exception
when an unhandled function was encountered in handle_function_value,
which caused not returning any value in such a case.
Instead just return the whole expression string, without checking
if the function is in some whitelist.
Also encountered in qml.pro.

Amends 91634c3c9b.

Change-Id: I47b73af1de0180becb9ef4fb78a8c35a04928d34
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
bb10
Alexandru Croitor 2019-09-22 16:42:16 +02:00
parent fbddf745e9
commit f0a22bd78d
1 changed files with 3 additions and 17 deletions

View File

@ -631,22 +631,8 @@ def handle_function_value(group: pp.ParseResults):
if isinstance(function_args, pp.ParseResults):
function_args = list(flatten_list(function_args.asList()))
# Return the whole expression as a string.
if function_name in [
"join",
"files",
"cmakeRelativePath",
"shell_quote",
"shadowed",
"cmakeTargetPath",
"shell_path",
"cmakeProcessLibs",
"cmakeTargetPaths",
"cmakePortablePaths",
"escape_expand",
"member",
]:
return f"join({''.join(function_args)})"
# For other functions, return the whole expression as a string.
return f"$${function_name}({' '.join(function_args)})"
class Operation:
@ -2178,7 +2164,7 @@ def simplify_condition(condition: str) -> str:
condition = condition.replace("True", "ON")
condition = condition.replace("False", "OFF")
condition = condition.replace("_dash_", "-")
except (SympifyError, TypeError):
except (SympifyError, TypeError, AttributeError):
# sympy did not like our input, so leave this condition alone:
condition = input_condition