diff options
author | Jędrzej Nowacki <jedrzej.nowacki@qt.io> | 2019-03-25 17:30:16 +0100 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@qt.io> | 2019-03-28 12:29:44 +0000 |
commit | ce9a1434670196c151c34ce5e0f7ed0718f4215f (patch) | |
tree | 0a9aa487418d80e75975ebc80692efdd8216ec87 /util/cmake/run_pro2cmake.py | |
parent | 601c840973e91987c492f4b312215ff17a95e837 (diff) |
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>
Diffstat (limited to 'util/cmake/run_pro2cmake.py')
-rwxr-xr-x | util/cmake/run_pro2cmake.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/util/cmake/run_pro2cmake.py b/util/cmake/run_pro2cmake.py index b3a07c7522..47bc6b661f 100755 --- a/util/cmake/run_pro2cmake.py +++ b/util/cmake/run_pro2cmake.py @@ -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: |