qt5base-lts/mkspecs/features/resources_functions.prf
Joerg Bornemann c5777ad81c Fix calls to qtFlattenResources from outside resources.prf
The xml_escape function must be part of resources_functions.prf, and the
qmake_immediate resource must not be created multiple times. Instead,
create another qmake_immediate resource with a number suffix.

This commit amends 577b6554.

Task-number: QTBUG-79672
Change-Id: Ibbe20c0fd1940f1fe7733cd1e5b0891f65689782
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2019-12-10 16:13:51 +01:00

81 lines
2.6 KiB
Plaintext

# http://www.w3.org/TR/xml/#syntax
defineReplace(xml_escape) {
1 ~= s,&,&amp;,
1 ~= s,\',&apos;,
1 ~= s,\",&quot;,
1 ~= s,<,&lt;,
1 ~= s,>,&gt;,
return($$1)
}
defineTest(qtFlattenResources) {
immediate = qmake_immediate$$QMAKE_RESOURCES_IMMEDIATE_NR
defined(QMAKE_RESOURCES_IMMEDIATE_NR, var): \
QMAKE_RESOURCES_IMMEDIATE_NR = $$num_add($$QMAKE_RESOURCES_IMMEDIATE_NR, 1)
else: \
QMAKE_RESOURCES_IMMEDIATE_NR = 1
RESOURCES += $$immediate
for(resource, RESOURCES) {
# Regular case of user qrc file
contains(resource, ".*\\.qrc$"): \
next()
# Fallback for stand-alone files/directories
!defined($${resource}.files, var) {
!equals(resource, $$immediate) {
!exists($$absolute_path($$resource, $$_PRO_FILE_PWD_)): \
warning("Failure to find: $$resource")
$${immediate}.files += $$resource
OTHER_FILES *= $$resource
}
RESOURCES -= $$resource
next()
}
resource_file = $$absolute_path($$RCC_DIR/qmake_$${resource}.qrc, $$OUT_PWD)
isEmpty(BUILDS)|build_pass {
# Collection of files, generate qrc file
prefix = $$eval($${resource}.prefix)
isEmpty(prefix): \
prefix = "/"
resource_file_content = \
"<!DOCTYPE RCC><RCC version=\"1.0\">" \
"<qresource prefix=\"$$xml_escape($$prefix)\">"
abs_base = $$absolute_path($$eval($${resource}.base), $$_PRO_FILE_PWD_)
for(file, $${resource}.files) {
abs_path = $$absolute_path($$file, $$_PRO_FILE_PWD_)
files = $$files($$abs_path/*, true)
isEmpty(files): \
files = $$abs_path
for (file, files) {
exists($$file/*): next() # exclude directories
alias = $$relative_path($$file, $$abs_base)
resource_file_content += \
"<file alias=\"$$xml_escape($$alias)\">$$xml_escape($$file)</file>"
OTHER_FILES *= $$file
}
}
resource_file_content += \
"</qresource>" \
"</RCC>"
!write_file($$resource_file, resource_file_content): \
error()
}
RESOURCES -= $$resource
RESOURCES += $$resource_file
}
export(QMAKE_RESOURCES_IMMEDIATE_NR)
export(RESOURCES)
export(OTHER_FILES)
export($${immediate}.files)
return(true)
}