[vlc-commits] contrib: qt: Add static plugins/qml modules to the static pkg-config

Steve Lhomme git at videolan.org
Tue May 7 12:01:11 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Apr 29 16:03:54 2019 +0200| [32c57ceda936d98dd4db6824ef1c53ae46e5e7c1] | committer: Steve Lhomme

contrib: qt: Add static plugins/qml modules to the static pkg-config

Get the library/pathes from the installed PRL files in PREFIX/plugins or
PREFIX/qml and add it to Libs.Private in the .pc files. So the libraries are
kept in those folders rather than copied in the libs directory.

We get exactly the libs and order that qmake would use when linking.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=32c57ceda936d98dd4db6824ef1c53ae46e5e7c1
---

 contrib/src/qt/AddStaticLink.sh          | 37 ++++++++++++++++++++++++++++++++
 contrib/src/qt/FixQtPcFiles.sh           |  7 ------
 contrib/src/qt/rules.mak                 | 25 ++++++---------------
 contrib/src/qtdeclarative/rules.mak      | 14 ++++--------
 contrib/src/qtgraphicaleffects/rules.mak |  7 ++----
 contrib/src/qtquickcontrols2/rules.mak   |  9 ++------
 contrib/src/qtsvg/rules.mak              |  8 ++-----
 7 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/contrib/src/qt/AddStaticLink.sh b/contrib/src/qt/AddStaticLink.sh
new file mode 100755
index 0000000000..ec6be88771
--- /dev/null
+++ b/contrib/src/qt/AddStaticLink.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+
+# Add a Qt plugin  in the static pkg-config configuration of a Qt module
+# By default plugins are found in $PREFIX/plugins but are not seen by pkg-config.
+# This is also done for qml plugins which are found in $PREFIX/qml.
+#
+# This could also be done in configure.ac to detect what plugins are available and where to add them
+
+PREFIX=$(realpath "$1")
+PLUGIN_PATH="$3"
+PLUGIN_NAME="$4"
+
+PC_DEST="${PREFIX}/lib/pkgconfig/${2}.pc"
+PRL_SOURCE=${PREFIX}/${PLUGIN_PATH}/${PLUGIN_NAME}.prl
+
+if [ ! -f $PC_DEST ]; then
+    echo "destination ${PC_DEST} doesn't exists" >&2
+    exit 1
+fi
+
+if [ ! -f $PRL_SOURCE ]; then
+    echo "source ${PRL_SOURCE} doesn't exists" >&2
+    exit 1
+fi
+
+# Get the links flags necessary to use the plugin from the installed PRL file of the plugin
+# replace hardcoded pathes by {libdir}
+LIBS=$(sed -e "/QMAKE_PRL_LIBS/ { \
+             s/QMAKE_PRL_LIBS =//; \
+             s@$PREFIX/lib@\${libdir}@g; \
+             s@\$\$\[QT_INSTALL_LIBS\]@\${libdir}@g; p \
+         }; d"  $PRL_SOURCE )
+
+# prepend the plugin that uses the module
+sed -i -e "s# -l${2}# -l${PLUGIN_NAME} -l${2}#" $PC_DEST
+# add the plugin static dependencies to the ones of the module
+sed -i -e "s#Libs.private: #Libs.private: $LIBS -L\${prefix}/${PLUGIN_PATH} #" $PC_DEST
diff --git a/contrib/src/qt/FixQtPcFiles.sh b/contrib/src/qt/FixQtPcFiles.sh
deleted file mode 100755
index 054f7f1428..0000000000
--- a/contrib/src/qt/FixQtPcFiles.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /bin/sh
-
-# Use the Libs.private from the prl files that don't have debug symbols and use a proper lib order
-LIBS=$(sed -e '/QMAKE_PRL_LIBS/ { s/QMAKE_PRL_LIBS =//; s/\$\$\[QT_INSTALL_LIBS\]/${libdir}/g; p }; d'  $1 )
-sed -i \
-	-e "s#Libs.private:.*#Libs.private: $LIBS#" \
-	-e "/Libs:/ { s/d / / }" $2
diff --git a/contrib/src/qt/rules.mak b/contrib/src/qt/rules.mak
index 118b31bf25..03327edc19 100644
--- a/contrib/src/qt/rules.mak
+++ b/contrib/src/qt/rules.mak
@@ -108,27 +108,14 @@ ENV_VARS := $(HOSTVARS) DXSDK_DIR=$(PREFIX)/bin
 	# Install tools
 	cd $< && $(MAKE) -C src sub-moc-install_subtargets sub-rcc-install_subtargets sub-uic-install_subtargets sub-qlalr-install_subtargets
 	# Install plugins
