summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-05-14 15:31:30 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-18 19:11:38 +0000
commit78a192e58d208680f10d397b275a5b571b600749 (patch)
tree0faab14f106c2a0c45047f76a2e43ad95c8f5560 /util
parentfb9d138e5369c0585cc658583a60539002057ec6 (diff)
Fix BASE argument of qt_add_resources
The BASE argument of qt_add_resources now denotes the root point of the alias of the file. Before, BASE was merely prepended to every file that got passed to qt_add_resources. Old behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "images/button.png") Alias is "../shared/images/button.png", and pro2cmake generated QT_RESOURCE_ALIAS assignments to fix this. New behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "../shared/images/button.png") The alias is "images/button.png". No extra QT_RESOURCE_ALIAS assignment is needed. The new behavior is in effect for user projects and for Qt repositories that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE. Qt repositories will be ported one by one to this new behavior. Then the old code path can be removed. Task-number: QTBUG-86726 Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 92185d417de43237ae62eae55599c65922cd9a15) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index e6943727a4..413f1f44bc 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -482,11 +482,6 @@ def process_qrc_file(
# 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
output += write_add_qt_resource_call(
@@ -518,26 +513,29 @@ def write_add_qt_resource_call(
) -> str:
output = ""
- sorted_files = sorted(files.keys())
-
- assert sorted_files
-
if base_dir:
base_dir_expanded = scope.expandString(base_dir)
if base_dir_expanded:
base_dir = base_dir_expanded
+ new_files = {}
+ for file_path, alias in files.items():
+ full_file_path = posixpath.join(base_dir, file_path)
+ new_files[full_file_path] = alias
+ files = new_files
+
+ sorted_files = sorted(files.keys())
+ assert sorted_files
source_file_properties = defaultdict(list)
for source in sorted_files:
- full_source = posixpath.join(base_dir, source)
alias = files[source]
if alias:
- source_file_properties[full_source].append(f'QT_RESOURCE_ALIAS "{alias}"')
+ source_file_properties[source].append(f'QT_RESOURCE_ALIAS "{alias}"')
# If a base dir is given, we have to write the source file property
# assignments that disable the quick compiler per file.
if base_dir and skip_qtquick_compiler:
- source_file_properties[full_source].append("QT_SKIP_QUICKCOMPILER 1")
+ source_file_properties[source].append("QT_SKIP_QUICKCOMPILER 1")
for full_source in source_file_properties:
per_file_props = source_file_properties[full_source]