[vlc-commits] [Git][videolan/vlc][master] 2 commits: contrib: protobuf: fix detection of installed protoc

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Oct 15 10:24:01 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
de6f3b34 by Steve Lhomme at 2022-10-15T09:31:43+00:00
contrib: protobuf: fix detection of installed protoc

protoc 3.4.1 reports a libprotoc version of 3.4.0

- - - - -
63b45cfc by Steve Lhomme at 2022-10-15T09:31:43+00:00
configure: do the same protoc check as done in the contribs

In the contribs we
* check that HOST-protoc has the same version as protobuf
otherwise
* check that protoc has the same version as protobuf

AC_CHECK_TOOL() only tests one version of protoc for the protobuf matching.

- - - - -


2 changed files:

- configure.ac
- contrib/src/protobuf/rules.mak


Changes:

=====================================
configure.ac
=====================================
@@ -3846,30 +3846,65 @@ PKG_ENABLE_MODULES_VLC([CHROMAPRINT], [stream_out_chromaprint], [libchromaprint
 dnl
 dnl  Chromecast streaming support
 dnl
+PKG_WITH_MODULES([CHROMECAST],[protobuf-lite], [],[
+    AS_IF([test "${enable_chromecast}" = "yes"],[
+        AC_MSG_ERROR(Library protobuf-lite needed for [chromecast] was not found)
+    ],[
+        AC_MSG_WARN(Library protobuf-lite needed for [chromecast] was not found)
+    ])
+    build_chromecast=no
+], [(Chromecast streaming support)], [auto])
+
 AC_ARG_VAR(PROTOC, [protobuf compiler])
 dnl Intentionally using prefixed binaries for native tool in contribs
-AC_CHECK_TOOL(PROTOC, protoc, no)
-AS_IF([test "${PROTOC}" != "no"], [
-    protoc_ver="$(eval ${PROTOC} --version 2>/dev/null | head -1 | sed s/'.* '//)"
-],[
-    protoc_ver="3.4.1"
-])
-m4_pushdef([protobuf_lite_version], ${protoc_ver})
-PKG_WITH_MODULES([CHROMECAST],[protobuf-lite = protobuf_lite_version], [
+AS_IF([test -n "$PKG_CONFIG"],[
+    AC_CHECK_TOOL(PROTOC, protoc, no)
     AS_IF([test "${PROTOC}" != "no"], [
-        build_chromecast="yes"
-    ], [
-    AC_MSG_ERROR(protoc compiler needed for [chromecast] was not found)
+        dnl silently checks the protoc version matches the protobuf library
+        protoc_ver="$(eval ${PROTOC} --version 2>/dev/null | head -1 | sed s/'.* '// | cut -d '.' -f -2)"
+        protoc_ver_next="${protoc_ver%.*}.$((${protoc_ver##*.}+1))"
+        AC_MSG_CHECKING([protobuf-lite matches ${PROTOC} version ${protoc_ver}])
+        AS_IF([test -n "$PKG_CONFIG"],[
+            ($PKG_CONFIG --exists --print-errors "protobuf-lite >= ${protoc_ver} protobuf-lite < ${protoc_ver_next}") 2>&5
+            ac_status=$?
+            AS_IF([test $ac_status = 0],[
+                protoc_matching=yes
+                AC_MSG_RESULT([yes])
+            ],[
+                protoc_matching=no
+                AC_MSG_RESULT([no])
+            ])
+        ])
+    ],[
+        protoc_matching=no
     ])
-], [
-    AS_IF([test "${enable_chromecast}" = "yes"],
-        AC_MSG_ERROR(Library [protobuf-lite = protobuf_lite_version] needed for [chromecast] was not found),
-        AC_MSG_WARN(Library [protobuf-lite = protobuf_lite_version] needed for [chromecast] was not found)
-    )
-    enable_chromecast="no"
-], [(Chromecast streaming support)], [auto])
-AM_CONDITIONAL([BUILD_CHROMECAST], [test "${build_chromecast}" = "yes"])
-m4_popdef([protobuf_lite_version])
+    AS_IF([test "${protoc_matching}" != "yes"], [
+        dnl Reset cache from the previous test
+        unset PROTOC
+        unset ac_cv_prog_PROTOC
+        dnl checking plain 'protoc' (possibly a second time)
+        AC_CHECK_PROG(PROTOC, protoc, no)
+
+        AS_IF([test "${PROTOC}" != "no"], [
+            dnl silently checks the protoc version matches the protobuf library
+            protoc_ver="$(eval ${PROTOC} --version 2>/dev/null | head -1 | sed s/'.* '// | cut -d '.' -f -2)"
+            protoc_ver_next="${protoc_ver%.*}.$((${protoc_ver##*.}+1))"
+            AC_MSG_CHECKING([protobuf-lite matches ${PROTOC} version ${protoc_ver}])
+            ($PKG_CONFIG --exists --print-errors "protobuf-lite >= ${protoc_ver} protobuf-lite < ${protoc_ver_next}") 2>&5
+            ac_status=$?
+            AS_IF([test $ac_status = 0],[
+                protoc_matching=yes
+                AC_MSG_RESULT([yes])
+            ],[
+                AC_MSG_RESULT([no])
+                AS_IF([test "${enable_chromecast}" != "no"], [
+                    AC_MSG_ERROR(protoc compiler needed for [chromecast] was not found)
+                ])
+            ])
+        ])
+    ])
+])
+AM_CONDITIONAL([BUILD_CHROMECAST], [test "${build_chromecast}" = "yes" -a "${protoc_matching}" = yes])
 
 dnl
 dnl  Interface plugins


=====================================
contrib/src/protobuf/rules.mak
=====================================
@@ -1,5 +1,7 @@
 # protobuf
-PROTOBUF_VERSION := 3.4.1
+PROTOBUF_MAJVERSION := 3.4
+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
 
 ifndef HAVE_TVOS
@@ -14,10 +16,10 @@ PKGS_FOUND += protoc
 endif
 endif
 
-ifeq ($(shell $(HOST)-protoc --version 2>/dev/null | head -1 | sed s/'.* '//),$(PROTOBUF_VERSION))
+ifeq ($(shell $(HOST)-protoc --version 2>/dev/null | head -1 | sed s/'.* '// | cut -d '.' -f -2),$(PROTOBUF_MAJVERSION))
 PKGS_FOUND += protoc
 endif
-ifeq ($(shell protoc --version 2>/dev/null | head -1 | sed s/'.* '//),$(PROTOBUF_VERSION))
+ifeq ($(shell protoc --version 2>/dev/null | head -1 | sed s/'.* '// | cut -d '.' -f -2),$(PROTOBUF_MAJVERSION))
 PKGS_FOUND += protoc
 endif
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d696b09984c122e062110d69241d89742b4f1cfb...63b45cfcf0214f77f0add30b538d1344ea23840c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d696b09984c122e062110d69241d89742b4f1cfb...63b45cfcf0214f77f0add30b538d1344ea23840c
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