[vlc-commits] [Git][videolan/vlc][master] 4 commits: contrib: add commands to build CMake native programs

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Feb 17 14:37:36 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
71bce22d by Steve Lhomme at 2024-02-17T13:57:42+00:00
contrib: add commands to build CMake native programs

It's using a separate build folder, so the same source tree can be used to build both, in parallel.

- - - - -
a93e6dc7 by Steve Lhomme at 2024-02-17T13:57:42+00:00
contrib: protobuf: use CMake commands to build native programs

- - - - -
262eeece by Steve Lhomme at 2024-02-17T13:57:42+00:00
contrib: protobuf: build using CMake

Just like protoc.

- - - - -
4e47bd35 by Steve Lhomme at 2024-02-17T13:57:42+00:00
contrib: update protobuf/protoc to 3.21.1

- - - - -


5 changed files:

- contrib/src/main.mak
- + contrib/src/protobuf/0001-Fix-9947-make-the-ABI-identical-between-debug-and-no.patch
- contrib/src/protobuf/SHA512SUMS
- − contrib/src/protobuf/protobuf-no-mingw-pthread.patch
- contrib/src/protobuf/rules.mak


Changes:

=====================================
contrib/src/main.mak
=====================================
@@ -437,7 +437,7 @@ RECONF = mkdir -p -- $(PREFIX)/share/aclocal && \
 BUILD_DIR = $</vlc_build
 BUILD_SRC := ..
 # build directory relative to UNPACK_DIR
-BUILD_DIRUNPACK = vlc_build
+BUILD_DIRUNPACK := vlc_build
 
 MAKEBUILDDIR = mkdir -p $(BUILD_DIR) && rm -f $(BUILD_DIR)/config.status && test ! -f $</config.status || $(MAKE) -C $< distclean
 MAKEBUILD = $(MAKE) -C $(BUILD_DIR)
@@ -449,15 +449,23 @@ MAKECONFIGURE = $(MAKECONFDIR)/configure $(HOSTCONF)
 # itself instead of relying on a shell, but a bug in gnulib ends up
 # trying to execute a cmake folder when one is found in the PATH
 CMAKEBUILD = env cmake --build $(BUILD_DIR)
-CMAKEINSTALL = env cmake --install $(BUILD_DIR) --prefix $(PREFIX)
+CMAKEINSTALL = env cmake --install $(BUILD_DIR)
 CMAKECLEAN = rm -f $(BUILD_DIR)/CMakeCache.txt
-CMAKE = cmake -S $< -DCMAKE_TOOLCHAIN_FILE=$(abspath toolchain.cmake) \
-		-B $(BUILD_DIR) \
+CMAKECONFIG = cmake -S $< -B $(BUILD_DIR) \
 		-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-		-DCMAKE_INSTALL_PREFIX:STRING=$(PREFIX) \
 		-DBUILD_SHARED_LIBS:BOOL=OFF \
 		-DCMAKE_INSTALL_LIBDIR:STRING=lib \
-		-DBUILD_TESTING:BOOL=OFF
+		-DBUILD_TESTING:BOOL=OFF \
+		-G $(CMAKE_GENERATOR)
+ifeq ($(V),1)
+CMAKECONFIG += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
+endif
+
+CMAKE = $(CMAKECONFIG) \
+		-DCMAKE_TOOLCHAIN_FILE=$(abspath toolchain.cmake) \
+		-DCMAKE_INSTALL_PREFIX:STRING=$(PREFIX)
+CMAKE_NATIVE = $(CMAKECONFIG) \
+		-DCMAKE_INSTALL_PREFIX:STRING=$(BUILDPREFIX)
 ifdef HAVE_WIN32
 CMAKE += -DCMAKE_DEBUG_POSTFIX:STRING=
 endif
@@ -468,11 +476,6 @@ ifdef MSYS_BUILD
 CMAKE = PKG_CONFIG_LIBDIR="$(PKG_CONFIG_PATH)" $(CMAKE)
 CMAKE += -DCMAKE_LINK_LIBRARY_SUFFIX:STRING=.a
 endif
-CMAKE += -G $(CMAKE_GENERATOR)
-
-ifeq ($(V),1)
-CMAKE += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-endif
 
 MESONFLAGS = $(BUILD_DIR) $< --default-library static --prefix "$(PREFIX)" \
 	--backend ninja -Dlibdir=lib


