summaryrefslogtreecommitdiffstats
path: root/src/tools/rcc
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-07-10 13:59:10 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-07-25 07:08:31 +0000
commite883ef619721e905cf2b5310c9a1e14665fba6b9 (patch)
tree1bf7a667953aa0e8a5be1a96a5f6172529ea9dad /src/tools/rcc
parentd1dcc4d8cdc36520dcc6cda4ad02eca8607f7b79 (diff)
rcc: Add a --list-mapping option to output both resource and real paths
The --list option outputs only the file system paths, but does not tell us where those files end up in the resource file system. This is unfortunate because the resource paths are possibly the most interesting thing to be expected from a listing of resource files. Add an option that outputs a full mapping. This is also useful for tools that need to resolve files for resource paths from outside the application using the resources. [ChangeLog][Tools][rcc] Added a --list-mapping option which shows a mapping of resource paths to file system paths. Change-Id: I0cb57fe091ef78b4a9eca8be2fc53278ae50cc11 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/tools/rcc')
-rw-r--r--src/tools/rcc/main.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp
index fba47b74c3..12f986b1e2 100644
--- a/src/tools/rcc/main.cpp
+++ b/src/tools/rcc/main.cpp
@@ -151,6 +151,10 @@ int runRcc(int argc, char *argv[])
QCommandLineOption listOption(QStringLiteral("list"), QStringLiteral("Only list .qrc file entries, do not generate code."));
parser.addOption(listOption);
+ QCommandLineOption mapOption(QStringLiteral("list-mapping"),
+ QStringLiteral("Only output a mapping of resource paths to file system paths defined in the .qrc file, do not generate code."));
+ parser.addOption(mapOption);
+
QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory."));
parser.addOption(projectOption);
@@ -207,6 +211,7 @@ int runRcc(int argc, char *argv[])
library.setVerbose(true);
const bool list = parser.isSet(listOption);
+ const bool map = parser.isSet(mapOption);
const bool projectRequested = parser.isSet(projectOption);
const QStringList filenamesIn = parser.positionalArguments();
@@ -242,7 +247,7 @@ int runRcc(int argc, char *argv[])
library.setInputFiles(filenamesIn);
- if (!library.readFiles(list, errorDevice))
+ if (!library.readFiles(list || map, errorDevice))
return 1;
QFile out;
@@ -294,6 +299,17 @@ int runRcc(int argc, char *argv[])
return 0;
}
+ if (map) {
+ const RCCResourceLibrary::ResourceDataFileMap data = library.resourceDataFileMap();
+ for (auto it = data.begin(), end = data.end(); it != end; ++it) {
+ out.write(qPrintable(it.key()));
+ out.write("\t");
+ out.write(qPrintable(QDir::cleanPath(it.value())));
+ out.write("\n");
+ }
+ return 0;
+ }
+
QFile temp;
if (!tempFilename.isEmpty()) {
temp.setFileName(tempFilename);