[vlc-devel] [PATCH 3.0 33/41] contrib: qt: Add static plugins/qml modules to the static pkg-config

Steve Lhomme robux4 at ycbcr.xyz
Tue Jul 7 15:11:32 CEST 2020


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.

(cherry picked from commit 32c57ceda936d98dd4db6824ef1c53ae46e5e7c1) (edited)

edited:
- removed JPEG support for 3.0

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
---
 contrib/src/qt/AddStaticLink.sh | 37 +++++++++++++++++++++++++++++++++
 contrib/src/qt/FixQtPcFiles.sh  |  7 -------
 contrib/src/qt/rules.mak        | 20 +++++-------------
 contrib/src/qtsvg/rules.mak     |  8 ++-----
 4 files changed, 44 insertions(+), 28 deletions(-)
 create mode 100755 contrib/src/qt/AddStaticLink.sh
 delete mode 100755 contrib/src/qt/FixQtPcFiles.sh

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 2a1f919398..bc84311da9 100644
--- a/contrib/src/qt/rules.mak
+++ b/contrib/src/qt/rules.mak
@@ -91,23 +91,13 @@ ENV_VARS := $(HOSTVARS)
 	# 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
 ifdef HAVE_WIN32
-	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 -luxtheme -ldwmapi -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
+	$(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/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 $@
-- 
2.26.2



More information about the vlc-devel mailing list