-	cd $< && $(MAKE) -C src/plugins sub-platforms-install_subtargets
+	cd $< && $(MAKE) -C src -C plugins sub-imageformats-install_subtargets sub-platforms-install_subtargets sub-styles-install_subtargets
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Gui plugins/imageformats qjpeg
 ifdef HAVE_WIN32
-	cd $< && $(MAKE) -C src/plugins sub-imageformats-install_subtargets
-	mv $(PREFIX)/plugins/imageformats/libqjpeg.a $(PREFIX)/lib/
-	mv $(PREFIX)/plugins/platforms/libqwindows.a $(PREFIX)/lib/ && rm -rf $(PREFIX)/plugins
+	# Add the private include to our project (similar to using "gui-private" in a qmake project)
+	sed -i.orig -e 's#-I$${includedir}/QtGui#-I$${includedir}/QtGui -I$${includedir}/QtGui/$(QT_VERSION)/QtGui#' $(PREFIX)/lib/pkgconfig/Qt5Gui.pc
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Gui plugins/platforms qwindows
 	# Vista styling
-	cd $< && $(MAKE) -C src -C plugins sub-styles-install_subtargets
-	mv $(PREFIX)/plugins/styles/libqwindowsvistastyle.a $(PREFIX)/lib/ && rm -rf $(PREFIX)/plugins
-	# Move includes to match what VLC expects
-	mkdir -p $(PREFIX)/include/QtGui/qpa
-	cp $(PREFIX)/include/QtGui/$(QT_VERSION)/QtGui/qpa/qplatformnativeinterface.h $(PREFIX)/include/QtGui/qpa
-	# Clean Qt mess
-	rm -rf $(PREFIX)/lib/libQt5Bootstrap* $</lib/libQt5Bootstrap*
-	# Fix .pc files
-	for i in Qt5Core Qt5Gui Qt5Widgets Qt5Test Qt5Network ; do $(SRC)/qt/FixQtPcFiles.sh $(PREFIX)/lib/$$i.prl $(PREFIX)/lib/pkgconfig/$$i.pc; done
-	# Fix Qt5Gui.pc file to include qwindows (QWindowsIntegrationPlugin) and platform support libraries
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig -e 's/ -lQt5Gui/ -lqwindows -lqjpeg -luxtheme -ldwmapi -lwtsapi32 -lQt5ThemeSupport -lQt5FontDatabaseSupport -lQt5EventDispatcherSupport -lQt5WindowsUIAutomationSupport -lqtfreetype -lQt5Gui/g' Qt5Gui.pc
-	# Fix Qt5Widget.pc file to include qwindowsvistastyle before Qt5Widget, as it depends on it
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig -e 's/ -lQt5Widget/ -lqwindowsvistastyle -lQt5Widget/' Qt5Widgets.pc
-	# Use ANGLE OpenGL provided by Qt
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig -e 's/-llibGLESv2/-llibGLESv2 -ld3d9 -ltranslator -lpreprocessor/g' Qt5Gui.pc
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Widgets plugins/styles qwindowsvistastyle
 endif
 	# Install a qmake with correct paths set
 	cd $< && $(MAKE) sub-qmake-qmake-aux-pro-install_subtargets install_mkspecs
diff --git a/contrib/src/qtdeclarative/rules.mak b/contrib/src/qtdeclarative/rules.mak
index 7829002b4f..40909479da 100644
--- a/contrib/src/qtdeclarative/rules.mak
+++ b/contrib/src/qtdeclarative/rules.mak
@@ -36,15 +36,9 @@ qtdeclarative: qtdeclarative-everywhere-src-$(QTDECLARATIVE_VERSION).tar.xz .sum
 	# the particle module to be built
 	cd $< && $(MAKE) -C src sub-particles-make_first-ordered
 	cd $< && $(MAKE) -C src sub-qmltest-install_subtargets sub-quick-install_subtargets sub-qml-install_subtargets sub-quickwidgets-install_subtargets sub-imports-install_subtargets
-	cp $(PREFIX)/qml/QtQuick.2/libqtquick2plugin.a $(PREFIX)/lib/
-	cd $(PREFIX)/qml/QtQuick/ && cp Layouts/libqquicklayoutsplugin.a Window.2/libwindowplugin.a $(PREFIX)/lib/
-	cp $(PREFIX)/qml/QtQml/Models.2/libmodelsplugin.a $(PREFIX)/lib/
-	rm -rf $(PREFIX)/qml
-	for i in Qt5Quick Qt5Qml Qt5QuickWidgets; do \
-		$(SRC)/qt/FixQtPcFiles.sh $(PREFIX)/lib/$$i.prl $(PREFIX)/lib/pkgconfig/$$i.pc; \
-	done
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig -e 's/ -lQt5Quick/ -lqtquick2plugin -lqquicklayoutsplugin -lwindowplugin -lQt5Quick/' Qt5Quick.pc
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig -e 's/ -lQt5Qml/ -lmodelsplugin -lQt5Qml/' Qt5Qml.pc
-
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Quick qml/QtQuick.2 qtquick2plugin
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Quick qml/QtQuick/Layouts qquicklayoutsplugin
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Quick qml/QtQuick/Window.2 windowplugin
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Qml qml/QtQml/Models.2 modelsplugin
 
 	touch $@
