summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Bizyaev <bizyaev@zoho.com>2018-10-09 23:14:44 +0300
committerIlya Bizyaev <bizyaev@zoho.com>2018-10-18 06:19:38 +0000
commit3d3ec897712f590e9e4e5ffad4b7017e235295cb (patch)
treedfcc4397928ad3aefc209a4f7cb014ad814e67cf
parent7c39470f174a3ab64c5425d9e349b3fe9f1be7cd (diff)
Support qmlimport option in windeployqt
This patch adds a new option, -qmlimport, which enables windeployqt to pass custom QML module import paths to qmlimportscanner. Change-Id: Iacde05543ab1f8f85b8306661e4674ad24badce4 Fixes: QTBUG-71045 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/shared/winutils/qmlutils.cpp6
-rw-r--r--src/shared/winutils/qmlutils.h2
-rw-r--r--src/windeployqt/main.cpp15
3 files changed, 19 insertions, 4 deletions
diff --git a/src/shared/winutils/qmlutils.cpp b/src/shared/winutils/qmlutils.cpp
index 6fe77e64..41444649 100644
--- a/src/shared/winutils/qmlutils.cpp
+++ b/src/shared/winutils/qmlutils.cpp
@@ -95,14 +95,16 @@ static void findFileRecursion(const QDir &directory, Platform platform,
}
}
-QmlImportScanResult runQmlImportScanner(const QString &directory, const QString &qmlImportPath,
+QmlImportScanResult runQmlImportScanner(const QString &directory, const QStringList &qmlImportPaths,
bool usesWidgets, int platform, DebugMatchMode debugMatchMode,
QString *errorMessage)
{
Q_UNUSED(usesWidgets);
QmlImportScanResult result;
QStringList arguments;
- arguments << QStringLiteral("-importPath") << qmlImportPath << QStringLiteral("-rootPath") << directory;
+ for (const QString &importPath : qmlImportPaths)
+ arguments << QStringLiteral("-importPath") << importPath;
+ arguments << QStringLiteral("-rootPath") << directory;
unsigned long exitCode;
QByteArray stdOut;
QByteArray stdErr;
diff --git a/src/shared/winutils/qmlutils.h b/src/shared/winutils/qmlutils.h
index 895c7f1d..a0500710 100644
--- a/src/shared/winutils/qmlutils.h
+++ b/src/shared/winutils/qmlutils.h
@@ -57,7 +57,7 @@ struct QmlImportScanResult {
bool operator==(const QmlImportScanResult::Module &m1, const QmlImportScanResult::Module &m2);
-QmlImportScanResult runQmlImportScanner(const QString &directory, const QString &qmlImportPath,
+QmlImportScanResult runQmlImportScanner(const QString &directory, const QStringList &qmlImportPaths,
bool usesWidgets, int platform, DebugMatchMode debugMatchMode,
QString *errorMessage);
diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index efffc5d0..738887c0 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -262,6 +262,7 @@ struct Options {
quint64 disabledLibraries = 0;
unsigned updateFileFlags = 0;
QStringList qmlDirectories; // Project's QML files.
+ QStringList qmlImportPaths; // Custom QML module locations.
QString directory;
QString translationsDirectory; // Translations target directory
QString libraryDirectory;
@@ -378,6 +379,11 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
QStringLiteral("directory"));
parser->addOption(qmlDirOption);
+ QCommandLineOption qmlImportOption(QStringLiteral("qmlimport"),
+ QStringLiteral("Add the given path to the QML module search locations."),
+ QStringLiteral("directory"));
+ parser->addOption(qmlImportOption);
+
QCommandLineOption noQuickImportOption(QStringLiteral("no-quick-import"),
QStringLiteral("Skip deployment of Qt Quick imports."));
parser->addOption(noQuickImportOption);
@@ -590,6 +596,9 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
if (parser->isSet(qmlDirOption))
options->qmlDirectories = parser->values(qmlDirOption);
+ if (parser->isSet(qmlImportOption))
+ options->qmlImportPaths = parser->values(qmlImportOption);
+
const QString &file = posArgs.front();
const QFileInfo fi(QDir::cleanPath(file));
if (!fi.exists()) {
@@ -1298,6 +1307,10 @@ static DeployResult deploy(const Options &options,
// Scan Quick2 imports
QmlImportScanResult qmlScanResult;
if (options.quickImports && usesQml2) {
+ // Custom list of import paths provided by user
+ QStringList qmlImportPaths = options.qmlImportPaths;
+ // Qt's own QML modules
+ qmlImportPaths << qmakeVariables.value(QStringLiteral("QT_INSTALL_QML"));
QStringList qmlDirectories = options.qmlDirectories;
if (qmlDirectories.isEmpty()) {
const QString qmlDirectory = findQmlDirectory(options.platform, options.directory);
@@ -1308,7 +1321,7 @@ static DeployResult deploy(const Options &options,
if (optVerboseLevel >= 1)
std::wcout << "Scanning " << QDir::toNativeSeparators(qmlDirectory) << ":\n";
const QmlImportScanResult scanResult =
- runQmlImportScanner(qmlDirectory, qmakeVariables.value(QStringLiteral("QT_INSTALL_QML")),
+ runQmlImportScanner(qmlDirectory, qmlImportPaths,
result.directlyUsedQtLibraries & QtWidgetsModule,
options.platform, debugMatchMode, errorMessage);
if (!scanResult.ok)