diff --git a/abs.yaml b/abs.yaml new file mode 100644 index 0000000..cf21595 --- /dev/null +++ b/abs.yaml @@ -0,0 +1,9 @@ +upload_without_merge: true +aggregate_check: false +upload_channels: + - protobuf423 +channels: + - protobuf423 +build_parameters: + - "--suppress-variables" + - "--error-overlinking" diff --git a/recipe/0001-remove-Werror-from-test-flags.patch b/recipe/0001-remove-Werror-from-test-flags.patch deleted file mode 100644 index 14e7bb5..0000000 --- a/recipe/0001-remove-Werror-from-test-flags.patch +++ /dev/null @@ -1,26 +0,0 @@ -From b153be3cc77095c4ef91faf42431144c8bf51dba Mon Sep 17 00:00:00 2001 -From: Jonathan Helmus -Date: Mon, 4 Jun 2018 17:06:30 -0400 -Subject: [PATCH] remove Werror from test flags - -Remove -Werror from the CXXFLAGS used for `make check` ---- - src/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/Makefile.am b/src/Makefile.am -index be18ba7..ecdeab2 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -894,7 +894,7 @@ no_warning_test.cc: - - no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la - no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \ -- -Wall -Wextra -Werror -Wno-unused-parameter -+ -Wall -Wextra -Wno-unused-parameter - nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs) - - TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \ --- -2.17.1 - diff --git a/recipe/0002-remove-failing-json-parser-test.patch b/recipe/0002-remove-failing-json-parser-test.patch deleted file mode 100644 index 5876961..0000000 --- a/recipe/0002-remove-failing-json-parser-test.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc -index aa4751d..b2abe1a 100644 ---- a/src/google/protobuf/util/internal/json_stream_parser_test.cc -+++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc -@@ -389,35 +389,35 @@ TEST_F(JsonStreamParserTest, ArrayComplexValues) { - } - - --// - object containing array, object, value (true, false, null, num, string) --TEST_F(JsonStreamParserTest, ObjectValues) { -- StringPiece str = -- "{t: true, f: false, n: null, s: 'a string', d: \"another string\", pi: " -- "22, ni: -127, pd: 45.3, nd: -1056.4, pl: 11779497823553162765, l: [[]], " -- "o: {'key': true}}"; -- for (int i = 0; i <= str.length(); ++i) { -- ow_.StartObject("") -- ->RenderBool("t", true) -- ->RenderBool("f", false) -- ->RenderNull("n") -- ->RenderString("s", "a string") -- ->RenderString("d", "another string") -- ->RenderUint64("pi", 22) -- ->RenderInt64("ni", -127) -- ->RenderDouble("pd", 45.3) -- ->RenderDouble("nd", -1056.4) -- ->RenderUint64("pl", uint64{11779497823553162765u}) -- ->StartList("l") -- ->StartList("") -- ->EndList() -- ->EndList() -- ->StartObject("o") -- ->RenderBool("key", true) -- ->EndObject() -- ->EndObject(); -- DoTest(str, i); -- } --} -+// // - object containing array, object, value (true, false, null, num, string) -+// TEST_F(JsonStreamParserTest, ObjectValues) { -+// StringPiece str = -+// "{t: true, f: false, n: null, s: 'a string', d: \"another string\", pi: " -+// "22, ni: -127, pd: 45.3, nd: -1056.4, pl: 11779497823553162765, l: [[]], " -+// "o: {'key': true}}"; -+// for (int i = 0; i <= str.length(); ++i) { -+// ow_.StartObject("") -+// ->RenderBool("t", true) -+// ->RenderBool("f", false) -+// ->RenderNull("n") -+// ->RenderString("s", "a string") -+// ->RenderString("d", "another string") -+// ->RenderUint64("pi", 22) -+// ->RenderInt64("ni", -127) -+// ->RenderDouble("pd", 45.3) -+// ->RenderDouble("nd", -1056.4) -+// ->RenderUint64("pl", uint64{11779497823553162765u}) -+// ->StartList("l") -+// ->StartList("") -+// ->EndList() -+// ->EndList() -+// ->StartObject("o") -+// ->RenderBool("key", true) -+// ->EndObject() -+// ->EndObject(); -+// DoTest(str, i); -+// } -+// } - - - TEST_F(JsonStreamParserTest, RejectNonUtf8WhenNotCoerced) { diff --git a/recipe/0003-remove-large-output-test.patch b/recipe/0003-remove-large-output-test.patch deleted file mode 100644 index 74abfe8..0000000 --- a/recipe/0003-remove-large-output-test.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc -index cc53949..4ffd1c0 100644 ---- a/src/google/protobuf/io/zero_copy_stream_unittest.cc -+++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc -@@ -712,20 +712,20 @@ TEST_F(IoTest, StringIo) { - } - } - --// Verifies that outputs up to kint32max can be created. --TEST_F(IoTest, LargeOutput) { -- std::string str; -- StringOutputStream output(&str); -- void* unused_data; -- int size; -- // Repeatedly calling Next should eventually grow the buffer to kint32max. -- do { -- EXPECT_TRUE(output.Next(&unused_data, &size)); -- } while (str.size() < std::numeric_limits::max()); -- // Further increases should be possible. -- output.Next(&unused_data, &size); -- EXPECT_GT(size, 0); --} -+// // Verifies that outputs up to kint32max can be created. -+// TEST_F(IoTest, LargeOutput) { -+// std::string str; -+// StringOutputStream output(&str); -+// void* unused_data; -+// int size; -+// // Repeatedly calling Next should eventually grow the buffer to kint32max. -+// do { -+// EXPECT_TRUE(output.Next(&unused_data, &size)); -+// } while (str.size() < std::numeric_limits::max()); -+// // Further increases should be possible. -+// output.Next(&unused_data, &size); -+// EXPECT_GT(size, 0); -+// } - - - // To test files, we create a temporary file, write, read, truncate, repeat. diff --git a/recipe/bld-shared.bat b/recipe/bld-shared.bat deleted file mode 100644 index e3879bb..0000000 --- a/recipe/bld-shared.bat +++ /dev/null @@ -1,21 +0,0 @@ -:: Setup directory structure per protobuf's instructions. -cd cmake -if errorlevel 1 exit 1 - -mkdir build-shared -if errorlevel 1 exit 1 -cd build-shared -if errorlevel 1 exit 1 - -:: Configure and install based on protobuf's instructions and other `bld.bat`s. -cmake -G "Ninja" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ - -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ - -Dprotobuf_WITH_ZLIB=ON ^ - -Dprotobuf_BUILD_SHARED_LIBS=ON ^ - -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^ - .. -if errorlevel 1 exit 1 -cmake --build . --target install --config Release -if errorlevel 1 exit 1 diff --git a/recipe/bld-static.bat b/recipe/bld-static.bat deleted file mode 100644 index ccba7af..0000000 --- a/recipe/bld-static.bat +++ /dev/null @@ -1,22 +0,0 @@ -:: Setup directory structure per protobuf's instructions. -cd cmake -if errorlevel 1 exit 1 - -mkdir build-static -if errorlevel 1 exit 1 -cd build-static -if errorlevel 1 exit 1 - -:: Configure and install based on protobuf's instructions and other `bld.bat`s. -cmake -G "Ninja" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ - -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ - -Dprotobuf_WITH_ZLIB=ON ^ - -Dprotobuf_BUILD_SHARED_LIBS=OFF ^ - -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^ - .. -if errorlevel 1 exit 1 -cmake --build . --target install --config Release -if errorlevel 1 exit 1 - diff --git a/recipe/build-lib.bat b/recipe/build-lib.bat new file mode 100644 index 0000000..7636d3a --- /dev/null +++ b/recipe/build-lib.bat @@ -0,0 +1,35 @@ +@echo on + +if "%PKG_NAME%"=="libprotobuf-static" ( + set CF_SHARED=OFF + mkdir build-static + cd build-static +) else ( + set CF_SHARED=ON + mkdir build-shared + cd build-shared +) + +:: Configure and install based on protobuf's instructions and other `bld.bat`s. +cmake -G "Ninja" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_CXX_STANDARD=17 ^ + -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ + -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ + -Dprotobuf_ABSL_PROVIDER="package" ^ + -Dprotobuf_BUILD_SHARED_LIBS=%CF_SHARED% ^ + -Dprotobuf_JSONCPP_PROVIDER="package" ^ + -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^ + -Dprotobuf_USE_EXTERNAL_GTEST=ON ^ + -Dprotobuf_WITH_ZLIB=ON ^ + .. +if %ERRORLEVEL% neq 0 exit 1 + +cmake --build . +if %ERRORLEVEL% neq 0 exit 1 + +ctest --progress --output-on-failure +if %ERRORLEVEL% neq 0 exit 1 + +cmake --install . +if %ERRORLEVEL% neq 0 exit 1 diff --git a/recipe/build-lib.sh b/recipe/build-lib.sh new file mode 100644 index 0000000..ff7123c --- /dev/null +++ b/recipe/build-lib.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -ex + +if [[ "$(uname)" == "Linux" ]]; then + # protobuf uses PROTOBUF_OPT_FLAG to set the optimization level + # unit test can fail if optmization above 0 are used. + CPPFLAGS="${CPPFLAGS//-O[0-9]/}" + CXXFLAGS="${CXXFLAGS//-O[0-9]/}" + export PROTOBUF_OPT_FLAG="-O2" + # to improve performance, disable checks intended for debugging + CXXFLAGS="$CXXFLAGS -DNDEBUG" +elif [[ "$(uname)" == "Darwin" ]]; then + # See https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk + CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY" + # remove pie from LDFLAGS + LDFLAGS="${LDFLAGS//-pie/}" +fi + +# required to pick up conda installed zlib +export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" + +# delete vendored gtest to force protobuf_USE_EXTERNAL_GTEST to work; +# this gets run twice (second time for libprotobuf-static), so don't fail +rm -rf ./third_party/googletest | true + +if [[ "$PKG_NAME" == "libprotobuf-static" ]]; then + export CF_SHARED=OFF + mkdir build-static + cd build-static +else + export CF_SHARED=ON + mkdir build-shared + cd build-shared +fi + +cmake -G "Ninja" \ + ${CMAKE_ARGS} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_STANDARD=17 \ + -Dprotobuf_ABSL_PROVIDER="package" \ + -Dprotobuf_BUILD_SHARED_LIBS=$CF_SHARED \ + -Dprotobuf_JSONCPP_PROVIDER="package" \ + -Dprotobuf_USE_EXTERNAL_GTEST=ON \ + -Dprotobuf_WITH_ZLIB=ON \ + .. + +cmake --build . + +#ctest is too broad and does not have an option to exclude specific gtest test cases, therefore calling gtest directly instead +#ctest --progress --output-on-failure +./lite-test +./tests --gtest_filter="IoTest.*-IoTest.LargeOutput" #LargeOutput failing because lack of resources on build agents + +cmake --install . diff --git a/recipe/build-shared.sh b/recipe/build-shared.sh deleted file mode 100644 index 328e86d..0000000 --- a/recipe/build-shared.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -ex - -if [ "$(uname)" == "Linux" ]; -then - # protobuf uses PROTOBUF_OPT_FLAG to set the optimization level - # unit test can fail if optmization above 0 are used. - # update: no -O at all is triggering warnings. - # CPPFLAGS="${CPPFLAGS//-O[0-9]/}" - # CXXFLAGS="${CXXFLAGS//-O[0-9]/}" - export PROTOBUF_OPT_FLAG="-O2" - # to improve performance, disable checks intended for debugging - CXXFLAGS="$CXXFLAGS -DNDEBUG" -elif [ "$(uname)" == "Darwin" ]; -then - # remove pie from LDFLAGS - LDFLAGS="${LDFLAGS//-pie/}" -fi - -# sed is missing from path in build for osx-arm64. This is a -# workaround for expediency and should be removed when possible. -if [[ "${target_platform}" == "osx-arm64" ]]; then - export SED="${BUILD_PREFIX}/bin/sed" -fi - - -# required to pick up conda installed zlib -export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include" -export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" - -# Build configure/Makefile as they are not present. -aclocal -libtoolize -autoconf -autoreconf -i -automake --add-missing - -./configure --prefix="${PREFIX}" \ - --build=${BUILD} \ - --host=${HOST} \ - --with-pic \ - --with-zlib \ - --enable-shared \ - CC_FOR_BUILD=${CC} \ - CXX_FOR_BUILD=${CXX} - -# Skip memory hungry tests -export GTEST_FILTER="-IoTest.LargeOutput" -if [ "${HOST}" == "powerpc64le-conda_cos7-linux-gnu" ]; then - make -j 2 - make check -j 2 || (cat src/test-suite.log; exit 1) -else - make -j ${CPU_COUNT} - if [[ "$CONDA_BUILD_CROSS_COMPILATION" != 1 ]]; then - make check -j ${CPU_COUNT} || (cat src/test-suite.log; exit 1) - fi -fi -make install -rm ${PREFIX}/lib/libprotobuf.a -rm ${PREFIX}/lib/libprotobuf-lite.a -rm ${PREFIX}/lib/libprotoc.a diff --git a/recipe/build.sh b/recipe/build.sh new file mode 100644 index 0000000..e69de29 diff --git a/recipe/build_static.sh b/recipe/build_static.sh deleted file mode 100755 index f4666ac..0000000 --- a/recipe/build_static.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -mkdir -p ${PREFIX}/lib -ls -l ./src/.libs/libproto*.a -cp ./src/.libs/libproto*.a ${PREFIX}/lib/ diff --git a/recipe/cmake_test/CMakeLists.txt b/recipe/cmake_test/CMakeLists.txt new file mode 100644 index 0000000..3903538 --- /dev/null +++ b/recipe/cmake_test/CMakeLists.txt @@ -0,0 +1,26 @@ +project(cf_dummy LANGUAGES C CXX) +cmake_minimum_required(VERSION 3.12) +# We need to specify CONFIG to make sure that CMake +# uses protobuf-config.cmake instead of relying on its +# own FindProtobuf.cmake that does not know about +# abseil transitive depedendency and about C++ version +# required, see https://github.com/conda-forge/conda-forge-pinning-feedstock/issues/4075#issuecomment-1569242816 +find_package(Protobuf CONFIG REQUIRED) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/struct_example.cc +" + +#include + +#include + +int main() +{ + google::protobuf::Struct myStruct; +} + +" +) + +add_executable(struct_example ${CMAKE_CURRENT_BINARY_DIR}/struct_example.cc) +target_link_libraries(struct_example PRIVATE protobuf::libprotobuf) diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index 3f0daee..7664a1a 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -1,4 +1,16 @@ -c_compiler_version: # [linux and ppc64le] - - 8 # [linux and ppc64le] -cxx_compiler_version: # [linux and ppc64le] - - 8 # [linux and ppc64le] \ No newline at end of file +# abseil 20230802 now only support MacOS >=10.13, reflect this here +MACOSX_SDK_VERSION: # [osx and x86_64] + - "10.13" # [osx and x86_64] +MACOSX_DEPLOYMENT_TARGET: # [osx and x86_64] + - "10.13" # [osx and x86_64] + +CONDA_BUILD_SYSROOT: # [osx and x86] + - /opt/MacOSX10.13.sdk # [osx and x86] + +c_compiler: # [win] + - vs2019 # [win] +cxx_compiler: # [win] + - vs2019 # [win] +vc: # [win] + - 16 # [win] + diff --git a/recipe/issue-7567.patch b/recipe/issue-7567.patch deleted file mode 100644 index 8254edc..0000000 --- a/recipe/issue-7567.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h -index c0427bc..8635314 100644 ---- a/src/google/protobuf/parse_context.h -+++ b/src/google/protobuf/parse_context.h -@@ -744,7 +744,6 @@ PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( - void* object, const char* ptr, ParseContext* ctx); - - template --PROTOBUF_EXPORT_TEMPLATE_DEFINE - PROTOBUF_MUST_USE_RESULT const - char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), InternalMetadata* metadata, -@@ -760,7 +759,6 @@ PROTOBUF_MUST_USE_RESULT const - } - - template --PROTOBUF_EXPORT_TEMPLATE_DEFINE - PROTOBUF_MUST_USE_RESULT const - char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(const void*, int), diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 4c27598..6ed20cf 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,113 +1,158 @@ -{% set version = "3.20.3" %} + +{% set version = "4.23.4" %} +{% set libraries = ["libprotoc", "libprotobuf", "libprotobuf-lite"] %} package: - name: libprotobuf-suite + name: libprotobuf-split version: {{ version }} source: - - url: https://github.com/protocolbuffers/protobuf/archive/v{{ version }}/libprotobuf-v{{ version }}.tar.gz - sha256: 9c0fd39c7a08dff543c643f0f4baf081988129a411b977a07c46221793605638 - patches: # [linux] - # We don't want the build to fail because of -Werror being used during - # make check. - - 0001-remove-Werror-from-test-flags.patch # [linux] - # - 0002-remove-failing-json-parser-test.patch # [s390x] - # our build machine does not have enough memory for this test. - # see: https://github.com/protocolbuffers/protobuf/issues/8082 - # - 0003-remove-large-output-test.patch # [s390x] - # This issue gets fixed and then reintroduced often - # https://github.com/protocolbuffers/protobuf/issues/7567 - #- issue-7567.patch - # these are git submodules from the {{ version }} release - # https://github.com/protocolbuffers/protobuf/tree/v{{ version }}/third_party - - url: https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz - sha256: 5dc92703f811f94e2aa63bdab07ab749f28a094befa6cdfd5fe177f947590a48 - folder: third_party/benchmark - - url: https://github.com/google/googletest/archive/5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz - sha256: 0e2f36e8e403c125fd0ab02171bdb786d3b6b3875b6ccf3b2eb7969be8faecd0 - folder: third_party/googletest + - url: https://github.com/protocolbuffers/protobuf/archive/refs/tags/v{{ version }}.tar.gz + sha256: 5f3cd52d6e5062071d99da57a96ea87e39bc020d6d25748001d919c474a4d8ed + patches: + - patches/0001-use-consistent-cmake-location.patch + - patches/0002-set-static-lib-extension-on-windows.patch + # backport https://github.com/protocolbuffers/protobuf/pull/12577 + - patches/0003-Enable-the-selection-of-system-provided-jsoncpp-1257.patch + - patches/0004-always-look-for-shared-abseil-builds.patch + # grpc_cpp_java_plugin links against otherwise internal symbols + - patches/0005-Export-functions-in-google-compiler-java-names.patch + - patches/0006-do-not-install-vendored-gmock.patch build: number: 0 -requirements: - build: # [linux or (osx and arm64)] - - patch # [linux] - - sed # [osx and arm64] - outputs: - name: libprotobuf - script: build-shared.sh # [unix] - script: bld-shared.bat # [win] + script: build-lib.sh # [unix] + script: build-lib.bat # [win] build: missing_dso_whitelist: # [s390x] - $RPATH/ld64.so.1 # [s390x] run_exports: - # breaks backwards compatibility and new SONAME each minor release - # https://abi-laboratory.pro/tracker/timeline/protobuf/ - # One exception was that 3.6.1 was incompatible with 3.6.0 - - {{ pin_subpackage('libprotobuf', max_pin='x.x') }} + # protobuf now (intentionally) increments the SOVER with every patch release, which + # breaks tools like grpc_plugin_cpp if they get the wrong libprotoc at runtime, see + # https://github.com/conda-forge/conda-forge-pinning-feedstock/issues/4075 + - {{ pin_subpackage('libprotobuf', max_pin='x.x.x') }} + ignore_run_exports_from: + # jsoncpp not needed at runtime + - jsoncpp + # gtest not needed at runtime + - gtest requirements: build: - {{ compiler('c') }} - {{ compiler('cxx') }} - - cmake # [win] - - ninja # [win] - - autoconf # [not win] - - automake # [not win] - - libtool # [not win] - - pkg-config # [not win] - - unzip # [not win] - - make # [not win] - - sed # [osx and arm64] + - cmake + - ninja + - patch # [unix] + - m2-patch # [win] host: + - gtest 1.14.0 + - jsoncpp 1.9.4 + - abseil-cpp 20230802 - zlib run: - - zlib + - __osx >={{ MACOSX_DEPLOYMENT_TARGET }} # [osx and x86_64] + test: + requires: + # cmake needs compiler to be able to run package detection, see + # https://discourse.cmake.org/t/questions-about-find-package-cli-msvc/6194 + - {{ compiler('cxx') }} + - cmake + - ninja + - zstd + + files: + - cmake_test/ commands: + {% for each_lib in libraries %} + # shared libraries + - test -f ${PREFIX}/lib/{{ each_lib }}.so # [linux] + - test -f ${PREFIX}/lib/{{ each_lib }}.dylib # [osx] + - if not exist %LIBRARY_BIN%\{{ each_lib }}.dll exit 1 # [win] + - if not exist %LIBRARY_LIB%\{{ each_lib }}.lib exit 1 # [win] + + # absence of static libraries + - test ! -f ${PREFIX}/lib/{{ each_lib }}.a # [unix] + - if exist %LIBRARY_LIB%\{{ each_lib }}-static.lib exit 1 # [win] + {% endfor %} + + # cmake + - test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix] + - if not exist %LIBRARY_LIB%\cmake\protobuf\protobuf-config.cmake exit 1 # [win] + + # pkgconfig + - test -f ${PREFIX}/lib/pkgconfig/protobuf.pc # [unix] + - test -f ${PREFIX}/lib/pkgconfig/protobuf-lite.pc # [unix] + - if not exist %LIBRARY_LIB%\pkgconfig\protobuf.pc exit 1 # [win] + - if not exist %LIBRARY_LIB%\pkgconfig\protobuf-lite.pc exit 1 # [win] + + # binary - protoc --help - - test -f ${PREFIX}/lib/libprotobuf${SHLIB_EXT} # [not win] - - test ! -f ${PREFIX}/lib/libprotobuf.a # [not win] - - if not exist %PREFIX%\\Library\\lib\\libprotoc.lib exit 1 # [win] - - if not exist %PREFIX%\\Library\\lib\\libprotobuf.lib exit 1 # [win] - - if not exist %PREFIX%\\Library\\lib\\libprotobuf-lite.lib exit 1 # [win] + + # more CMake integration + - cd cmake_test + - cmake -GNinja $CMAKE_ARGS . # [unix] + # windows cannot link with mix debug and release version, so set to Release + - cmake -GNinja -DCMAKE_BUILD_TYPE=Release . # [win] + - cmake --build . - name: libprotobuf-static - script: build_static.sh # [unix] - script: bld-static.bat # [win] + script: build-lib.sh # [unix] + script: build-lib.bat # [win] + build: + always_include_files: + # Must overwrite the CMake metadata from shared libprotobuf + - lib/cmake/protobuf/ # [unix] + - Library/lib/cmake/protobuf/ # [win] + ignore_run_exports_from: + # jsoncpp not needed at runtime + - jsoncpp + # gtest not needed at runtime + - gtest requirements: build: - {{ compiler('c') }} - {{ compiler('cxx') }} - - cmake # [win] - - ninja # [win] - - autoconf # [not win] - - automake # [not win] - - libtool # [not win] - - pkg-config # [not win] - - unzip # [not win] - - make # [not win] + - cmake + - ninja host: - - zlib # [not win] - - {{ pin_subpackage('libprotobuf', exact=True) }} # [not win] + - gtest 1.14.0 + - jsoncpp 1.9.4 + - abseil-cpp 20230802 + - zlib + - {{ pin_subpackage('libprotobuf', exact=True) }} run: - - zlib # [not win] - - {{ pin_subpackage('libprotobuf', exact=True) }} # [not win] - run_constrained: - - libprotobuf <0a0 # [win] + - {{ pin_subpackage('libprotobuf', exact=True) }} test: + requires: + # cmake needs compiler to be able to run package detection, see + # https://discourse.cmake.org/t/questions-about-find-package-cli-msvc/6194 + - {{ compiler('cxx') }} + - cmake + - ninja + - zlib + - zstd + files: + - cmake_test/ commands: - - test -f ${PREFIX}/lib/libprotobuf.a # [unix] - - test -f ${PREFIX}/lib/libprotobuf-lite.a # [unix] - - test -f ${PREFIX}/lib/libprotoc.a # [unix] - - if exist %PREFIX%\\Library\\bin\\libprotoc.dll exit 1 # [win] - - if not exist %PREFIX%\\Library\\lib\\libprotoc.lib exit 1 # [win] - - if not exist %PREFIX%\\Library\\lib\\libprotobuf.lib exit 1 # [win] - - if not exist %PREFIX%\\Library\\lib\\libprotobuf-lite.lib exit 1 # [win] + {% for each_lib in libraries %} + # static libraries + - test -f ${PREFIX}/lib/{{ each_lib }}.a # [unix] + - if not exist %LIBRARY_LIB%\{{ each_lib }}-static.lib exit 1 # [win] + {% endfor %} + + # more CMake integration + - cd cmake_test + - cmake -GNinja $CMAKE_ARGS . # [unix] + # windows cannot link with mix debug and release version, so set to Release + - cmake -GNinja -DCMAKE_BUILD_TYPE=Release . # [win] + - cmake --build . about: - home: https://developers.google.com/protocol-buffers/ + home: https://protobuf.dev/ license: BSD-3-Clause license_family: BSD license_file: LICENSE @@ -117,13 +162,15 @@ about: platform-neutral, extensible mechanism for serializing structured data- think XML, but smaller, faster, and simpler. dev_url: https://github.com/protocolbuffers/protobuf - doc_url: https://developers.google.com/protocol-buffers/ + doc_url: https://protobuf.dev/ extra: recipe-maintainers: + - xylar - dopplershift - jakirkham - ocefpaf - wesm - hajapy - xhochy + - h-vetinari diff --git a/recipe/patches/0001-use-consistent-cmake-location.patch b/recipe/patches/0001-use-consistent-cmake-location.patch new file mode 100644 index 0000000..38c0698 --- /dev/null +++ b/recipe/patches/0001-use-consistent-cmake-location.patch @@ -0,0 +1,32 @@ +From c15a3b5551d4ad414ef6840d63153fd5babd71a5 Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Sat, 3 Sep 2022 19:48:04 +0200 +Subject: [PATCH 1/6] use consistent cmake location + +--- + cmake/install.cmake | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +diff --git a/cmake/install.cmake b/cmake/install.cmake +index e7eb2103b..24d7a3ec9 100644 +--- a/cmake/install.cmake ++++ b/cmake/install.cmake +@@ -84,15 +84,9 @@ set(_install_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the c + set(_build_cmakedir_desc "Directory relative to CMAKE_CURRENT_BINARY_DIR for cmake configuration files") + set(_exampledir_desc "Directory relative to CMAKE_INSTALL_DATA to install examples") + set(_protobuf_subdir_desc "Subdirectory in which to install cmake configuration files") +-if(NOT MSVC) +- set(protobuf_CMAKE_SUBDIR "cmake/protobuf" CACHE STRING "${_protobuf_subdir_desc}") +- set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/${protobuf_CMAKE_SUBDIR}" CACHE STRING "${_install_cmakedir_desc}") +- set(CMAKE_INSTALL_EXAMPLEDIR "${CMAKE_INSTALL_DATADIR}/protobuf/examples" CACHE STRING "${_exampledir_desc}") +-else() +- set(protobuf_CMAKE_SUBDIR "cmake" CACHE STRING "${_protobuf_subdir_desc}") +- set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}") +- set(CMAKE_INSTALL_EXAMPLEDIR "examples" CACHE STRING "${_exampledir_desc}") +-endif() ++set(protobuf_CMAKE_SUBDIR "cmake/protobuf" CACHE STRING "${_protobuf_subdir_desc}") ++set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/${protobuf_CMAKE_SUBDIR}" CACHE STRING "${_install_cmakedir_desc}") ++set(CMAKE_INSTALL_EXAMPLEDIR "${CMAKE_INSTALL_DATADIR}/protobuf/examples" CACHE STRING "${_exampledir_desc}") + set(CMAKE_BUILD_CMAKEDIR "${CMAKE_CURRENT_BINARY_DIR}/${protobuf_CMAKE_SUBDIR}" CACHE STRING "${_build_cmakedir_desc}") + mark_as_advanced(protobuf_CMAKE_SUBDIR) + mark_as_advanced(CMAKE_BUILD_CMAKEDIR) diff --git a/recipe/patches/0002-set-static-lib-extension-on-windows.patch b/recipe/patches/0002-set-static-lib-extension-on-windows.patch new file mode 100644 index 0000000..c93a269 --- /dev/null +++ b/recipe/patches/0002-set-static-lib-extension-on-windows.patch @@ -0,0 +1,26 @@ +From 7b2a54aa3e10a6c64dfcbbb0352c4cbd2003abf4 Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Sun, 4 Sep 2022 10:57:08 +0200 +Subject: [PATCH 2/6] set static lib extension on windows + +--- + CMakeLists.txt | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 909cfe39a..3104f6500 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -371,6 +371,12 @@ else () + endif () + endif () + ++if (MSVC AND NOT protobuf_BUILD_SHARED_LIBS) ++ set_target_properties(libprotoc PROPERTIES SUFFIX "-static.lib") ++ set_target_properties(libprotobuf PROPERTIES SUFFIX "-static.lib") ++ set_target_properties(libprotobuf-lite PROPERTIES SUFFIX "-static.lib") ++endif (MSVC AND NOT protobuf_BUILD_SHARED_LIBS) ++ + # Ensure we have a protoc executable and protobuf libraries if we need one + if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLES) + if (NOT DEFINED protobuf_PROTOC_EXE) diff --git a/recipe/patches/0003-Enable-the-selection-of-system-provided-jsoncpp-1257.patch b/recipe/patches/0003-Enable-the-selection-of-system-provided-jsoncpp-1257.patch new file mode 100644 index 0000000..3fbac9a --- /dev/null +++ b/recipe/patches/0003-Enable-the-selection-of-system-provided-jsoncpp-1257.patch @@ -0,0 +1,75 @@ +From e41c414ae97281f7a10738199be7fa3b4ef359a7 Mon Sep 17 00:00:00 2001 +From: Mike Rochefort +Date: Mon, 1 May 2023 09:34:17 -0700 +Subject: [PATCH 3/6] Enable the selection of system provided jsoncpp (#12577) + +Allows the use of an external `jsoncpp` library to be used. Replicates the model used by `abseil-cpp` as a "package" or "module" to the `protobuf_JSONCPP_PROVIDER` option. + +Resolves: #11827 + +Closes #12577 + +COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12577 from omenos:omenos/cmake-jsoncpp 073edd69b4d3c57a37c00f1ba992e6cbd1dad949 +PiperOrigin-RevId: 528492610 +--- + CMakeLists.txt | 3 +++ + cmake/conformance.cmake | 31 +++++++++++++++++++------------ + 2 files changed, 22 insertions(+), 12 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3104f6500..b8eccae10 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -332,6 +332,9 @@ endif (protobuf_UNICODE) + set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library") + set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package") + ++set(protobuf_JSONCPP_PROVIDER "module" CACHE STRING "Provider of jsoncpp library") ++set_property(CACHE protobuf_JSONCPP_PROVIDER PROPERTY STRINGS "module" "package") ++ + if (protobuf_BUILD_TESTS) + include(${protobuf_SOURCE_DIR}/cmake/gtest.cmake) + endif (protobuf_BUILD_TESTS) +diff --git a/cmake/conformance.cmake b/cmake/conformance.cmake +index 61ac25a0d..6ba9050af 100644 +--- a/cmake/conformance.cmake ++++ b/cmake/conformance.cmake +@@ -1,12 +1,15 @@ +- +-if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt") +- message(FATAL_ERROR +- "Cannot find third_party/jsoncpp directory that's needed to " +- "build conformance tests. If you use git, make sure you have cloned " +- "submodules:\n" +- " git submodule update --init --recursive\n" +- "If instead you want to skip them, run cmake with:\n" +- " cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n") ++if (protobuf_JSONCPP_PROVIDER STREQUAL "module") ++ if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt") ++ message(FATAL_ERROR ++ "Cannot find third_party/jsoncpp directory that's needed to " ++ "build conformance tests. If you use git, make sure you have cloned " ++ "submodules:\n" ++ " git submodule update --init --recursive\n" ++ "If instead you want to skip them, run cmake with:\n" ++ " cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n") ++ endif() ++elseif(protobuf_JSONCPP_PROVIDER STREQUAL "package") ++ find_package(jsoncpp REQUIRED) + endif() + + add_custom_command( +@@ -84,6 +87,10 @@ add_test(NAME conformance_cpp_test + DEPENDS conformance_test_runner conformance_cpp) + + set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests") +-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp) +-target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include) +-target_link_libraries(conformance_test_runner jsoncpp_lib) ++if(protobuf_JSONCPP_PROVIDER STREQUAL "module") ++ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp) ++ target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include) ++ target_link_libraries(conformance_test_runner jsoncpp_lib) ++else() ++ target_link_libraries(conformance_test_runner jsoncpp) ++endif() diff --git a/recipe/patches/0004-always-look-for-shared-abseil-builds.patch b/recipe/patches/0004-always-look-for-shared-abseil-builds.patch new file mode 100644 index 0000000..c111c4b --- /dev/null +++ b/recipe/patches/0004-always-look-for-shared-abseil-builds.patch @@ -0,0 +1,22 @@ +From 52ee899847501a833926b2232dc0e19bad256003 Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Sat, 13 May 2023 22:43:45 +1100 +Subject: [PATCH 4/6] always look for shared abseil builds + +--- + cmake/abseil-cpp.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake +index b50fb89e6..b07e63f26 100644 +--- a/cmake/abseil-cpp.cmake ++++ b/cmake/abseil-cpp.cmake +@@ -37,7 +37,7 @@ elseif(protobuf_ABSL_PROVIDER STREQUAL "package") + endif() + set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()") + +-if (BUILD_SHARED_LIBS AND MSVC) ++if (MSVC) + # On MSVC Abseil is bundled into a single DLL. + # This condition is necessary as of abseil 20230125.3 when abseil is consumed via add_subdirectory, + # the abseil_dll target is named abseil_dll, while if abseil is consumed via find_package, the target diff --git a/recipe/patches/0005-Export-functions-in-google-compiler-java-names.patch b/recipe/patches/0005-Export-functions-in-google-compiler-java-names.patch new file mode 100644 index 0000000..fc1414a --- /dev/null +++ b/recipe/patches/0005-Export-functions-in-google-compiler-java-names.patch @@ -0,0 +1,91 @@ +From 3a047d8d43d088cf07911d87eca1aa7d4c9b69de Mon Sep 17 00:00:00 2001 +From: "Uwe L. Korn" +Date: Wed, 14 Jun 2023 11:36:55 +0200 +Subject: [PATCH 5/6] Export functions in google::compiler::java::names + +--- + src/google/protobuf/compiler/java/names.h | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/src/google/protobuf/compiler/java/names.h b/src/google/protobuf/compiler/java/names.h +index ddfc8e65d..f26004cd7 100644 +--- a/src/google/protobuf/compiler/java/names.h ++++ b/src/google/protobuf/compiler/java/names.h +@@ -63,67 +63,67 @@ namespace java { + // + // Returns: + // The fully-qualified Java class name. +-std::string ClassName(const Descriptor* descriptor); ++PROTOC_EXPORT std::string ClassName(const Descriptor* descriptor); + + // Requires: + // descriptor != NULL + // + // Returns: + // The fully-qualified Java class name. +-std::string ClassName(const EnumDescriptor* descriptor); ++PROTOC_EXPORT std::string ClassName(const EnumDescriptor* descriptor); + + // Requires: + // descriptor != NULL + // + // Returns: + // The fully-qualified Java class name. +-std::string ClassName(const FileDescriptor* descriptor); ++PROTOC_EXPORT std::string ClassName(const FileDescriptor* descriptor); + + // Requires: + // descriptor != NULL + // + // Returns: + // The fully-qualified Java class name. +-std::string ClassName(const ServiceDescriptor* descriptor); ++PROTOC_EXPORT std::string ClassName(const ServiceDescriptor* descriptor); + + // Requires: + // descriptor != NULL + // + // Returns: + // Java package name. +-std::string FileJavaPackage(const FileDescriptor* descriptor, ++PROTOC_EXPORT std::string FileJavaPackage(const FileDescriptor* descriptor, + Options options = {}); + + // Requires: + // descriptor != NULL + // Returns: + // Capitalized camel case name field name. +-std::string CapitalizedFieldName(const FieldDescriptor* descriptor); ++PROTOC_EXPORT std::string CapitalizedFieldName(const FieldDescriptor* descriptor); + + // Returns: + // Converts a name to camel-case. If cap_first_letter is true, capitalize the + // first letter. +-std::string UnderscoresToCamelCase(absl::string_view input, ++PROTOC_EXPORT std::string UnderscoresToCamelCase(absl::string_view input, + bool cap_next_letter); + // Requires: + // field != NULL + // Returns: + // Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes + // "fooBarBaz" or "FooBarBaz", respectively. +-std::string UnderscoresToCamelCase(const FieldDescriptor* field); ++PROTOC_EXPORT std::string UnderscoresToCamelCase(const FieldDescriptor* field); + + // Requires: + // method != NULL + // Returns: + // Similar, but for method names. (Typically, this merely has the effect + // of lower-casing the first letter of the name.) +-std::string UnderscoresToCamelCase(const MethodDescriptor* method); ++PROTOC_EXPORT std::string UnderscoresToCamelCase(const MethodDescriptor* method); + + // Requires: + // field != NULL + // Returns: + // Same as UnderscoresToCamelCase, but checks for reserved keywords +-std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field); ++PROTOC_EXPORT std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field); + + + } // namespace java diff --git a/recipe/patches/0006-do-not-install-vendored-gmock.patch b/recipe/patches/0006-do-not-install-vendored-gmock.patch new file mode 100644 index 0000000..ffb8446 --- /dev/null +++ b/recipe/patches/0006-do-not-install-vendored-gmock.patch @@ -0,0 +1,24 @@ +From b075b8e59c2c9ec51a3937c53545b6e987b44504 Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Wed, 9 Aug 2023 14:06:35 +1100 +Subject: [PATCH 6/6] do not install vendored gmock + +--- + cmake/install.cmake | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/cmake/install.cmake b/cmake/install.cmake +index 24d7a3ec9..687c05289 100644 +--- a/cmake/install.cmake ++++ b/cmake/install.cmake +@@ -124,10 +124,3 @@ if(protobuf_INSTALL_EXAMPLES) + DESTINATION "${CMAKE_INSTALL_EXAMPLEDIR}" + COMPONENT protobuf-examples) + endif() +- +-if (protobuf_INSTALL_TESTS) +- install(TARGETS gmock EXPORT protobuf-targets +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +-endif()