diff options
author | Richard Weickelt <richard@weickelt.de> | 2019-07-08 01:49:19 +0200 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2019-10-10 08:05:15 +0000 |
commit | 905ee49fabe197bfe4537c1f10df9d7c48f731c2 (patch) | |
tree | 57acb908ac5449be8ddb84e01e00e52d7ce07755 /src/shared | |
parent | 73ed687cf11cb2d4e7f263ef5754039b96b69aaa (diff) | |
download | qbs-905ee49fabe197bfe4537c1f10df9d7c48f731c2.tar.gz |
Bundle Qt libraries on all platforms
This patch allows us to deploy a self-containing Qbs package on all host
platforms that are supported by the official Qt binary packages.
Although not all (Linux) distributions make use of it, this will
be helpful to
- provide at least some binary convenience packages for the most
important distributions,
- perform building and testing in different environments, for instance
build Qbs in one stage and then run autotests for desktop, iOS,
android in parallel on multiple machines,
- avoid windeployqt which does not work when cross-building
for Windows on a Linux hosts.
Change-Id: I63de4ea2240b37d8bd465cbbf4ddff3d01eeac7e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bundledqt/bundledqt.qbs | 181 |
1 files changed, 135 insertions, 46 deletions
diff --git a/src/shared/bundledqt/bundledqt.qbs b/src/shared/bundledqt/bundledqt.qbs index 6e9b744ab..5995ae4d6 100644 --- a/src/shared/bundledqt/bundledqt.qbs +++ b/src/shared/bundledqt/bundledqt.qbs @@ -1,18 +1,29 @@ import qbs +import qbs.File import qbs.FileInfo Product { Depends { name: "qbsbuildconfig" } - Depends { name: "Qt"; submodules: - ["core", "gui", "network", "printsupport", "widgets", "xml"] } - Depends { name: "Qt.script"; required: false } + Depends { name: "Qt"; submodules: ["core", "gui", "network", "printsupport", "widgets", "xml"] } + Depends { name: "Qt.test"; condition: project.withTests === true } + Depends { name: "Qt.script"; condition: !qbsbuildconfig.useBundledQtScript; required: false } + Depends { + name: "Qt"; + submodules: [ "dbus", "xcb_qpa_lib-private" ]; + required: false + } - property bool deployQt: qbsbuildconfig.enableBundledQt && qbs.targetOS.contains("macos") - && Qt.core.qtConfig.contains("rpath") - property bool deployDebugLibraries: qbs.buildVariant === "debug" - || (qbs.buildVariants && qbs.buildVariants.contains("debug")) + condition: { + if (!qbsbuildconfig.enableBundledQt) + return false; + if (Qt.core.staticBuild) + throw("Cannot bundle static Qt libraries"); + return true; + } readonly property string qtDebugLibrarySuffix: { + if (Qt.core.qtBuildVariant !== "debug") + return ""; if (qbs.targetOS.contains("windows")) return "d"; if (qbs.targetOS.contains("darwin")) @@ -21,7 +32,6 @@ Product { } Group { - condition: deployQt && !Qt.core.staticBuild name: "qt.conf" files: ["qt.conf"] qbs.install: true @@ -29,56 +39,135 @@ Product { } Group { - condition: deployQt name: "Qt libraries" - files: !Qt.core.staticBuild ? Array.prototype.concat.apply( - [], Object.getOwnPropertyNames(Qt).map(function(mod) { - if (mod === "script" && !Qt[mod].present) - return []; - if (!Qt[mod].hasLibrary) - return []; - var fp = Qt[mod].libFilePathRelease; - var fpd = Qt.core.frameworkBuild ? fp + qtDebugLibrarySuffix : Qt[mod].libFilePathDebug; - - var list = [fp]; - if (deployDebugLibraries && qtDebugLibrarySuffix) - list.push(fpd); - - if (Qt.core.frameworkBuild) { - var suffix = ".framework/"; - var frameworkPath = fp.substr(0, fp.lastIndexOf(suffix) + suffix.length - 1); - var versionsPath = frameworkPath + "/Versions"; - var versionPath = versionsPath + "/" + Qt.core.versionMajor; - list.push(frameworkPath + "/Resources"); - list.push(versionPath + "/Resources/Info.plist"); - list.push(versionPath + "/" + FileInfo.fileName(fp)); - if (deployDebugLibraries && qtDebugLibrarySuffix) - list.push(versionPath + "/" + FileInfo.fileName(fpd)); - if (qbsbuildconfig.installApiHeaders) { - list.push(frameworkPath + "/Headers"); - list.push(versionPath + "/Headers/**"); + files: { + function getLibsForQtModule(mod) { + if (mod === "script" && !Qt[mod].present) + return []; + if ((mod !== "core") && !Qt[mod].hasLibrary) + return []; + if (Qt[mod].isStaticLibrary) + return []; + + var list = []; + if (qbs.targetOS.contains("windows")) { + var basename = FileInfo.baseName(Qt[mod].libNameForLinker); + var dir = Qt.core.binPath; + list.push(dir + "/" + basename + ".dll"); + + } else if (qbs.targetOS.contains("linux")) { + var fp = Qt[mod].libFilePath; + var basename = FileInfo.baseName(fp); + var dir = FileInfo.path(fp); + list.push(dir + "/" + basename + ".so"); + list.push(dir + "/" + basename + ".so." + Qt.core.versionMajor); + list.push(dir + "/" + basename + ".so." + Qt.core.versionMajor + "." + Qt.core.versionMinor); + list.push(fp); + + } else if (Qt.core.frameworkBuild) { + var fp = Qt[mod].libFilePathRelease; + var fpd = fp + "_debug"; + + if (qtDebugLibrarySuffix) + list.push(fpd); + + var suffix = ".framework/"; + var frameworkPath = fp.substr(0, fp.lastIndexOf(suffix) + suffix.length - 1); + var versionsPath = frameworkPath + "/Versions"; + var versionPath = versionsPath + "/" + Qt.core.versionMajor; + list.push(frameworkPath + "/Resources"); + list.push(versionPath + "/Resources/Info.plist"); + list.push(versionPath + "/" + FileInfo.fileName(fp)); + if (qtDebugLibrarySuffix) + list.push(versionPath + "/" + FileInfo.fileName(fpd)); + if (qbsbuildconfig.installApiHeaders) { + list.push(frameworkPath + "/Headers"); + list.push(versionPath + "/Headers/**"); + } } + return list; + } + + var qtModules = Object.getOwnPropertyNames(Qt); + var libraries = Array.prototype.concat.apply([], qtModules.map(getLibsForQtModule)); + + // Qt might be bundled with additional libraries + if (qbs.targetOS.contains("linux")) { + var dir = FileInfo.path(Qt.core.libFilePathRelease); + var addons = [ "libicui18n", "libicuuc", "libicudata" ]; + addons.forEach(function(lib) { + var fp = dir + "/" + lib + ".so"; + if (File.exists(fp)) + libraries.push(fp + "*"); + }); } - return list; - })) : [] + return libraries; + } + qbs.install: true qbs.installDir: qbsbuildconfig.libInstallDir - qbs.installSourceBase: Qt.core.libPath + qbs.installSourceBase: qbs.targetOS.contains("windows") ? Qt.core.binPath : Qt.core.libPath } Group { - condition: deployQt + name: "Windows Plugins" + condition: qbs.targetOS.contains("windows") prefix: Qt.core.pluginPath + "/" - name: "QPA plugin" - files: !Qt.core.staticBuild ? Array.prototype.concat.apply([], [""].concat( - deployDebugLibraries && qtDebugLibrarySuffix ? [qtDebugLibrarySuffix] : []).map( - function(suffix) { - return ["platforms/" + cpp.dynamicLibraryPrefix + (Qt.gui.defaultQpaPlugin || "qcocoa") - + suffix + cpp.dynamicLibrarySuffix]; - })) : [] + files: [ + "platforms/qwindows" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix, + "styles/qwindowsvistastyle" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix + ] qbs.install: true qbs.installDir: "plugins" qbs.installSourceBase: prefix } + + Group { + name: "macOS Plugins" + condition: qbs.targetOS.contains("darwin") + prefix: Qt.core.pluginPath + "/" + files: [ + "platforms/libqcocoa" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix, + "styles/libqmacstyle" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix + ] + qbs.install: true + qbs.installDir: "plugins" + qbs.installSourceBase: prefix + } + + Group { + name: "Linux Plugins" + condition: qbs.targetOS.contains("linux") + prefix: Qt.core.pluginPath + "/" + files: [ + "platforms/libqxcb" + cpp.dynamicLibrarySuffix, + "platformthemes/libqgtk3" + cpp.dynamicLibrarySuffix + ] + qbs.install: true + qbs.installDir: "plugins" + qbs.installSourceBase: prefix + } + + Group { + name: "MinGW Runtime DLLs" + condition: qbs.targetOS.contains("windows") && qbs.toolchain.contains("mingw") + + files: { + var libFileGlobs = [ + "*libgcc_s*.dll", + "*libstdc++-6.dll", + "*libwinpthread-1.dll" + ]; + var searchPaths = cpp.compilerLibraryPaths; + return Array.prototype.concat.apply([], searchPaths.map(function(path) { + return libFileGlobs.map(function(glob) { + return path + "/" + glob; + }); + })); + } + + qbs.install: true + qbs.installDir: "bin" + } } |