=====================================
contrib/src/protobuf/0001-Fix-9947-make-the-ABI-identical-between-debug-and-no.patch
=====================================
@@ -0,0 +1,76 @@
+From 0ec6d488e784dd3d94567f35abc56a8da454d9f9 Mon Sep 17 00:00:00 2001
+From: Antoine Pitrou <antoine at python.org>
+Date: Tue, 19 Jul 2022 16:40:28 +0200
+Subject: [PATCH] Fix #9947: make the ABI identical between debug and non-debug
+ builds
+
+---
+ src/google/protobuf/message_lite.cc |  8 ++------
+ src/google/protobuf/metadata_lite.h | 13 ++++++++++---
+ 2 files changed, 12 insertions(+), 9 deletions(-)
+
+diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc
+index 3a1b67bf6..da66c1965 100644
+--- a/src/google/protobuf/message_lite.cc
++++ b/src/google/protobuf/message_lite.cc
+@@ -520,18 +520,14 @@ void GenericTypeHandler<std::string>::Merge(const std::string& from,
+   *to = from;
+ }
+ 
+-// Non-inline implementations of InternalMetadata routines
+-#if defined(NDEBUG) || defined(_MSC_VER)
+-// for opt and MSVC builds, the destructor is defined in the header.
+-#else
++// Non-inline implementations of InternalMetadata destructor
+ // This is moved out of the header because the GOOGLE_DCHECK produces a lot of code.
+-InternalMetadata::~InternalMetadata() {
++void InternalMetadata::CheckedDestruct() {
+   if (HasMessageOwnedArenaTag()) {
+     GOOGLE_DCHECK(!HasUnknownFieldsTag());
+     delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
+   }
+ }
+-#endif
+ 
+ // Non-inline variants of std::string specializations for
+ // various InternalMetadata routines.
+diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h
+index 11faba69f..0c31517f0 100644
+--- a/src/google/protobuf/metadata_lite.h
++++ b/src/google/protobuf/metadata_lite.h
+@@ -74,15 +74,19 @@ class PROTOBUF_EXPORT InternalMetadata {
+     GOOGLE_DCHECK(!is_message_owned || arena != nullptr);
+   }
+ 
+-#if defined(NDEBUG) || defined(_MSC_VER)
++  // To keep the ABI identical between debug and non-debug builds,
++  // the destructor is always defined here even though it may delegate
++  // to a non-inline private method.
++  // (see https://github.com/protocolbuffers/protobuf/issues/9947)
+   ~InternalMetadata() {
++#if defined(NDEBUG) || defined(_MSC_VER)
+     if (HasMessageOwnedArenaTag()) {
+       delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
+     }
+-  }
+ #else
+-  ~InternalMetadata();
++    CheckedDestruct();
+ #endif
++  }
+ 
+   template <typename T>
+   void Delete() {
+@@ -261,6 +265,9 @@ class PROTOBUF_EXPORT InternalMetadata {
+   PROTOBUF_NOINLINE void DoSwap(T* other) {
+     mutable_unknown_fields<T>()->Swap(other);
+   }
++
++  // Private helper with debug checks for ~InternalMetadata()
++  void CheckedDestruct();
+ };
+ 
+ // String Template specializations.
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/protobuf/SHA512SUMS
=====================================
@@ -1 +1 @@
-6189e23c7e381f62e971bd0e35ad9c3ed8effe584755357013887c6a582cb5a9a654c39affa2a073b658854138f31bfb70f89fa1df494e9386f1d64fd73d07d2  protobuf-3.4.1-cpp.tar.gz
+370541974e9049963271ed6100c2b78a93d5c206d5ca8bcf00b423038bc3ec049e2c8025d5b306dcd0b3104b15559ac7d9d8a59e235eb94566678afb3c0cef6f  protobuf-3.21.1.tar.gz


=====================================
contrib/src/protobuf/protobuf-no-mingw-pthread.patch deleted
=====================================
@@ -1,13 +0,0 @@
---- protobuf/m4/acx_pthread.m4.orig	2022-02-23 11:15:51.818483000 +0100
-+++ protobuf/m4/acx_pthread.m4	2022-02-23 11:16:06.148340600 +0100
-@@ -134,6 +134,10 @@ case "${host_cpu}-${host_os}" in
- 
-         acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
-         ;;
-+        *mingw*)
-+        # Do not use pthread, fallback to the win32 threading API
-+        acx_pthread_flags=""
-+        ;;
- esac
- 
- if test x"$acx_pthread_ok" = xno; then


=====================================
contrib/src/protobuf/rules.mak
=====================================
@@ -1,8 +1,10 @@
 # protobuf
