Skip to content

Commit 5ade129

Browse files
authored
Merge pull request #85 from mnesarco/master
Added Qt6 support
2 parents 222c614 + 271d4cc commit 5ade129

File tree

4 files changed

+159
-37
lines changed

4 files changed

+159
-37
lines changed

src/deployers/PluginsDeployerFactory.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ PluginsDeployerFactory::PluginsDeployerFactory(AppDir& appDir,
2424
bf::path qtLibexecsPath,
2525
bf::path qtInstallQmlPath,
2626
bf::path qtTranslationsPath,
27-
bf::path qtDataPath) : appDir(appDir),
27+
bf::path qtDataPath,
28+
int qtMajorVersion) : appDir(appDir),
2829
qtPluginsPath(std::move(qtPluginsPath)),
2930
qtLibexecsPath(std::move(qtLibexecsPath)),
3031
qtInstallQmlPath(std::move(qtInstallQmlPath)),
3132
qtTranslationsPath(std::move(qtTranslationsPath)),
32-
qtDataPath(std::move(qtDataPath)) {}
33+
qtDataPath(std::move(qtDataPath)),
34+
qtMajorVersion(qtMajorVersion) {}
3335

3436
std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeployers(const std::string& moduleName) {
3537
if (moduleName == "gui") {
@@ -40,7 +42,7 @@ std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeploye
4042
return {getInstance<XcbglIntegrationPluginsDeployer>(moduleName)};
4143
}
4244

43-
if (moduleName == "network") {
45+
if (moduleName == "network" && qtMajorVersion < 6) {
4446
return {getInstance<BearerPluginsDeployer>(moduleName)};
4547
}
4648

src/deployers/PluginsDeployerFactory.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace linuxdeploy {
2323
const boost::filesystem::path qtInstallQmlPath;
2424
const boost::filesystem::path qtTranslationsPath;
2525
const boost::filesystem::path qtDataPath;
26+
const int qtMajorVersion;
2627

2728
template<typename T>
2829
std::shared_ptr<PluginsDeployer> getInstance(const std::string& moduleName) {
@@ -45,7 +46,8 @@ namespace linuxdeploy {
4546
boost::filesystem::path qtLibexecsPath,
4647
boost::filesystem::path qtInstallQmlPath,
4748
boost::filesystem::path qtTranslationsPath,
48-
boost::filesystem::path qtDataPath);
49+
boost::filesystem::path qtDataPath,
50+
int qtMajorVersion);
4951

5052
std::vector<std::shared_ptr<PluginsDeployer>> getDeployers(const std::string& moduleName);
5153
};

src/main.cpp

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,53 @@ int main(const int argc, const char *const *const argv) {
7070
return 1;
7171
}
7272

73+
auto qmakePath = findQmake();
74+
75+
if (qmakePath.empty()) {
76+
ldLog() << LD_ERROR << "Could not find qmake, please install or provide path using $QMAKE" << std::endl;
77+
return 1;
78+
}
79+
80+
if (!bf::exists(qmakePath)) {
81+
ldLog() << LD_ERROR << "No such file or directory:" << qmakePath << std::endl;
82+
return 1;
83+
}
84+
85+
ldLog() << "Using qmake:" << qmakePath << std::endl;
86+
87+
auto qmakeVars = queryQmake(qmakePath);
88+
89+
if (qmakeVars.empty()) {
90+
ldLog() << LD_ERROR << "Failed to query Qt paths using qmake -query" << std::endl;
91+
return 1;
92+
}
93+
94+
const bf::path qtPluginsPath = qmakeVars["QT_INSTALL_PLUGINS"];
95+
const bf::path qtLibexecsPath = qmakeVars["QT_INSTALL_LIBEXECS"];
96+
const bf::path qtDataPath = qmakeVars["QT_INSTALL_DATA"];
97+
const bf::path qtTranslationsPath = qmakeVars["QT_INSTALL_TRANSLATIONS"];
98+
const bf::path qtBinsPath = qmakeVars["QT_INSTALL_BINS"];
99+
const bf::path qtLibsPath = qmakeVars["QT_INSTALL_LIBS"];
100+
const bf::path qtInstallQmlPath = qmakeVars["QT_INSTALL_QML"];
101+
const std::string qtVersion = qmakeVars["QT_VERSION"];
102+
103+
if (qtVersion.empty()) {
104+
ldLog() << LD_ERROR << "Failed to query QT_VERSION using qmake -query" << std::endl;
105+
return 1;
106+
}
107+
108+
int qtMajorVersion = std::stoi(qtVersion, nullptr, 10);
109+
if (qtMajorVersion < 5) {
110+
ldLog() << std::endl << LD_WARNING << "Minimum Qt version supported is 5" << std::endl;
111+
qtMajorVersion = 5;
112+
}
113+
else if (qtMajorVersion > 6) {
114+
ldLog() << std::endl << LD_WARNING << "Maximum Qt version supported is 6" << std::endl;
115+
qtMajorVersion = 6;
116+
}
117+
118+
ldLog() << std::endl << "Using Qt version: " << qtVersion << " (" << qtMajorVersion << ")" << std::endl;
119+
73120
appdir::AppDir appDir(appDirPath.Get());
74121

75122
// allow disabling copyright files deployment via environment variable
@@ -125,7 +172,9 @@ int main(const int argc, const char *const *const argv) {
125172
return false;
126173
};
127174

128-
std::copy_if(QtModules.begin(), QtModules.end(), std::back_inserter(foundQtModules),
175+
const std::vector<QtModule>& qtModules = getQtModules(qtMajorVersion);
176+
177+
std::copy_if(qtModules.begin(), qtModules.end(), std::back_inserter(foundQtModules),
129178
[&matchesQtModule, &libraryNames](const QtModule &module) {
130179
return std::find_if(libraryNames.begin(), libraryNames.end(),
131180
[&matchesQtModule, &module](const std::string &libraryName) {
@@ -139,7 +188,7 @@ int main(const int argc, const char *const *const argv) {
139188
extraPluginsFromEnv = linuxdeploy::util::split(std::string(extraPluginsFromEnvData), ';');
140189

141190
for (const auto& pluginsList : {static_cast<std::vector<std::string>>(extraPlugins.Get()), extraPluginsFromEnv}) {
142-
std::copy_if(QtModules.begin(), QtModules.end(), std::back_inserter(extraQtModules),
191+
std::copy_if(qtModules.begin(), qtModules.end(), std::back_inserter(extraQtModules),
143192
[&matchesQtModule, &libraryNames, &pluginsList](const QtModule &module) {
144193
return std::find_if(pluginsList.begin(), pluginsList.end(),
145194
[&matchesQtModule, &module](const std::string &libraryName) {
@@ -170,35 +219,6 @@ int main(const int argc, const char *const *const argv) {
170219
return 1;
171220
}
172221

173-
auto qmakePath = findQmake();
174-
175-
if (qmakePath.empty()) {
176-
ldLog() << LD_ERROR << "Could not find qmake, please install or provide path using $QMAKE" << std::endl;
177-
return 1;
178-
}
179-
180-
if (!bf::exists(qmakePath)) {
181-
ldLog() << LD_ERROR << "No such file or directory:" << qmakePath << std::endl;
182-
return 1;
183-
}
184-
185-
ldLog() << "Using qmake:" << qmakePath << std::endl;
186-
187-
auto qmakeVars = queryQmake(qmakePath);
188-
189-
if (qmakeVars.empty()) {
190-
ldLog() << LD_ERROR << "Failed to query Qt paths using qmake -query" << std::endl;
191-
return 1;
192-
}
193-
194-
const bf::path qtPluginsPath = qmakeVars["QT_INSTALL_PLUGINS"];
195-
const bf::path qtLibexecsPath = qmakeVars["QT_INSTALL_LIBEXECS"];
196-
const bf::path qtDataPath = qmakeVars["QT_INSTALL_DATA"];
197-
const bf::path qtTranslationsPath = qmakeVars["QT_INSTALL_TRANSLATIONS"];
198-
const bf::path qtBinsPath = qmakeVars["QT_INSTALL_BINS"];
199-
const bf::path qtLibsPath = qmakeVars["QT_INSTALL_LIBS"];
200-
const bf::path qtInstallQmlPath = qmakeVars["QT_INSTALL_QML"];
201-
202222
ldLog() << std::endl;
203223
ldLog() << "QT_INSTALL_LIBS:" << qtLibsPath << std::endl;
204224
std::ostringstream newLibraryPath;
@@ -223,7 +243,8 @@ int main(const int argc, const char *const *const argv) {
223243
qtLibexecsPath,
224244
qtInstallQmlPath,
225245
qtTranslationsPath,
226-
qtDataPath
246+
qtDataPath,
247+
qtMajorVersion
227248
);
228249

229250
for (const auto& module : qtModulesToDeploy) {

src/qt-modules.h

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string>
33
#include <tuple>
44
#include <vector>
5+
#include <stdexcept>
56

67
#pragma once
78

@@ -17,7 +18,7 @@ class QtModule {
1718
};
1819

1920
// TODO: the list of translation file prefixes is probably incomplete
20-
static const std::vector<QtModule> QtModules = {
21+
static const std::vector<QtModule> Qt5Modules = {
2122
{"3danimation", "libQt53DAnimation", ""},
2223
{"3dcore", "libQt53DCore", ""},
2324
{"3dextras", "libQt53DExtras", ""},
@@ -80,3 +81,99 @@ static const std::vector<QtModule> QtModules = {
8081
{"xmlpatterns", "libQt5XmlPatterns", "qtxmlpatterns"},
8182
{"xml", "libQt5Xml", "qtbase"},
8283
};
84+
85+
static const std::vector<QtModule> Qt6Modules = {
86+
{"concurrent", "libQt6Concurrent", "qtbase"},
87+
{"core5compat", "libQt6Core5Compat", "qtbase"},
88+
{"core", "libQt6Core", "qtbase"},
89+
{"dbus", "libQt6DBus", ""},
90+
{"designercomponents", "libQt6DesignerComponents", ""},
91+
{"designer", "libQt6Designer", ""},
92+
{"eglfsdeviceintegration", "libQt6EglFSDeviceIntegration", ""},
93+
{"eglfskmssupport", "libQt6EglFsKmsSupport", ""},
94+
{"gui", "libQt6Gui", "qtbase"},
95+
{"help", "libQt6Help", "qt_help"},
96+
{"network", "libQt6Network", "qtbase"},
97+
{"opengl", "libQt6OpenGL", ""},
98+
{"openglwidgets", "libQt6OpenGLWidgets", ""},
99+
{"printsupport", "libQt6PrintSupport", ""},
100+
{"qmlmodels", "libQt6QmlModels", ""},
101+
{"qml", "libQt6Qml", "qtdeclarative"},
102+
{"qmlworkerscript", "libQt6QmlWorkerScript", ""},
103+
{"quick3dassetimport", "libQt6Quick3DAssetImport", ""},
104+
{"quick3druntimerender", "libQt6Quick3DRuntimeRender", ""},
105+
{"quick3d", "libQt6Quick3D", ""},
106+
{"quick3dutils", "libQt6Quick3DUtils", ""},
107+
{"quickcontrols2impl", "libQt6QuickControls2Impl", ""},
108+
{"quickcontrols2", "libQt6QuickControls2", ""},
109+
{"quickparticles", "libQt6QuickParticles", ""},
110+
{"quickshapes", "libQt6QuickShapes", ""},
111+
{"quick", "libQt6Quick", "qtdeclarative"},
112+
{"quicktemplates2", "libQt6QuickTemplates2", ""},
113+
{"quicktest", "libQt6QuickTest", ""},
114+
{"quickwidgets", "libQt6QuickWidgets", ""},
115+
{"shadertools", "libQt6ShaderTools", ""},
116+
{"sql", "libQt6Sql", "qtbase"},
117+
{"svg", "libQt6Svg", ""},
118+
{"svgwidgets", "libQt6SvgWidgets", ""},
119+
{"test", "libQt6Test", "qtbase"},
120+
{"uitools", "libQt6UiTools", ""},
121+
{"waylandclient", "libQt6WaylandClient", ""},
122+
{"waylandcompositor", "libQt6WaylandCompositor", ""},
123+
{"widgets", "libQt6Widgets", "qtbase"},
124+
{"xcbqpa", "libQt6XcbQpa", ""},
125+
{"xml", "libQt6Xml", "qtbase"},
126+
127+
/* Not Included in Qt6.0.0, maybe some of them will be added back in 6.1, 6.2
128+
129+
{"3danimation", "libQt63DAnimation", ""},
130+
{"3dcore", "libQt63DCore", ""},
131+
{"3dextras", "libQt63DExtras", ""},
132+
{"3dinput", "libQt63DInput", ""},
133+
{"3dlogic", "libQt63DLogic", ""},
134+
{"3drender", "libQt63DRender", ""},
135+
{"3dquickanimation", "libQt63DQuickAnimation", ""},
136+
{"3dquickextras", "libQt63DQuickExtras", ""},
137+
{"3dquickinput", "libQt63DQuickInput", ""},
138+
{"3dquickrender", "libQt63DQuickRender", ""},
139+
{"3dquickscene2d", "libQt63DQuickScene2D", ""},
140+
{"3dquick", "libQt63DQuick", ""},
141+
{"bluetooth", "libQt6Bluetooth", ""},
142+
{"clucene", "libQt6CLucene", "qt_help"},
143+
{"declarative", "libQt6Declarative", "qtquick1"},
144+
{"gamepad", "libQt6Gamepad", ""},
145+
{"location", "libQt6Location", ""},
146+
{"multimediagsttools", "libQt6MultimediaGstTools", "qtmultimedia"},
147+
{"multimediaquick", "libQt6MultimediaQuick", "qtmultimedia"},
148+
{"multimedia", "libQt6Multimedia", "qtmultimedia"},
149+
{"multimediawidgets", "libQt6MultimediaWidgets", "qtmultimedia"},
150+
{"nfc", "libQt6Nfc", ""},
151+
{"positioning", "libQt6Positioning", ""},
152+
{"remoteobjects", "libQt6RemoteObjects", ""},
153+
{"script", "libQt6Script", "qtscript"},
154+
{"scripttools", "libQt6ScriptTools", "qtscript"},
155+
{"scxml", "libQt6Scxml", ""},
156+
{"sensors", "libQt6Sensors", ""},
157+
{"serialbus", "libQt6SerialBus", ""},
158+
{"serialport", "libQt6SerialPort", "qtserialport"},
159+
{"texttospeech", "libQt6TextToSpeech", ""},
160+
{"webchannel", "libQt6WebChannel", ""},
161+
{"webenginecore", "libQt6WebEngineCore", ""},
162+
{"webengine", "libQt6WebEngine", "qtwebengine"},
163+
{"webenginewidgets", "libQt6WebEngineWidgets", ""},
164+
{"websockets", "libQt6WebSockets", "qtwebsockets"},
165+
{"x11extras", "libQt6X11Extras", ""},
166+
{"xmlpatterns", "libQt6XmlPatterns", "qtxmlpatterns"},
167+
*/
168+
169+
};
170+
171+
inline const std::vector<QtModule>& getQtModules(const int version) {
172+
if (version == 5) {
173+
return Qt5Modules;
174+
}
175+
else if (version == 6) {
176+
return Qt6Modules;
177+
}
178+
throw std::runtime_error("Unknown Qt version: " + std::to_string(version));
179+
}

0 commit comments

Comments
 (0)