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 <simon.hausmann@qt.io>
bb10
Alexandru Croitor 2019-10-08 11:19:20 +02:00
parent a48a3e95cf
commit 361a24ae1c
1 changed files with 3 additions and 1 deletions

View File

@ -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