2019-11-27 13:52:32 +00:00
|
|
|
# http://www.w3.org/TR/xml/#syntax
|
|
|
|
defineReplace(xml_escape) {
|
|
|
|
1 ~= s,&,&,
|
|
|
|
1 ~= s,\',',
|
|
|
|
1 ~= s,\",",
|
|
|
|
1 ~= s,<,<,
|
|
|
|
1 ~= s,>,>,
|
|
|
|
return($$1)
|
|
|
|
}
|
|
|
|
|
2019-11-04 12:34:36 +00:00
|
|
|
defineTest(qtFlattenResources) {
|
2019-11-27 13:52:32 +00:00
|
|
|
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
|
2019-11-04 12:34:36 +00:00
|
|
|
for(resource, RESOURCES) {
|
|
|
|
# Regular case of user qrc file
|
|
|
|
contains(resource, ".*\\.qrc$"): \
|
|
|
|
next()
|
|
|
|
|
|
|
|
# Fallback for stand-alone files/directories
|
|
|
|
!defined($${resource}.files, var) {
|
2019-11-27 13:52:32 +00:00
|
|
|
!equals(resource, $$immediate) {
|
2019-11-04 12:34:36 +00:00
|
|
|
!exists($$absolute_path($$resource, $$_PRO_FILE_PWD_)): \
|
|
|
|
warning("Failure to find: $$resource")
|
2019-11-27 13:52:32 +00:00
|
|
|
$${immediate}.files += $$resource
|
2019-11-04 12:34:36 +00:00
|
|
|
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
|
|
|
|
}
|
2019-11-27 13:52:32 +00:00
|
|
|
export(QMAKE_RESOURCES_IMMEDIATE_NR)
|
2019-11-04 12:34:36 +00:00
|
|
|
export(RESOURCES)
|
|
|
|
export(OTHER_FILES)
|
2019-11-27 13:52:32 +00:00
|
|
|
export($${immediate}.files)
|
2019-11-04 12:34:36 +00:00
|
|
|
return(true)
|
|
|
|
}
|