From 8b3ded6a4ce66a88a48463caec92a7306e2d0069 Mon Sep 17 00:00:00 2001 From: Ilya Bizyaev Date: Fri, 5 Oct 2018 13:29:28 +0300 Subject: [PATCH] Add option to specify qmlimportscanner importPaths (#320) --- tools/linuxdeployqt/main.cpp | 11 ++++++++++- tools/linuxdeployqt/shared.cpp | 10 ++++++++-- tools/linuxdeployqt/shared.h | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/linuxdeployqt/main.cpp b/tools/linuxdeployqt/main.cpp index 19269d5..fe932ce 100644 --- a/tools/linuxdeployqt/main.cpp +++ b/tools/linuxdeployqt/main.cpp @@ -89,6 +89,7 @@ int main(int argc, char **argv) qInfo() << " -no-translations : Skip deployment of translations."; qInfo() << " -qmake= : The qmake executable to use."; qInfo() << " -qmldir= : Scan for QML imports in the given path."; + qInfo() << " -qmlimport= : Add the given path to QML module search locations."; qInfo() << " -show-exclude-libs : Print exclude libraries list."; qInfo() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default),"; qInfo() << " 2 = normal, 3 = debug."; @@ -215,6 +216,7 @@ int main(int argc, char **argv) bool qmldirArgumentUsed = false; bool skipTranslations = false; QStringList qmlDirs; + QStringList qmlImportPaths; QString qmakeExecutable; extern QStringList extraQtPlugins; extern QStringList excludeLibs; @@ -413,6 +415,13 @@ int main(int argc, char **argv) LogError() << "Missing qml directory path"; else qmlDirs << argument.mid(index+1); + } else if (argument.startsWith(QByteArray("-qmlimport"))) { + LogDebug() << "Argument found:" << argument; + int index = argument.indexOf('='); + if (index == -1) + LogError() << "Missing qml import path"; + else + qmlImportPaths << argument.mid(index+1); } else if (argument.startsWith("-no-copy-copyright-files")) { LogDebug() << "Argument found:" << argument; copyCopyrightFiles = false; @@ -471,7 +480,7 @@ int main(int argc, char **argv) } if (!qmlDirs.isEmpty()) { - bool ok = deployQmlImports(appDirPath, deploymentInfo, qmlDirs); + bool ok = deployQmlImports(appDirPath, deploymentInfo, qmlDirs, qmlImportPaths); if (!ok && qmldirArgumentUsed) return 1; // exit if the user explicitly asked for qml import deployment // Update deploymentInfo.deployedLibraries - the QML imports diff --git a/tools/linuxdeployqt/shared.cpp b/tools/linuxdeployqt/shared.cpp index b67b11c..6c38311 100644 --- a/tools/linuxdeployqt/shared.cpp +++ b/tools/linuxdeployqt/shared.cpp @@ -1522,7 +1522,7 @@ void deployQmlImport(const QString &appDirPath, const QSet &rpaths, con } // Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to ./qml. -bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs) +bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths) { if(!qtDetected){ LogDebug() << "Skipping QML imports since no Qt detected"; @@ -1531,7 +1531,8 @@ bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, LogNormal() << ""; LogNormal() << "Deploying QML imports "; - LogNormal() << "Application QML file search path(s) is" << qmlDirs; + LogNormal() << "Application QML file path(s) is" << qmlDirs; + LogNormal() << "QML module search path(s) is" << qmlImportPaths; // Use qmlimportscanner from QLibraryInfo::BinariesPath QString qmlImportScannerPath = QDir::cleanPath(qtToBeBundledInfo.value("QT_INSTALL_BINS")) + "/qmlimportscanner"; @@ -1558,6 +1559,11 @@ bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, argumentList.append(qmlDir); } + foreach (const QString &importPath, qmlImportPaths) { + argumentList.append("-importPath"); + argumentList.append(importPath); + } + argumentList.append( "-importPath"); argumentList.append(qtToBeBundledInfo.value("QT_INSTALL_QML")); diff --git a/tools/linuxdeployqt/shared.h b/tools/linuxdeployqt/shared.h index 5c07bcb..2301059 100644 --- a/tools/linuxdeployqt/shared.h +++ b/tools/linuxdeployqt/shared.h @@ -123,7 +123,7 @@ DeploymentInfo deployQtLibraries(QList libraries,const QString &bun void createQtConf(const QString &appDirPath); void createQtConfForQtWebEngineProcess(const QString &appDirPath); void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo); -bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs); +bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths); void changeIdentification(const QString &id, const QString &binaryPath); void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath); void runStrip(const QString &binaryPath);