summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-08-06 14:51:04 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-08-06 13:17:17 +0000
commitd9432527414f66c5eaa8d44697ad307f9b37bd66 (patch)
treee9f2384046fc342d40997ffd027eef4523430a75 /util/cmake/pro2cmake.py
parent709538096c9e52c0ab7a54a1fd2f63f7e42584f8 (diff)
Fix shared resource paths in tests
Resources shared by tests were incorrectly setup. Resources would always be registered with BASE/filename as alias. In these cases the fix is to set the alias with the original file name. Change-Id: I667ce7b74ae5f86740c8bb8a040cc2895a3dc116 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 905c2107d7..8a002244ef 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -133,8 +133,12 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil
resource_name = os.path.splitext(os.path.basename(filepath))[0]
- base_dir = os.path.join('' if base_dir == '.' else base_dir, os.path.dirname(filepath))
+ dir_name = os.path.dirname(filepath)
+ base_dir = os.path.join('' if base_dir == '.' else base_dir, dir_name)
+ # Small not very thorough check to see if this a shared qrc resource
+ # pattern is mostly used by the tests.
+ is_parent_path = dir_name.startswith('..')
if not os.path.isfile(filepath):
raise RuntimeError('Invalid file path given to process_qrc_file: {}'.format(filepath))
@@ -159,6 +163,11 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil
# Get alias:
alias = file.get('alias', '')
+ # In cases where examples use shared resources, we set the alias
+ # too the same name of the file, or the applications won't be
+ # be able to locate the resource
+ if not alias and is_parent_path:
+ alias = path
files[path] = alias
sorted_files = sorted(files.keys())