qt6.qtbase: fix macdeployqt would not find qmlimportscanner

The qmlimportscanner tool is provided by qtdeclarative. Because of the
modularized installation in Nix, it can not be found via the usual
mechanisms.  Also, hard-coding it like we do for Qt5 would also not
work, as it would require making qtbase depend on qtdeclarative.

Here we add an option to provide its location via the environment.
While this means macdeployqt does not work out of the box, it provides
a workaround for users.

Also, we make sure that qmlimportscanner gets passed the right QML
import paths as described in the environment.
This commit is contained in:
Juan Pedro Bolívar Puente 2023-08-09 16:23:18 +02:00
parent a224b6d744
commit a5b92645f1
4 changed files with 103 additions and 0 deletions

View File

@ -48,6 +48,9 @@ let
./patches/0005-qtbase-deal-with-a-font-face-at-index-0-as-Regular-f.patch
./patches/0006-qtbase-qt-cmake-always-use-cmake-from-path.patch
./patches/0007-qtbase-find-qt-tools-in-QTTOOLSPATH.patch
./patches/0008-qtbase-find-qmlimportscanner-in-macdeployqt-via-environment.patch
./patches/0009-qtbase-check-in-the-QML-folder-of-this-library-does-actuall.patch
./patches/0010-qtbase-pass-to-qmlimportscanner-the-QML2_IMPORT_PATH.patch
];
};
env = callPackage ./qt-env.nix { };

View File

@ -0,0 +1,35 @@
From 505391a31aa353b8f1cc5d3feb9861582554d9f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Pedro=20Bol=C3=ADvar=20Puente?= <raskolnikov@gnu.org>
Date: Wed, 9 Aug 2023 16:16:21 +0200
Subject: [PATCH 1/3] Find qmlimportscanner in macdeployqt via environment
The qmlimportscanner tool is provided by qtdeclarative. Because of the
modularized installation in Nix, it can not be found via the usual
mechanisms. Also, hard-coding it like we do for Qt5 would also not
work, as it would require making qtbase depend on qtdeclarative.
Here we add an option to provide its location via the environment.
While this means macdeployqt does not work out of the box, it provides
a workaround for users.
---
src/tools/macdeployqt/shared/shared.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/tools/macdeployqt/shared/shared.cpp b/src/tools/macdeployqt/shared/shared.cpp
index 643fe5390a..b8fcc9c9bd 100644
--- a/src/tools/macdeployqt/shared/shared.cpp
+++ b/src/tools/macdeployqt/shared/shared.cpp
@@ -1270,6 +1270,10 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
if (!QFile::exists(qmlImportScannerPath))
qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
+ // Fallback: Pass qml import scanner via environment variable
+ if (!QFile::exists(qmlImportScannerPath))
+ qmlImportScannerPath = ::qgetenv("NIX_QMLIMPORTSCANNER");
+
// Verify that we found a qmlimportscanner binary
if (!QFile::exists(qmlImportScannerPath)) {
LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
--
2.26.2

View File

@ -0,0 +1,35 @@
From 32df59bea18bebc18d6d308750e88be325522d2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Pedro=20Bol=C3=ADvar=20Puente?= <raskolnikov@gnu.org>
Date: Thu, 10 Aug 2023 14:15:34 +0200
Subject: [PATCH 2/3] Check in the QML folder of this library does actually
exist
In a modularized installation, this folder will be the location where
`qtbase` itself is installed, but `qtbase` does not have any QML
code, and `qmlimportscanner` will complain that it does not exist.
---
src/tools/macdeployqt/shared/shared.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/tools/macdeployqt/shared/shared.cpp b/src/tools/macdeployqt/shared/shared.cpp
index b8fcc9c9bd..676d34d545 100644
--- a/src/tools/macdeployqt/shared/shared.cpp
+++ b/src/tools/macdeployqt/shared/shared.cpp
@@ -1290,9 +1290,12 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
}
for (const QString &importPath : qmlImportPaths)
argumentList << "-importPath" << importPath;
+
QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
- argumentList.append( "-importPath");
- argumentList.append(qmlImportsPath);
+ if (QFile::exists(qmlImportsPath)) {
+ argumentList.append( "-importPath");
+ argumentList.append(qmlImportsPath);
+ }
// run qmlimportscanner
QProcess qmlImportScanner;
--
2.26.2

View File

@ -0,0 +1,30 @@
From 39eb99dcd66f8ffb632fed6308a49896fe5ad2d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Pedro=20Bol=C3=ADvar=20Puente?= <raskolnikov@gnu.org>
Date: Thu, 10 Aug 2023 14:17:03 +0200
Subject: [PATCH 3/3] Pass to qmlimportscanner the QML2_IMPORT_PATH
---
src/tools/macdeployqt/shared/shared.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/tools/macdeployqt/shared/shared.cpp b/src/tools/macdeployqt/shared/shared.cpp
index 676d34d545..7908b07b3c 100644
--- a/src/tools/macdeployqt/shared/shared.cpp
+++ b/src/tools/macdeployqt/shared/shared.cpp
@@ -1297,6 +1297,13 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
argumentList.append(qmlImportsPath);
}
+ // In a modularized installation of qt as we have in Nix, instead, we will
+ // read the paths from the environment, as they are spread in multiple
+ // locations and normally set in the environment like this
+ auto envQmlImportPaths = ::qgetenv("QML2_IMPORT_PATH").split(':');
+ for (const QString &importPath : envQmlImportPaths)
+ argumentList << "-importPath" << importPath;
+
// run qmlimportscanner
QProcess qmlImportScanner;
qmlImportScanner.start(qmlImportScannerPath, argumentList);
--
2.26.2