Skip to content

Commit 8b3ded6

Browse files
IlyaBizyaevprobonopd
authored andcommitted
Add option to specify qmlimportscanner importPaths (#320)
1 parent c6c6898 commit 8b3ded6

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

tools/linuxdeployqt/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ int main(int argc, char **argv)
8989
qInfo() << " -no-translations : Skip deployment of translations.";
9090
qInfo() << " -qmake=<path> : The qmake executable to use.";
9191
qInfo() << " -qmldir=<path> : Scan for QML imports in the given path.";
92+
qInfo() << " -qmlimport=<path> : Add the given path to QML module search locations.";
9293
qInfo() << " -show-exclude-libs : Print exclude libraries list.";
9394
qInfo() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default),";
9495
qInfo() << " 2 = normal, 3 = debug.";
@@ -215,6 +216,7 @@ int main(int argc, char **argv)
215216
bool qmldirArgumentUsed = false;
216217
bool skipTranslations = false;
217218
QStringList qmlDirs;
219+
QStringList qmlImportPaths;
218220
QString qmakeExecutable;
219221
extern QStringList extraQtPlugins;
220222
extern QStringList excludeLibs;
@@ -413,6 +415,13 @@ int main(int argc, char **argv)
413415
LogError() << "Missing qml directory path";
414416
else
415417
qmlDirs << argument.mid(index+1);
418+
} else if (argument.startsWith(QByteArray("-qmlimport"))) {
419+
LogDebug() << "Argument found:" << argument;
420+
int index = argument.indexOf('=');
421+
if (index == -1)
422+
LogError() << "Missing qml import path";
423+
else
424+
qmlImportPaths << argument.mid(index+1);
416425
} else if (argument.startsWith("-no-copy-copyright-files")) {
417426
LogDebug() << "Argument found:" << argument;
418427
copyCopyrightFiles = false;
@@ -471,7 +480,7 @@ int main(int argc, char **argv)
471480
}
472481

473482
if (!qmlDirs.isEmpty()) {
474-
bool ok = deployQmlImports(appDirPath, deploymentInfo, qmlDirs);
483+
bool ok = deployQmlImports(appDirPath, deploymentInfo, qmlDirs, qmlImportPaths);
475484
if (!ok && qmldirArgumentUsed)
476485
return 1; // exit if the user explicitly asked for qml import deployment
477486
// Update deploymentInfo.deployedLibraries - the QML imports

tools/linuxdeployqt/shared.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ void deployQmlImport(const QString &appDirPath, const QSet<QString> &rpaths, con
15221522
}
15231523

15241524
// Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to ./qml.
1525-
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs)
1525+
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths)
15261526
{
15271527
if(!qtDetected){
15281528
LogDebug() << "Skipping QML imports since no Qt detected";
@@ -1531,7 +1531,8 @@ bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo,
15311531

15321532
LogNormal() << "";
15331533
LogNormal() << "Deploying QML imports ";
1534-
LogNormal() << "Application QML file search path(s) is" << qmlDirs;
1534+
LogNormal() << "Application QML file path(s) is" << qmlDirs;
1535+
LogNormal() << "QML module search path(s) is" << qmlImportPaths;
15351536

15361537
// Use qmlimportscanner from QLibraryInfo::BinariesPath
15371538
QString qmlImportScannerPath = QDir::cleanPath(qtToBeBundledInfo.value("QT_INSTALL_BINS")) + "/qmlimportscanner";
@@ -1558,6 +1559,11 @@ bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo,
15581559
argumentList.append(qmlDir);
15591560
}
15601561

1562+
foreach (const QString &importPath, qmlImportPaths) {
1563+
argumentList.append("-importPath");
1564+
argumentList.append(importPath);
1565+
}
1566+
15611567
argumentList.append( "-importPath");
15621568
argumentList.append(qtToBeBundledInfo.value("QT_INSTALL_QML"));
15631569

tools/linuxdeployqt/shared.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ DeploymentInfo deployQtLibraries(QList<LibraryInfo> libraries,const QString &bun
123123
void createQtConf(const QString &appDirPath);
124124
void createQtConfForQtWebEngineProcess(const QString &appDirPath);
125125
void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo);
126-
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs);
126+
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths);
127127
void changeIdentification(const QString &id, const QString &binaryPath);
128128
void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
129129
void runStrip(const QString &binaryPath);

0 commit comments

Comments
 (0)