diff options
Diffstat (limited to 'src/extras/generateresource.prf')
-rw-r--r-- | src/extras/generateresource.prf | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/extras/generateresource.prf b/src/extras/generateresource.prf new file mode 100644 index 00000000..f84f1d87 --- /dev/null +++ b/src/extras/generateresource.prf @@ -0,0 +1,27 @@ +defineReplace(generate_resource) { + GENERATED_FILE = $$OUT_PWD/$$1 + INCLUDED_FILES = $$2 + GENERATED_CONTENT = \ + "<RCC>" + + RESOURCE_PREFIX = "" + for (FILE, INCLUDED_FILES) { + RELATIVE_PATH = $$relative_path($$absolute_path($$FILE), $$_PRO_FILE_PWD_) + SUB_FOLDER = /$$dirname(RELATIVE_PATH) + !equals(SUB_FOLDER, $$RESOURCE_PREFIX) { + !isEmpty(RESOURCE_PREFIX): GENERATED_CONTENT += "</qresource>" + RESOURCE_PREFIX = "ExtrasImports"/$$TARGETPATH$$SUB_FOLDER + GENERATED_CONTENT += "<qresource prefix=\"$$RESOURCE_PREFIX\">" + } + ABSOLUTE_PATH = $$absolute_path($$FILE) + ALIAS_NAME = $$basename(FILE) + GENERATED_CONTENT += "<file alias=\"$$ALIAS_NAME\">$$ABSOLUTE_PATH</file>" + } + !isEmpty(RESOURCE_PREFIX): GENERATED_CONTENT += "</qresource>" + + GENERATED_CONTENT += \ + "</RCC>" + write_file($$GENERATED_FILE, GENERATED_CONTENT)|error("Failed to write resource file!") + + return($$GENERATED_FILE) +} |