diff --git a/contrib/src/qtgraphicaleffects/rules.mak b/contrib/src/qtgraphicaleffects/rules.mak
index 6e9e9bf31c..043d28670b 100644
--- a/contrib/src/qtgraphicaleffects/rules.mak
+++ b/contrib/src/qtgraphicaleffects/rules.mak
@@ -28,9 +28,6 @@ qtgraphicaleffects: qtgraphicaleffects-everywhere-src-$(QTGE_VERSION).tar.xz .su
 	# Make && Install libraries
 	cd $< && $(MAKE)
 	cd $< && $(MAKE) -C src sub-effects-install_subtargets
-	cd $(PREFIX)/qml/QtGraphicalEffects/ && cp libqtgraphicaleffectsplugin.a private/libqtgraphicaleffectsprivate.a $(PREFIX)/lib/
-	rm -rf $(PREFIX)/qml
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig \
-		-e 's/ -lQt5QuickWidgets/ -lqtgraphicaleffectsplugin -lqtgraphicaleffectsprivate -lQt5QuickWidgets/' \
-		Qt5QuickWidgets.pc
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5QuickWidgets qml/QtGraphicalEffects qtgraphicaleffectsplugin
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5QuickWidgets qml/QtGraphicalEffects/private qtgraphicaleffectsprivate
 	touch $@
diff --git a/contrib/src/qtquickcontrols2/rules.mak b/contrib/src/qtquickcontrols2/rules.mak
index da34d3c9eb..e92fec4a0e 100644
--- a/contrib/src/qtquickcontrols2/rules.mak
+++ b/contrib/src/qtquickcontrols2/rules.mak
@@ -29,11 +29,6 @@ qtquickcontrols2: qtquickcontrols2-everywhere-src-$(QTQC2_VERSION).tar.xz .sum-q
 	# Make && Install libraries
 	cd $< && $(MAKE)
 	cd $< && $(MAKE) -C src sub-quickcontrols2-install_subtargets sub-imports-install_subtargets
-	cp $(PREFIX)/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a $(PREFIX)/lib/
-	cp $(PREFIX)/qml/QtQuick/Templates.2/libqtquicktemplates2plugin.a $(PREFIX)/lib/
-	rm -rf $(PREFIX)/qml
-	$(SRC)/qt/FixQtPcFiles.sh $(PREFIX)/lib/Qt5QuickControls2.prl $(PREFIX)/lib/pkgconfig/Qt5QuickControls2.pc
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig \
-		-e 's/ -lQt5QuickControls2/ -lqtquicktemplates2plugin  -lQt5QuickTemplates2 -lqtquickcontrols2plugin -lQt5QuickControls2/' \
-		Qt5QuickControls2.pc
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5QuickControls2 qml/QtQuick/Controls.2 qtquickcontrols2plugin
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5QuickControls2 qml/QtQuick/Templates.2 qtquicktemplates2plugin
 	touch $@
diff --git a/contrib/src/qtsvg/rules.mak b/contrib/src/qtsvg/rules.mak
index 84e03f2519..1c94ed6e70 100644
--- a/contrib/src/qtsvg/rules.mak
+++ b/contrib/src/qtsvg/rules.mak
@@ -29,10 +29,6 @@ qtsvg: qtsvg-everywhere-src-$(QTSVG_VERSION).tar.xz .sum-qtsvg
 	# Make && Install libraries
 	cd $< && $(MAKE)
 	cd $< && $(MAKE) -C src sub-plugins-install_subtargets sub-svg-install_subtargets
-	mv $(PREFIX)/plugins/iconengines/libqsvgicon.a $(PREFIX)/lib/
-	mv $(PREFIX)/plugins/imageformats/libqsvg.a $(PREFIX)/lib/
-	$(SRC)/qt/FixQtPcFiles.sh $(PREFIX)/lib/Qt5Svg.prl $(PREFIX)/lib/pkgconfig/Qt5Svg.pc
-	cd $(PREFIX)/lib/pkgconfig; sed -i.orig \
-		-e '/Libs:/  s/-lQt5Svg/-lqsvg -lqsvgicon -lQt5Svg/ ' \
-		Qt5Svg.pc
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Svg plugins/iconengines qsvgicon
+	$(SRC)/qt/AddStaticLink.sh "$(PREFIX)" Qt5Svg plugins/imageformats qsvg
 	touch $@



More information about the vlc-commits mailing list