From 361a24ae1c3676f971a66d9e91715c07bc7bf5ed Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 8 Oct 2019 11:19:20 +0200 Subject: [PATCH] run_pro2cmake: Fix the file preference sorter When invoking the script with "." as the only argument, and there are multiple .pro files in the current directory, the script would not choose the correct preferred .pro file (the one that has the same name as the current directory). Fix the sorter to handle such a case. Change-Id: I6df70d7c577649f8854bca9b8879f13bdb1b4d26 Reviewed-by: Simon Hausmann --- util/cmake/run_pro2cmake.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/cmake/run_pro2cmake.py b/util/cmake/run_pro2cmake.py index cb7181449a4..0db9f2a6071 100755 --- a/util/cmake/run_pro2cmake.py +++ b/util/cmake/run_pro2cmake.py @@ -77,7 +77,9 @@ def find_all_pro_files(base_path: str, args: argparse.Namespace): """ Sorter that tries to prioritize main pro files in a directory. """ pro_file_without_suffix = pro_file.rsplit("/", 1)[-1][:-4] dir_name = os.path.dirname(pro_file) - if dir_name.endswith("/" + pro_file_without_suffix): + if dir_name == ".": + dir_name = os.path.basename(os.getcwd()) + if dir_name.endswith(pro_file_without_suffix): return dir_name return dir_name + "/__" + pro_file