diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-03-11 15:34:27 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-03-12 16:30:46 +0100 |
commit | a5ec9bea639ac0343b15fc740ecd526702bb5f45 (patch) | |
tree | 8bd580ed9c47ce9404159a78370813a22317d727 | |
parent | d4018dac8b0c1834ae3f865020637f63d6846ddd (diff) |
CMake: pro2cmake handle ${QT_SOURCE_TREE} for include statements
Replace ${QT_SOURCE_TREE} with top level project directory when
encountered in include statements.
This is required to parse tests/auto/testlib/selftests/test/test.pro.
Change-Id: I80f31142cf5a35441d1424c38e21bb097e44cd0f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rwxr-xr-x | util/cmake/pro2cmake.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index e6ad26ad3c..6010120e45 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -191,6 +191,10 @@ def _parse_commandline(): ) return parser.parse_args() +def get_top_level_repo_project_path(project_file_path: str = "") -> str: + qmake_conf_path = find_qmake_conf(project_file_path) + qmake_conf_dir_path = os.path.dirname(qmake_conf_path) + return qmake_conf_dir_path def is_top_level_repo_project(project_file_path: str = "") -> bool: qmake_conf_path = find_qmake_conf(project_file_path) @@ -3977,6 +3981,9 @@ def do_include(scope: Scope, *, debug: bool = False) -> None: for include_index, include_file in enumerate(scope.get_files("_INCLUDED", is_include=True)): if not include_file: continue + if include_file.startswith("${QT_SOURCE_TREE}"): + root_source_dir = get_top_level_repo_project_path(scope.file_absolute_path) + include_file = include_file.replace("${QT_SOURCE_TREE}", root_source_dir) if not os.path.isfile(include_file): generated_config_pri_pattern = re.compile(r"qt.+?-config\.pri$") match_result = re.search(generated_config_pri_pattern, include_file) |