[vlc-devel] [PATCH] contrib: qt: Add static plugins/qml modules to the static pkg-config
Steve Lhomme
robux4 at ycbcr.xyz
Tue Apr 30 09:56:33 CEST 2019
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.
---
contrib/src/qt/AddStaticLink.sh | 33 ++++++++++++++++++++++++
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, 49 insertions(+), 54 deletions(-)
create mode 100644 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 100644
index 0000000000..b1ae2c6970
--- /dev/null
+++ b/contrib/src/qt/AddStaticLink.sh
@@ -0,0 +1,33 @@
+#! /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"
+ exit 1
+fi
+
+if [ ! -f $PRL_SOURCE ]; then
+ echo "source ${PRL_SOURCE} doesn't exists"
+ exit 1
+fi
+
+echo PRL_SOURCE=$PRL_SOURCE
+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 )
+
+sed -i -e "s#Libs.private: #Libs.private: $LIBS -L\${prefix}/${PLUGIN_PATH} -l${PLUGIN_NAME} #" $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 d9ea10a581..af0c6dca31 100644
--- a/contrib/src/qt/rules.mak
+++ b/contrib/src/qt/rules.mak
@@ -110,27 +110,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..3d6be45a71 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..9d58a16bb3 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..04443adb8a 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..1999a401d8 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.17.1
More information about the vlc-devel
mailing list