qt5base-lts/mkspecs/features/resources_functions.prf

64 lines
2.1 KiB
Plaintext
Raw Normal View History

defineTest(qtFlattenResources) {
RESOURCES += qmake_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, qmake_immediate) {
!exists($$absolute_path($$resource, $$_PRO_FILE_PWD_)): \
warning("Failure to find: $$resource")
qmake_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(RESOURCES)
export(OTHER_FILES)
export(qmake_immediate.files)
return(true)
}