-PROTOBUF_MAJVERSION := 3.4
+PROTOBUF_MAJPACKAGE := 3
+PROTOBUF_MAJVERSION := 21
 PROTOBUF_REVISION := 1
 PROTOBUF_VERSION := $(PROTOBUF_MAJVERSION).$(PROTOBUF_REVISION)
-PROTOBUF_URL := $(GITHUB)/google/protobuf/releases/download/v$(PROTOBUF_VERSION)/protobuf-cpp-$(PROTOBUF_VERSION).tar.gz
+PROTOBUF_PACKAGE := $(PROTOBUF_MAJPACKAGE).$(PROTOBUF_MAJVERSION).$(PROTOBUF_REVISION)
+PROTOBUF_URL := $(GITHUB)/google/protobuf/releases/download/v$(PROTOBUF_VERSION)/protobuf-cpp-$(PROTOBUF_PACKAGE).tar.gz
 
 ifndef HAVE_TVOS
 PKGS += protobuf protoc
@@ -23,29 +25,29 @@ ifeq ($(shell protoc --version 2>/dev/null | head -1 | sed s/'.* '// | cut -d '.
 PKGS_FOUND += protoc
 endif
 
-$(TARBALLS)/protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz:
+$(TARBALLS)/protobuf-$(PROTOBUF_PACKAGE).tar.gz:
 	$(call download_pkg,$(PROTOBUF_URL),protobuf)
 
-$(TARBALLS)/protoc-$(PROTOBUF_VERSION)-cpp.tar.gz: $(TARBALLS)/protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz
+$(TARBALLS)/protoc-$(PROTOBUF_VERSION)-cpp.tar.gz: $(TARBALLS)/protobuf-$(PROTOBUF_PACKAGE).tar.gz
 	$(RM) -R "$@"
 	cp "$<" "$@"
 
-.sum-protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz
+.sum-protobuf: protobuf-$(PROTOBUF_PACKAGE).tar.gz
 
 DEPS_protobuf = zlib $(DEPS_zlib)
 
-PROTOBUFVARS := DIST_LANG="cpp"
-PROTOCVARS := DIST_LANG="cpp"
-
 PROTOBUF_COMMON_CONF := -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_DEBUG_POSTFIX:STRING=
-PROTOC_CONF := $(PROTOBUF_COMMON_CONF)
+PROTOBUF_CONF := $(PROTOBUF_COMMON_CONF) -Dprotobuf_BUILD_PROTOC_BINARIES=OFF
+PROTOC_CONF := $(PROTOBUF_COMMON_CONF) -Dprotobuf_BUILD_PROTOC_BINARIES=ON
 
 .sum-protoc: .sum-protobuf
 	touch $@
 
 protoc: protoc-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protoc
+	# extract in a different directory as it may run at the same time as the protobug extraction
 	$(RM) -Rf $@ $(UNPACK_DIR) && mkdir -p $(UNPACK_DIR)
 	tar $(TAR_VERBOSE)xzfo "$<" -C $(UNPACK_DIR) --strip-components=1
+	$(APPLY) $(SRC)/protobuf/0001-Fix-9947-make-the-ABI-identical-between-debug-and-no.patch
 	# add a dummy install command to disable some installation
 	sed -i.old '1s;^;function (noinstall ...)\nendfunction()\n;' $(UNPACK_DIR)/cmake/install.cmake
 	# don't install pkg-config files (on top of the target ones)
@@ -56,47 +58,41 @@ protoc: protoc-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protoc
 	sed -i.orig -e 's,install(TARGETS ,noinstall(TARGETS ,' $(UNPACK_DIR)/cmake/install.cmake
 	sed -i.orig -e 's,noinstall(TARGETS protoc,install(TARGETS protoc,' $(UNPACK_DIR)/cmake/install.cmake
 	# set the binary prefix
-	echo "set_target_properties(protoc PROPERTIES PREFIX \"$(HOST)-\")" >> $(UNPACK_DIR)/cmake/install.cmake
+	echo "set_target_properties(protoc PROPERTIES PREFIX \"$(HOST)-\")" >> $(UNPACK_DIR)/cmake/protoc.cmake
 	# disable libprotobuf-ltie
 	# sed -i.orig -e 's,libprotobuf-lite, ,' $(UNPACK_DIR)/cmake/install.cmake
 	# sed -i.orig -e 's,include(libprotobuf-lite,#include(libprotobuf-lite,' $(UNPACK_DIR)/cmake/CMakeLists.txt
 	$(MOVE)
 
+.protoc: BUILD_DIR=$</vlc_native
 .protoc: protoc
 	$(CMAKECLEAN)
-	$(BUILDVARS) cmake -S $</cmake \
-		-B $(BUILD_DIR) \
-		-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-		-DCMAKE_INSTALL_PREFIX:STRING=$(BUILDPREFIX) \
-		-DBUILD_SHARED_LIBS:BOOL=OFF \
-		-DCMAKE_INSTALL_LIBDIR:STRING=lib \
-		-DBUILD_TESTING:BOOL=OFF $(PROTOC_CONF)
+	$(BUILDVARS) $(CMAKE_NATIVE) $(PROTOC_CONF)
 	+$(CMAKEBUILD)
-	env cmake --install $(BUILD_DIR) --prefix $(BUILDPREFIX)
+	$(CMAKEINSTALL)
 	touch $@
 
-protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
+protobuf: protobuf-$(PROTOBUF_PACKAGE).tar.gz .sum-protobuf
 	$(UNPACK)
-	$(RM) -Rf $(UNPACK_DIR)
-	mv protobuf-$(PROTOBUF_VERSION) protobuf-$(PROTOBUF_VERSION)-cpp
-	# don't build benchmarks and conformance
-	sed -i.orig 's, conformance benchmarks,,' "$(UNPACK_DIR)/Makefile.am"
-	sed -i.orig 's, benchmarks/Makefile conformance/Makefile,,' "$(UNPACK_DIR)/configure.ac"
-	# don't use gmock or any sub project to configure
-	sed -i.orig 's,AC_CONFIG_SUBDIRS,dnl AC_CONFIG_SUBDIRS,' "$(UNPACK_DIR)/configure.ac"
+	$(APPLY) $(SRC)/protobuf/0001-Fix-9947-make-the-ABI-identical-between-debug-and-no.patch
+	# add a dummy install command to disable some installation
+	sed -i.old '1s;^;function (noinstall ...)\nendfunction()\n;' $(UNPACK_DIR)/cmake/install.cmake
+	# don't build libprotoc
+	sed -i.orig -e 's,include(libprotoc,#include(libprotoc,' $(UNPACK_DIR)/cmake/CMakeLists.txt
 	# don't build protoc
-	sed -i.orig 's,bin_PROGRAMS,#bin_PROGRAMS,' "$(UNPACK_DIR)/src/Makefile.am"
-	sed -i.orig 's,BUILT_SOURCES,#BUILT_SOURCES,' "$(UNPACK_DIR)/src/Makefile.am"
-	sed -i.orig 's,libprotobuf-lite.la libprotobuf.la libprotoc.la,libprotobuf-lite.la libprotobuf.la,' "$(UNPACK_DIR)/src/Makefile.am"
+	sed -i.orig -e 's,include(protoc,#include(protoc,' $(UNPACK_DIR)/cmake/CMakeLists.txt
+	# don't install libprotoc
+	sed -i.orig -e 's, libprotoc protoc, ,' $(UNPACK_DIR)/cmake/install.cmake
+	sed -i.orig -e 's, libprotoc, ,' $(UNPACK_DIR)/cmake/install.cmake
+	# don't install protoc
+	sed -i.orig -e 's,install(TARGETS protoc,noinstall(TARGETS protoc,' $(UNPACK_DIR)/cmake/install.cmake
 	# force include <algorithm>
 	sed -i.orig 's,#ifdef _MSC_VER,#if 1,' "$(UNPACK_DIR)/src/google/protobuf/repeated_field.h"
-	$(APPLY) $(SRC)/protobuf/protobuf-no-mingw-pthread.patch
 	$(MOVE)
 
-.protobuf: protobuf
-	$(RECONF)
-	$(MAKEBUILDDIR)
-	$(MAKECONFIGURE) $(PROTOBUFVARS)
-	+$(MAKEBUILD)
-	+$(MAKEBUILD) install
+.protobuf: protobuf toolchain.cmake
+	$(CMAKECLEAN)
+	$(HOSTVARS) $(CMAKE) $(PROTOBUF_CONF)
+	+$(CMAKEBUILD)
+	$(CMAKEINSTALL)
 	touch $@



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9a078736ce748c4cf2935c4c3b9368922ea5a0a3...4e47bd35022941eb17d8ae364a054eef1fc45baa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9a078736ce748c4cf2935c4c3b9368922ea5a0a3...4e47bd35022941eb17d8ae364a054eef1fc45baa
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