From 577b6554f0d48a8d6e178cab52676d961f6bb997 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 4 Nov 2019 13:34:36 +0100 Subject: Move RESOURCE flattening code to dedicated function Introduce resources_functions.prf with the test function qtFlattenResources which ensures that RESOURCES has a flat structure, e.g. only contains *.qrc entries. This can be called by other .prf files like qtquickcompiler.prf without disturbing the ability to extend RESOURCES in other .prf files. Task-number: QTBUG-79672 Change-Id: I43246e40f5ea52a9d9c917a1bd781aeeb1304acc Reviewed-by: Kai Koehne --- mkspecs/features/resources.prf | 59 +----------------------------- mkspecs/features/resources_functions.prf | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 57 deletions(-) create mode 100644 mkspecs/features/resources_functions.prf (limited to 'mkspecs') diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index fa8ff1fb58..ca95768de8 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -16,63 +16,8 @@ defineReplace(xml_escape) { return($$1) } -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 = \ - "" \ - "" - - 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 += \ - "$$xml_escape($$file)" - OTHER_FILES *= $$file - } - } - - resource_file_content += \ - "" \ - "" - - !write_file($$resource_file, resource_file_content): \ - error() - } - - RESOURCES -= $$resource - RESOURCES += $$resource_file -} +load(resources_functions) +qtFlattenResources() !isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static { pluginBaseName = $$basename(TARGET) diff --git a/mkspecs/features/resources_functions.prf b/mkspecs/features/resources_functions.prf new file mode 100644 index 0000000000..f7fed9e524 --- /dev/null +++ b/mkspecs/features/resources_functions.prf @@ -0,0 +1,63 @@ +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 = \ + "" \ + "" + + 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 += \ + "$$xml_escape($$file)" + OTHER_FILES *= $$file + } + } + + resource_file_content += \ + "" \ + "" + + !write_file($$resource_file, resource_file_content): \ + error() + } + + RESOURCES -= $$resource + RESOURCES += $$resource_file + } + export(RESOURCES) + export(OTHER_FILES) + export(qmake_immediate.files) + return(true) +} -- cgit v1.2.3