[vlc-commits] [Git][videolan/vlc][master] qt: direct rcc to use zlib if qt can not decompress zstd

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Dec 13 17:14:52 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
144757e5 by Fatih Uzunoglu at 2024-12-13T16:58:29+00:00
qt: direct rcc to use zlib if qt can not decompress zstd

Starting with Qt 6, RCC uses zstd by default. If Qt is
built without zstd, it does not have the ability to
decompress zstd.

This is mainly a problem when host tools are outsourced.
For example, currently we don't provide zstd to Qt in
the contribs, so it does not support compressing (rcc)
or decompressing (libqtcore) zstd. However, the script
that determines the host tools only check for version
and does not check for feature mismatch (contrib/main.mak).
Not only that, it also prioritizes the system than the
contribs even if tools exist in the contribs.

Because of this reason, host tools are picked from the
system. In my case, my system RCC was built with zstd
support, so it uses zstd compression by default. However,
contrib Qt does not support zstd.

If this occurs with static Qt, it leads to build failure
due to undefined reference. If this occurs with dynamic
Qt, I assume that it would cause runtime error.

Qt's officially supported build systems seem to already
check if Qt supports decompressing zstd and adjust the
rcc invocation (mkspecs/features/resources.prf). In this
patch, I propose doing the same for our unofficial
Autotools and Meson build systems for the Qt module.

- - - - -


3 changed files:

- configure.ac
- modules/gui/qt/Makefile.am
- modules/gui/qt/meson.build


Changes:

=====================================
configure.ac
=====================================
@@ -4009,6 +4009,7 @@ have_qt_declarative_private="no"
 have_qt_gui_private="no"
 have_qt_core_private="no"
 have_qt65="no"
+have_qt_zstd="no"
 have_fxc="no"
 AS_IF([test "${enable_qt}" != "no"], [
   have_qt="yes"
@@ -4137,6 +4138,22 @@ AS_IF([test "${enable_qt}" != "no"], [
         have_qt="no"
       ])
 
+      AC_MSG_CHECKING([if Qt can decompress zstd])
+      VLC_SAVE_FLAGS
+      CPPFLAGS="${CPPFLAGS} ${QT_CFLAGS}"
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[#include <qconfig.h>]],[[
+        #if QT_FEATURE_zstd != 1
+        #error "Qt can not decompress zstd. Resources are going to be compressed using zlib."
+        #endif
+        ]])], [
+         have_qt_zstd="yes"
+         AC_MSG_RESULT([yes])
+        ],[
+         AC_MSG_RESULT([no])
+        ])
+      VLC_RESTORE_FLAGS
+
       AC_MSG_CHECKING([for Qt QTest])
       (${QMAKE} ${srcdir}/modules/gui/qt/qtest.pro -o ${ac_pwd}/modules/gui/qt/qmake-qtest) 2>/dev/null
       ac_status=$?
@@ -4276,6 +4293,7 @@ AM_CONDITIONAL([HAVE_QT_CORE_PRIVATE], [test "${have_qt_core_private}" = "yes"])
 AM_CONDITIONAL([HAVE_FXC], [test "${have_fxc}" = "yes"])
 AM_CONDITIONAL([HAVE_QT67], [test "${QT_VERSION_MAJ:-0}" -gt "6" || (test "${QT_VERSION_MAJ:-0}" = "6" && test "${QT_VERSION_MIN:-0}" -ge "7")])
 AM_CONDITIONAL([HAVE_QT65], [test "${have_qt65}" = "yes"])
+AM_CONDITIONAL([HAVE_QT_ZSTD], [test "${have_qt_zstd}" = "yes"])
 
 dnl
 dnl detect kde4-config patch (used for kde solids).


=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -18,6 +18,13 @@ SUFFIXES += .ui .h .hpp .moc.cpp .qml .js .mjs .moc
 TEST_EXTENSIONS = .qml
 EXTRA_DIST = qt6.pro private-core.pro private-gui.pro private-quick.pro quicktest.pro scripts
 vlc_qt_libs = $(QT_LIBS)
+RCC_EXTRA_PARAMS =
+
+if HAVE_QT_ZSTD
+RCC_EXTRA_PARAMS += -compress-algo=zstd
+else
+RCC_EXTRA_PARAMS += -compress-algo=zlib
+endif
 
 vlc_qt_check_SOURCES = vlc-qt-check.cpp plugins.hpp
 vlc_qt_check_CXXFLAGS = $(AM_CXXFLAGS) $(QT_CFLAGS) -fPIC $(CXXFLAGS_qt)
@@ -1402,7 +1409,7 @@ QSB_PARAMS_VERBOSE__0 = $(QSB_PARAMS_VERBOSE_0)
 
 shaders/shaders.cpp: $(srcdir)/shaders/shaders.qrc $(libqt_plugin_la_SHADER:.frag=.frag.qsb) $(libqt_plugin_la_SHADER:.vert=.vert.qsb)
 	$(AM_V_GEN) cp -f $(filter %.qrc, $^) $(builddir)/shaders/shaders.qrc || true
