Do not overwrite CMakeLists.txt when running run_pro2cmake
One directory may contain many pro files. The generator was happily generating the same CMakeLists.txt for all of them (overwriting). This patch implements a different logic. It tries to find the main pro file and skips others assuming that somehow implicitly they will be incorporated (for example through SUBDIRS). Change-Id: Ie07d75e900a96dd48bf981a896c9dfb920f39a23 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
parent
601c840973
commit
ce9a143467
@ -41,9 +41,33 @@ pro2cmake = os.path.join(script_path, 'pro2cmake.py')
|
||||
if len(sys.argv) > 1:
|
||||
base_path = os.path.abspath(sys.argv[1])
|
||||
|
||||
failed_files = []
|
||||
|
||||
all_files = glob.glob(os.path.join(base_path, '**/*.pro'), recursive=True)
|
||||
def find_all_pro_files():
|
||||
|
||||
def sorter(pro_file: str) -> str:
|
||||
""" 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):
|
||||
return dir_name
|
||||
return dir_name + "/__" + pro_file
|
||||
|
||||
all_files = []
|
||||
previous_dir_name: str = None
|
||||
for pro_file in sorted(glob.glob(os.path.join(base_path, '**/*.pro'),
|
||||
recursive=True),
|
||||
key=sorter):
|
||||
dir_name = os.path.dirname(pro_file)
|
||||
if dir_name == previous_dir_name:
|
||||
print("Skipping:", pro_file)
|
||||
else:
|
||||
all_files.append(pro_file)
|
||||
previous_dir_name = dir_name
|
||||
return all_files
|
||||
|
||||
|
||||
failed_files = []
|
||||
all_files = find_all_pro_files()
|
||||
files_count = len(all_files)
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(initializer=os.nice, initargs=(10,)) as pool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user