diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-08 16:18:34 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-11 15:48:35 +0000 |
commit | 21aac7612477ada4c4b360681541312a98cfacfc (patch) | |
tree | eee59108cba87ab2833520e3ae12e3f5b0ac0dae | |
parent | 8148b3c04bc68c6c4d4b8e7bb6a6ba9e362967de (diff) |
Add --bare option to qmltc and qmlcachegen
We need those to prevent usage of the host Qt's import path when
building QML files for the target.
Task-number: QTBUG-106365
Change-Id: I34499af850fb759603206cb429ff97633c76054d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 2f583eeab254edbb0e1b42213e9d48ce6ad3f04e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tools/qmlcachegen/qmlcachegen.cpp | 5 | ||||
-rw-r--r-- | tools/qmltc/main.cpp | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index f3fc06bec5..3a74f587e9 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -66,6 +66,8 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addVersionOption(); + QCommandLineOption bareOption(QStringLiteral("bare"), QCoreApplication::translate("main", "Do not include default import directories. This may be used to run qmlcachegen on a project using a different Qt version.")); + parser.addOption(bareOption); QCommandLineOption filterResourceFileOption(QStringLiteral("filter-resource-file"), QCoreApplication::translate("main", "Filter out QML/JS files from a resource file that can be cached ahead of time instead")); parser.addOption(filterResourceFileOption); QCommandLineOption resourceFileMappingOption(QStringLiteral("resource-file-mapping"), QCoreApplication::translate("main", "Path from original resource file to new one"), QCoreApplication::translate("main", "old-name=new-name")); @@ -234,7 +236,8 @@ int main(int argc, char **argv) if (parser.isSet(importPathOption)) importPaths = parser.values(importPathOption); - importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath)); + if (!parser.isSet(bareOption)) + importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath)); QQmlJSImporter importer( importPaths, parser.isSet(resourceOption) ? &fileMapper : nullptr); diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index cf47943034..d47c9af4e4 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -58,6 +58,14 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addVersionOption(); + QCommandLineOption bareOption { + u"bare"_s, + QCoreApplication::translate( + "main", "Do not include default import directories. This may be used to run " + "qmltc on a project using a different Qt version.") + }; + parser.addOption(bareOption); + QCommandLineOption importPathOption { u"I"_s, QCoreApplication::translate("main", "Look for QML modules in specified directory"), QCoreApplication::translate("main", "import directory") @@ -123,7 +131,8 @@ int main(int argc, char **argv) return EXIT_FAILURE; QStringList importPaths = parser.values(importPathOption); - importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath)); + if (!parser.isSet(bareOption)) + importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath)); QStringList qmldirFiles = parser.values(qmldirOption); QString outputCppFile; |