-	$(AM_V_GEN) $(RCC) --name shaders -o $@ $(builddir)/shaders/$(notdir $(filter %.qrc, $^))
+	$(AM_V_GEN) $(RCC) $(RCC_EXTRA_PARAMS) --name shaders -o $@ $(builddir)/shaders/$(notdir $(filter %.qrc, $^))
 
 libqt_plugin_la_SOURCES += shaders/shaders.qrc $(libqt_plugin_la_SHADER)
 BUILT_SOURCES += shaders/shaders.qrc
@@ -1414,7 +1421,7 @@ lib_qt_plugin_la_QRC += windows.qrc
 
 windows.cpp: $(libqt_plugin_la_RES)
 windows.cpp: windows.qrc
-	$(AM_V_GEN)$(RCC) --name windows -o $@ $<
+	$(AM_V_GEN)$(RCC) $(RCC_EXTRA_PARAMS) --name windows -o $@ $<
 
 nodist_libqt_plugin_la_SOURCES += windows.cpp
 endif
@@ -1505,7 +1512,7 @@ endif
 
 #package qmldir files
 %_qmlassets.cpp: $(builddir)/%/qmldir.qrc
-	$(AM_V_GEN)$(RCC) --name $*_assets -o $@ $<
+	$(AM_V_GEN)$(RCC) $(RCC_EXTRA_PARAMS) --name $*_assets -o $@ $<
 
 
 CLEANFILES += \
@@ -1523,7 +1530,7 @@ libqt_plugin_la_QML_MODULES_QMLDIR = $(libqt_plugin_la_QML_MODULES:%=$(builddir)
 libqt_plugin_la_QML_MODULES_QMLDIR_QRC = $(libqt_plugin_la_QML_MODULES:%=$(builddir)/%/qmldir.qrc)
 
 %_qmlassets.cpp: $(builddir)/%/qmldir.qrc $(builddir)/%/res.qrc $(libqt_plugin_la_ALL_QML)
-	$(AM_V_GEN)$(RCC) --name $*_assets -o $@ $(builddir)/$*/qmldir.qrc $(builddir)/$*/res.qrc
+	$(AM_V_GEN)$(RCC) $(RCC_EXTRA_PARAMS) --name $*_assets -o $@ $(builddir)/$*/qmldir.qrc $(builddir)/$*/res.qrc
 
 nodist_libqt_plugin_la_SOURCES += $(libqt_plugin_la_QML_MODULES:%=%_qmlassets.cpp)
 
@@ -1537,7 +1544,7 @@ EXTRA_DIST += $(libqt_plugin_la_QML)
 
 assets.cpp: $(libqt_plugin_la_RES)
 assets.cpp: assets.qrc
-	$(AM_V_GEN)$(RCC) --name assets -o $@ $<
+	$(AM_V_GEN)$(RCC) $(RCC_EXTRA_PARAMS) --name assets -o $@ $<
 
 
 if HAVE_QT_GTK


=====================================
modules/gui/qt/meson.build
=====================================
@@ -909,6 +909,19 @@ qml_tests = {
 qmllibs = []
 
 if qt6_dep.found()
+    qt_rcc_extra_arguments = []
+    qt_zstd_check = '''
+    #include <qconfig.h>
+    #if QT_FEATURE_zstd != 1
+    #error "Qt can not decompress zstd. Resources are going to be compressed using zlib."
+    #endif
+    '''
+    if cpp.compiles(qt_zstd_check, dependencies: qt6_dep, name: 'Qt supports decompressing zstd')
+        qt_rcc_extra_arguments += '-compress-algo=zstd'
+    else
+        qt_rcc_extra_arguments += '-compress-algo=zlib'
+    endif
+
     prog_python = find_program('python3')
     modules_qrc = []
     foreach module : qml_modules
@@ -946,7 +959,8 @@ if qt6_dep.found()
                 meson.current_build_dir() / module['outdir'] / 'qmldir.qrc',
             ),
             include_directories: qt_include_dir,
-            dependencies: qt6_dep
+            dependencies: qt6_dep,
+            rcc_extra_arguments: qt_rcc_extra_arguments
         )
 
         #FIXME copy every files to the outdir module so they can be used by qt tooling
@@ -960,7 +974,8 @@ if qt6_dep.found()
     qt6pre_qrc = qt6.preprocess(
         qresources: qrc_files,
         include_directories: qt_include_dir,
-        dependencies: qt6_dep)
+        dependencies: qt6_dep,
+        rcc_extra_arguments: qt_rcc_extra_arguments)
 
     qt_sources = files('qt.cpp')
 
@@ -1083,7 +1098,8 @@ if qt6_dep.found()
         moc_headers: moc_headers,
         moc_extra_arguments: qt_extra_flags,
         include_directories: qt_include_dir,
-        dependencies: qt6_dep)
+        dependencies: qt6_dep,
+        rcc_extra_arguments: qt_rcc_extra_arguments)
 
     # TODO support qmlcachegen
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/144757e5f13753fec538893505bb03aaae72b276

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/144757e5f13753fec538893505bb03aaae72b276
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list