Commit 631bf20c authored by Morten Johan Sørvig's avatar Morten Johan Sørvig
Browse files

Improve how macdeployqt calls qmlimportscanner


Construct the argument list using "-rootPath", which
correctly handles multiple qmlDirs. Don't merge
qmlimportscanner stdout and stderr. Log stderr as
macdeployqt warnings.

Change-Id: I6f82f90f4e242c9aa246ab26ba3b9af88e1fd123
Reviewed-by: default avatarGabriel de Dietrich <gabriel.dedietrich@digia.com>
Showing with 27 additions and 5 deletions
...@@ -673,6 +673,10 @@ void deployQmlImport(const QString &appBundlePath, const QString &importSourcePa ...@@ -673,6 +673,10 @@ void deployQmlImport(const QString &appBundlePath, const QString &importSourcePa
// Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to Contents/Resources/qml. // Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to Contents/Resources/qml.
void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs) void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs)
{ {
LogNormal() << "";
LogNormal() << "Deploying QML imports ";
LogNormal() << "Application QML file search path(s) is" << qmlDirs;
// verify that qmlimportscanner is in BinariesPath // verify that qmlimportscanner is in BinariesPath
QString qmlImportScannerPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner"); QString qmlImportScannerPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner");
if (!QFile(qmlImportScannerPath).exists()) { if (!QFile(qmlImportScannerPath).exists()) {
...@@ -681,20 +685,37 @@ void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs) ...@@ -681,20 +685,37 @@ void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs)
return; return;
} }
// run qmlimportscanner // build argument list for qmlimportsanner: "-rootPath foo/ -rootPath bar/ -importPath path/to/qt/qml"
// ("rootPath" points to a directory containing app qml, "importPath" is where the Qt imports are installed)
QStringList argumentList;
foreach (const QString &qmlDir, qmlDirs) {
argumentList.append("-rootPath");
argumentList.append(qmlDir);
}
QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
argumentList.append( "-importPath");
argumentList.append(qmlImportsPath);
// run qmlimportscanner
QProcess qmlImportScanner; QProcess qmlImportScanner;
qmlImportScanner.setProcessChannelMode(QProcess::MergedChannels); qmlImportScanner.start(qmlImportScannerPath, argumentList);
qmlImportScanner.start(qmlImportScannerPath, QStringList() << qmlDirs << "-importPath" << qmlImportsPath);
if (!qmlImportScanner.waitForStarted()) { if (!qmlImportScanner.waitForStarted()) {
LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString(); LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString();
return; return;
} }
qmlImportScanner.waitForFinished(); qmlImportScanner.waitForFinished();
QByteArray json = qmlImportScanner.readAll();
// log qmlimportscanner errors
qmlImportScanner.setReadChannel(QProcess::StandardError);
QByteArray errors = qmlImportScanner.readAll();
if (!errors.isEmpty()) {
LogWarning() << "QML file parse error (deployment will continue):";
LogWarning() << errors;
}
// parse qmlimportscanner json // parse qmlimportscanner json
qmlImportScanner.setReadChannel(QProcess::StandardOutput);
QByteArray json = qmlImportScanner.readAll();
QJsonDocument doc = QJsonDocument::fromJson(json); QJsonDocument doc = QJsonDocument::fromJson(json);
if (!doc.isArray()) { if (!doc.isArray()) {
LogError() << "qmlimportscanner output error. Expected json array, got:"; LogError() << "qmlimportscanner output error. Expected json array, got:";
...@@ -739,6 +760,7 @@ void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs) ...@@ -739,6 +760,7 @@ void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs)
name.append(version); name.append(version);
deployQmlImport(appBundlePath, path, name); deployQmlImport(appBundlePath, path, name);
LogNormal() << "";
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment