Skip to content

Commit 6e53020

Browse files
committed
TESTING: Protobuf v26 vs v27
* be able to test a locally cloned and hacker version
1 parent 5e6f23b commit 6e53020

File tree

4 files changed

+94
-5
lines changed

4 files changed

+94
-5
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ git_repository(
101101
# This statement defines the @com_google_protobuf repo.
102102
git_repository(
103103
name = "com_google_protobuf",
104-
patches = ["//patches:protobuf-v27.2.patch"],
104+
patches = ["//patches:protobuf-v27.patch"],
105105
patch_args = ["-p1"],
106106
tag = "v27.2",
107107
remote = "https://github.com/protocolbuffers/protobuf.git",

cmake/dependencies/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ if(BUILD_Protobuf)
106106
#set(protobuf_BUILD_LIBUPB ON)
107107
FetchContent_Declare(
108108
Protobuf
109+
#SOURCE_DIR "${CMAKE_SOURCE_DIR}/pb"
110+
109111
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
110-
GIT_TAG "v27.2"
112+
GIT_TAG "v27.2" # NACK
113+
#GIT_TAG "v27.1" # NACK
114+
#GIT_TAG "v27.0" # NACK
115+
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v27.patch"
116+
117+
#GIT_TAG "v26.1" # ACK
118+
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v26.patch"
119+
111120
GIT_SHALLOW TRUE
112121
GIT_SUBMODULES ""
113-
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v27.2.patch")
122+
)
114123
FetchContent_MakeAvailable(Protobuf)
115124
list(POP_BACK CMAKE_MESSAGE_INDENT)
116125
message(CHECK_PASS "fetched")

patches/protobuf-v26.patch

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 312eeb928..3e154785b 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -41,7 +41,7 @@ else (BUILD_SHARED_LIBS)
6+
endif (BUILD_SHARED_LIBS)
7+
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
8+
include(CMakeDependentOption)
9+
-cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
10+
+cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" OFF
11+
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
12+
set(protobuf_WITH_ZLIB_DEFAULT ON)
13+
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
14+
@@ -158,24 +158,16 @@ endif()
15+
16+
set(_protobuf_FIND_ZLIB)
17+
if (protobuf_WITH_ZLIB)
18+
- find_package(ZLIB)
19+
- if (ZLIB_FOUND)
20+
- set(HAVE_ZLIB 1)
21+
- # FindZLIB module define ZLIB_INCLUDE_DIRS variable
22+
- # Set ZLIB_INCLUDE_DIRECTORIES for compatible
23+
- set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
24+
- # Using imported target if exists
25+
- if (TARGET ZLIB::ZLIB)
26+
- set(ZLIB_LIBRARIES ZLIB::ZLIB)
27+
- set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
28+
- endif (TARGET ZLIB::ZLIB)
29+
- else (ZLIB_FOUND)
30+
- set(HAVE_ZLIB 0)
31+
- # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
32+
- # complain when we use them later.
33+
- set(ZLIB_INCLUDE_DIRECTORIES)
34+
- set(ZLIB_LIBRARIES)
35+
- endif (ZLIB_FOUND)
36+
+ if (NOT TARGET ZLIB::ZLIB)
37+
+ find_package(ZLIB REQUIRED)
38+
+ endif()
39+
+ set(HAVE_ZLIB 1)
40+
+ # FindZLIB module define ZLIB_INCLUDE_DIRS variable
41+
+ # Set ZLIB_INCLUDE_DIRECTORIES for compatible
42+
+ set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
43+
+ # Using imported target if exists
44+
+ set(ZLIB_LIBRARIES ZLIB::ZLIB)
45+
+ set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)\n find_package(ZLIB REQUIRED)\nendif()")
46+
endif (protobuf_WITH_ZLIB)
47+
48+
# We need to link with libatomic on systems that do not have builtin atomics, or
49+
@@ -277,7 +269,6 @@ else (MSVC)
50+
endif (MSVC)
51+
52+
include_directories(
53+
- ${ZLIB_INCLUDE_DIRECTORIES}
54+
${protobuf_BINARY_DIR}
55+
# Support #include-ing other top-level directories, i.e. upb_generator.
56+
${protobuf_SOURCE_DIR}
57+
diff --git a/cmake/install.cmake b/cmake/install.cmake
58+
index 52914a8ea..d7dc5f232 100644
59+
--- a/cmake/install.cmake
60+
+++ b/cmake/install.cmake
61+
@@ -31,6 +31,7 @@ foreach(_library ${_protobuf_libraries})
62+
set_property(TARGET ${_library}
63+
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
64+
$<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
65+
+ $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}>
66+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
67+
if (UNIX AND NOT APPLE)
68+
set_property(TARGET ${_library}

patches/protobuf-v27.2.patch renamed to patches/protobuf-v27.patch

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 9b51e9722..33c1021d4 100644
2+
index 9b51e972..33c1021d 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
55
@@ -42,7 +42,7 @@ else (BUILD_SHARED_LIBS)
@@ -54,8 +54,20 @@ index 9b51e9722..33c1021d4 100644
5454
${protobuf_BINARY_DIR}
5555
# Support #include-ing other top-level directories, i.e. upb_generator.
5656
${protobuf_SOURCE_DIR}
57+
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
58+
index 11c09b1b..fdea9ce1 100644
59+
--- a/cmake/libprotobuf.cmake
60+
+++ b/cmake/libprotobuf.cmake
61+
@@ -28,6 +28,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
62+
endif()
63+
target_include_directories(libprotobuf PUBLIC
64+
$<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
65+
+ $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}>
66+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
67+
)
68+
target_link_libraries(libprotobuf PUBLIC ${protobuf_ABSL_USED_TARGETS})
5769
diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h
58-
index 4fec7dc13..afb6f846a 100644
70+
index 4fec7dc1..afb6f846 100644
5971
--- a/src/google/protobuf/port.h
6072
+++ b/src/google/protobuf/port.h
6173
@@ -49,31 +49,35 @@ inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {

0 commit comments

Comments
 (0)