From aed2c1f5ae002df7cc92bd4ceaa65c173757c40a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 7 May 2019 16:46:28 +0200 Subject: [PATCH] Force pro2cmake.py to always change the dir to the converted pro file Otherwise if you call the script from a different directory, path handling becomes broken and certain files are not found. Change-Id: Ia2f60abbd312a771330b3d5e928e1ccd0b4a845b Reviewed-by: Tobias Hunger --- util/cmake/pro2cmake.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 23ba9d7fc8b..a6ebc1094c0 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1566,8 +1566,14 @@ def main() -> None: debug_parsing = args.debug_parser or args.debug + backup_current_dir = os.getcwd() + for file in args.files: - parseresult = parseProFile(file, debug=debug_parsing) + new_current_dir = os.path.dirname(file) + file_relative_path = os.path.basename(file) + os.chdir(new_current_dir) + + parseresult = parseProFile(file_relative_path, debug=debug_parsing) if args.debug_parse_result or args.debug: print('\n\n#### Parser result:') @@ -1578,7 +1584,7 @@ def main() -> None: print(parseresult.asDict()) print('\n#### End of parser result dictionary.\n') - file_scope = Scope.FromDict(None, file, + file_scope = Scope.FromDict(None, file_relative_path, parseresult.asDict().get('statements')) if args.debug_pro_structure or args.debug: @@ -1594,6 +1600,7 @@ def main() -> None: print('\n#### End of full .pro/.pri file structure.\n') generate_cmakelists(file_scope) + os.chdir(backup_current_dir) if __name__ == '__main__':