qt5: add option to build Qt5 statically

Add PACKAGECONFIG that enables static build for qtbase and consequently
to all Qt recipes. This can be enabled with DISTRO_FEATURE 'qt5-static',
which also adds qtdeclarative-native dependency to all recipes that
depend on qtdeclarative as it's required for qmlimportscannertool.

Building examples and tests with static build can take excessive amounts
of time and disk space, so disabling DISTRO_FEATURE 'ptest' and
PACKAGECONFIGs 'examples' from qtbase is advised.

Not all recipes support static builds and those are not fixed here.

Change-Id: Ia0e2a2467cd42d4395ed5292a645fd1d89ad521a
Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
This commit is contained in:
Samuli Piippo
2018-06-18 10:52:40 +03:00
committed by Otavio Salvador
parent a4f88b6b5f
commit 0263af75c0
4 changed files with 30 additions and 1 deletions

View File

@@ -37,6 +37,14 @@ python __anonymous() {
d.setVar("PACKAGE_ARCH", tarch)
}
# if building static Qt5, add qtdeclarative-native dependency to all recipes
# that depend on qtdeclarative as it's required for qmlimportscannertool
python __anonymous() {
if bb.utils.contains('DISTRO_FEATURES', "qt5-static", True, False, d):
if bb.utils.contains('DEPENDS', "qtdeclarative", True, False, d):
d.appendVar("DEPENDS", " qtdeclarative-native")
}
# Many examples come with libraries installed outside of standard libdir,
# suppress QA check complaining
INSANE_SKIP_${PN}-dbg += "libdir"
@@ -48,6 +56,8 @@ PACKAGES =. "${PN}-qmlplugins-dbg ${PN}-tools-dbg ${PN}-plugins-dbg ${PN}-qmldes
ALLOW_EMPTY_${PN} = "1"
ALLOW_EMPTY_${PN}-dbg = "1"
ALLOW_EMPTY_${PN}-plugins = "1"
ALLOW_EMPTY_${PN}-qmlplugins = "1"
RRECOMMENDS_${PN} = " \
${PN}-plugins \
@@ -159,6 +169,18 @@ FILES_${PN}-dbg += " \
"
FILES_${PN}-staticdev += " \
${OE_QMAKE_PATH_LIBS}/*.a \
${OE_QMAKE_PATH_PLUGINS}/*/*.a \
${OE_QMAKE_PATH_PLUGINS}/*/*.prl \
${OE_QMAKE_PATH_PLUGINS}/*/*/*.a \
${OE_QMAKE_PATH_PLUGINS}/*/*/*.prl \
${OE_QMAKE_PATH_QML}/*/*.a \
${OE_QMAKE_PATH_QML}/*/*.prl \
${OE_QMAKE_PATH_QML}/*/*/*.a \
${OE_QMAKE_PATH_QML}/*/*/*.prl \
${OE_QMAKE_PATH_QML}/*/*/*/*.a \
${OE_QMAKE_PATH_QML}/*/*/*/*.prl \
${OE_QMAKE_PATH_QML}/*/*/*/*/*.a \
${OE_QMAKE_PATH_QML}/*/*/*/*/*.prl \
"
FILES_${PN}-examples = " \
${OE_QMAKE_PATH_EXAMPLES}/* \

View File

@@ -70,6 +70,7 @@ PACKAGECONFIG_RELEASE ?= "release"
# PACKAGECONFIG_OPENSSL ?= "openssl"
PACKAGECONFIG_DEFAULT ?= "dbus udev evdev widgets tools libs freetype tests \
${@bb.utils.contains('SELECTED_OPTIMIZATION', '-Os', 'optimize-size ltcg', '', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'qt5-static', 'static', '', d)} \
"
PACKAGECONFIG ?= " \
@@ -84,6 +85,7 @@ PACKAGECONFIG ?= " \
${PACKAGECONFIG_DISTRO} \
"
PACKAGECONFIG[static] = "-static,-shared"
PACKAGECONFIG[release] = "-release,-debug"
PACKAGECONFIG[debug] = ""
PACKAGECONFIG[developer] = "-developer-build"

View File

@@ -14,10 +14,11 @@ LIC_FILES_CHKSUM = " \
DEPENDS += "qtbase"
PACKAGECONFIG ??= "qtxmlpatterns qml-debug qml-network"
PACKAGECONFIG ??= "qtxmlpatterns qml-debug qml-network ${@bb.utils.contains('DISTRO_FEATURES', 'qt5-static', 'static', '', d)}"
PACKAGECONFIG[qtxmlpatterns] = ",,qtxmlpatterns"
PACKAGECONFIG[qml-debug] = "-qml-debug,-no-qml-debug"
PACKAGECONFIG[qml-network] = "-qml-network, -no-qml-network"
PACKAGECONFIG[static] = ",,qtdeclarative-native"
do_configure_prepend() {
# disable qtxmlpatterns test if it isn't enabled by PACKAGECONFIG

View File

@@ -73,6 +73,10 @@ inherit qmake5
inherit gettext
inherit pythonnative
inherit perlnative
inherit distro_features_check
# Static builds of QtWebEngine aren't supported.
CONFLICT_DISTRO_FEATURES = "qt5-static"
# we don't want gettext.bbclass to append --enable-nls
def gettext_oeconf(d):