From fd2811d2a530709d743325034716e0242b045e4f Mon Sep 17 00:00:00 2001 From: Pavel Geler <53797155+pgeler@users.noreply.github.com> Date: Thu, 11 Aug 2022 05:42:59 -0400 Subject: [PATCH] (#12079) add protobuf package version 3.21.4 * add protobuf package version 3.21.4 * fix * fix * Use scm.Version Signed-off-by: Uilian Ries * Adopt new tools Signed-off-by: Uilian Ries * remove old versions * fix Signed-off-by: Uilian Ries Co-authored-by: Uilian Ries --- recipes/protobuf/all/conandata.yml | 52 +--------------- recipes/protobuf/all/conanfile.py | 60 ++++++++++--------- ...issue-7567-no-export-template-define.patch | 20 ------- .../upstream-pr-7288-android-log.patch | 26 -------- .../upstream-pr-7761-cmake-regex-fix.patch | 36 ----------- .../upstream-pr-8301-bundle-destination.patch | 11 ---- .../protobuf/all/test_package/conanfile.py | 8 ++- recipes/protobuf/config.yml | 18 +----- 8 files changed, 42 insertions(+), 189 deletions(-) delete mode 100644 recipes/protobuf/all/patches/upstream-issue-7567-no-export-template-define.patch delete mode 100644 recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch delete mode 100644 recipes/protobuf/all/patches/upstream-pr-7761-cmake-regex-fix.patch delete mode 100644 recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 1c7fe4c9eac39..bf497f2b2f364 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,66 +1,20 @@ sources: - "3.21.1": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.21.1.tar.gz" - sha256: "a295dd3b9551d3e2749a9969583dea110c6cdcc39d02088f7c7bb1100077e081" + "3.21.4": + url: "https://github.com/protocolbuffers/protobuf/archive/v3.21.4.tar.gz" + sha256: "85d42d4485f36f8cec3e475a3b9e841d7d78523cd775de3a86dba77081f4ca25" "3.20.0": url: "https://github.com/protocolbuffers/protobuf/archive/v3.20.0.tar.gz" sha256: "b07772d38ab07e55eca4d50f4b53da2d998bb221575c60a4f81100242d4b4889" "3.19.4": url: "https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz" sha256: "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568" - "3.19.2": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.19.2.tar.gz" - sha256: "4dd35e788944b7686aac898f77df4e9a54da0ca694b8801bd6b2a9ffc1b3085e" "3.18.1": url: "https://github.com/protocolbuffers/protobuf/archive/v3.18.1.tar.gz" sha256: "9111bf0b542b631165fadbd80aa60e7fb25b25311c532139ed2089d76ddf6dd7" "3.17.1": url: "https://github.com/protocolbuffers/protobuf/archive/v3.17.1.tar.gz" sha256: "036d66d6eec216160dd898cfb162e9d82c1904627642667cc32b104d407bb411" - "3.16.0": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.16.0.tar.gz" - sha256: "7892a35d979304a404400a101c46ce90e85ec9e2a766a86041bb361f626247f5" - "3.15.8": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.15.8.tar.gz" - sha256: "0cbdc9adda01f6d2facc65a22a2be5cecefbefe5a09e5382ee8879b522c04441" - "3.15.5": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.15.5.tar.gz" - sha256: "bc3dbf1f09dba1b2eb3f2f70352ee97b9049066c9040ce0c9b67fb3294e91e4b" - "3.13.0": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz" - sha256: "9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a" - "3.12.4": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.12.4.tar.gz" - sha256: "512e5a674bf31f8b7928a64d8adf73ee67b8fe88339ad29adaa3b84dbaa570d8" - "3.11.4": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.11.4.tar.gz" - sha256: "a79d19dcdf9139fa4b81206e318e33d245c4c9da1ffed21c87288ed4380426f9" - "3.9.1": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.9.1.tar.gz" - sha256: "98e615d592d237f94db8bf033fba78cd404d979b0b70351a9e5aaff725398357" patches: "3.19.4": - patch_file: "patches/upstream-pr-9153-msvc-runtime.patch" base_path: "source_subfolder" - "3.19.2": - - patch_file: "patches/upstream-pr-9153-msvc-runtime.patch" - base_path: "source_subfolder" - "3.15.5": - - patch_file: "patches/upstream-pr-8301-bundle-destination.patch" - base_path: "source_subfolder" - "3.13.0": - - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" - base_path: "source_subfolder" - - patch_file: "patches/upstream-pr-7288-android-log.patch" - base_path: "source_subfolder" - - patch_file: "patches/upstream-pr-8301-bundle-destination.patch" - base_path: "source_subfolder" - "3.12.4": - - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" - base_path: "source_subfolder" - - patch_file: "patches/upstream-issue-7567-no-export-template-define.patch" - base_path: "source_subfolder" - - patch_file: "patches/upstream-pr-7288-android-log.patch" - base_path: "source_subfolder" - - patch_file: "patches/upstream-pr-8301-bundle-destination.patch" - base_path: "source_subfolder" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index faa6839278faa..c0e78eec914a4 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -1,7 +1,12 @@ -from conan.tools.files import rename +from conan.tools.files import rename, get, apply_conandata_patches, replace_in_file, rmdir, rm from conan.tools.microsoft import msvc_runtime_flag -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.tools.build import cross_building +from conan.tools.apple.apple import is_apple_os +from conan.errors import ConanInvalidConfiguration +from conan import ConanFile +from conans import CMake + import functools import os import textwrap @@ -60,7 +65,7 @@ def _is_clang_x86(self): @property def _can_disable_rtti(self): - return tools.Version(self.version) >= "3.15.4" + return Version(self.version) >= "3.15.4" def export_sources(self): self.copy("CMakeLists.txt") @@ -86,21 +91,21 @@ def validate(self): raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") if self.settings.compiler == "Visual Studio": - if tools.Version(self.settings.compiler.version) < "14": + if Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " "Visual Studio 2015 or higher.") if self.settings.compiler == "clang": - if tools.Version(self.version) >= "3.15.4" and tools.Version(self.settings.compiler.version) < "4": + if Version(self.version) >= "3.15.4" and Version(self.settings.compiler.version) < "4": raise ConanInvalidConfiguration("protobuf {} doesn't support clang < 4".format(self.version)) - if hasattr(self, "settings_build") and tools.cross_building(self) and \ + if hasattr(self, "settings_build") and cross_building(self) and \ self.settings.os == "Macos" and self.options.shared: # FIXME: should be allowed, actually build succeeds but it fails at build time of test package due to SIP raise ConanInvalidConfiguration("protobuf shared not supported yet in CCI while cross-building on Macos") def source(self): - tools.get(**self.conan_data["sources"][self.version], + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @property @@ -116,7 +121,7 @@ def _configure_cmake(self): cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True if not self.options.debug_suffix: cmake.definitions["protobuf_DEBUG_POSTFIX"] = "" - if tools.Version(self.version) >= "3.14.0": + if Version(self.version) >= "3.14.0": cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True if self._can_disable_rtti: cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti @@ -125,21 +130,20 @@ def _configure_cmake(self): if not runtime: runtime = self.settings.get_safe("compiler.runtime") cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in runtime - if tools.Version(self.version) < "3.18.0" and self._is_clang_cl: + if Version(self.version) < "3.18.0" and self._is_clang_cl: cmake.definitions["CMAKE_RC_COMPILER"] = os.environ.get("RC", "llvm-rc") cmake.configure(build_folder=self._build_subfolder) return cmake def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # Provide relocatable protobuf::protoc target and Protobuf_PROTOC_EXECUTABLE cache variable # TODO: some of the following logic might be disabled when conan will # allow to create executable imported targets in package_info() protobuf_config_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in") - tools.replace_in_file( + replace_in_file(self, protobuf_config_cmake, "@_protobuf_FIND_ZLIB@", "# BEGIN CONAN PATCH\n#_protobuf_FIND_ZLIB@\n# END CONAN PATCH" @@ -163,7 +167,7 @@ def _patch_sources(self): set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{Protobuf_PROTOC_EXECUTABLE}}) endif() """.format(protoc_rel_path=protoc_rel_path)) - tools.replace_in_file( + replace_in_file(self, protobuf_config_cmake, "include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")", protoc_target @@ -172,16 +176,16 @@ def _patch_sources(self): # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf # (even with virtualrunenv, this fix might be required due to SIP) # Only works with cmake, cmake_find_package or cmake_find_package_multi generators - if tools.is_apple_os(self.settings.os): - tools.replace_in_file( + if is_apple_os(self.settings.os): + replace_in_file(self, protobuf_config_cmake, "add_custom_command(", ("set(CUSTOM_DYLD_LIBRARY_PATH ${CONAN_LIB_DIRS} ${Protobuf_LIB_DIRS} ${Protobuf_LIB_DIRS_RELEASE} ${Protobuf_LIB_DIRS_DEBUG} ${Protobuf_LIB_DIRS_RELWITHDEBINFO} ${Protobuf_LIB_DIRS_MINSIZEREL})\n" "string(REPLACE \";\" \":\" CUSTOM_DYLD_LIBRARY_PATH \"${CUSTOM_DYLD_LIBRARY_PATH}\")\n" "add_custom_command(") ) - cmd_str = "COMMAND protobuf::protoc" if tools.Version(self.version) < "3.20.0" else "COMMAND protobuf::protoc" - tools.replace_in_file( + cmd_str = "COMMAND protobuf::protoc" if Version(self.version) < "3.20.0" else "COMMAND protobuf::protoc" + replace_in_file(self, protobuf_config_cmake, cmd_str, "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" $" @@ -190,12 +194,12 @@ def _patch_sources(self): # Disable a potential warning in protobuf-module.cmake.in # TODO: remove this patch? Is it really useful? protobuf_module_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in") - tools.replace_in_file( + replace_in_file(self, protobuf_module_cmake, "if(DEFINED Protobuf_SRC_ROOT_FOLDER)", "if(0)\nif(DEFINED Protobuf_SRC_ROOT_FOLDER)", ) - tools.replace_in_file( + replace_in_file(self, protobuf_module_cmake, "# Define upper case versions of output variables", "endif()", @@ -203,8 +207,8 @@ def _patch_sources(self): # https://github.com/protocolbuffers/protobuf/issues/9916 # it will be solved in protobuf 3.21.0 - if tools.Version(self.version) == "3.20.0": - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "google", "protobuf", "port_def.inc"), + if Version(self.version) == "3.20.0": + replace_in_file(self, os.path.join(self._source_subfolder, "src", "google", "protobuf", "port_def.inc"), "#elif PROTOBUF_GNUC_MIN(12, 0)", "#elif PROTOBUF_GNUC_MIN(12, 2)") @@ -217,7 +221,7 @@ def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets-{}.cmake".format(str(self.settings.build_type).lower()))) @@ -225,8 +229,8 @@ def package(self): os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) if not self.options.lite: - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "libprotobuf-lite.*") - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "libprotobuf-lite.*") + rm(self, "libprotobuf-lite.*", os.path.join(self.package_folder, "lib")) + rm(self, "libprotobuf-lite.*", os.path.join(self.package_folder, "bin")) def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") @@ -290,6 +294,8 @@ def package_info(self): self.cpp_info.filenames["cmake_find_package"] = "Protobuf" self.cpp_info.filenames["cmake_find_package_multi"] = "protobuf" self.cpp_info.names["pkg_config"] ="protobuf_full_package" - self.cpp_info.components["libprotobuf"].build_modules = build_modules + for generator in ["cmake_find_package", "cmake_find_package_multi"]: + self.cpp_info.components["libprotobuf"].build_modules[generator] = build_modules if self.options.lite: - self.cpp_info.components["libprotobuf-lite"].build_modules = build_modules + for generator in ["cmake_find_package", "cmake_find_package_multi"]: + self.cpp_info.components["libprotobuf-lite"].build_modules[generator] = build_modules diff --git a/recipes/protobuf/all/patches/upstream-issue-7567-no-export-template-define.patch b/recipes/protobuf/all/patches/upstream-issue-7567-no-export-template-define.patch deleted file mode 100644 index 1f4994dcc6f04..0000000000000 --- a/recipes/protobuf/all/patches/upstream-issue-7567-no-export-template-define.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- src/google/protobuf/parse_context.h -+++ src/google/protobuf/parse_context.h -@@ -744,7 +744,7 @@ - void* object, const char* ptr, ParseContext* ctx); - - template --PROTOBUF_EXPORT_TEMPLATE_DEFINE -+// PROTOBUF_EXPORT_TEMPLATE_DEFINE do not export definition - PROTOBUF_MUST_USE_RESULT const - char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(int), InternalMetadata* metadata, -@@ -760,7 +760,7 @@ - } - - template --PROTOBUF_EXPORT_TEMPLATE_DEFINE -+// PROTOBUF_EXPORT_TEMPLATE_DEFINE do not export definition - PROTOBUF_MUST_USE_RESULT const - char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx, - bool (*is_valid)(const void*, int), diff --git a/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch b/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch deleted file mode 100644 index ee8110a0c6e02..0000000000000 --- a/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch +++ /dev/null @@ -1,26 +0,0 @@ -https://github.com/protocolbuffers/protobuf/pull/7288 ---- a/cmake/libprotobuf.cmake -+++ b/cmake/libprotobuf.cmake -@@ -121,6 +121,9 @@ endif() - if(protobuf_LINK_LIBATOMIC) - target_link_libraries(libprotobuf atomic) - endif() -+if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") -+ target_link_libraries(libprotobuf log) -+endif() - target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src) - if(MSVC AND protobuf_BUILD_SHARED_LIBS) - target_compile_definitions(libprotobuf - ---- a/cmake/libprotobuf-lite.cmake -+++ b/cmake/libprotobuf-lite.cmake -@@ -67,6 +67,9 @@ target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT}) - if(protobuf_LINK_LIBATOMIC) - target_link_libraries(libprotobuf-lite atomic) - endif() -+if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") -+ target_link_libraries(libprotobuf-lite log) -+endif() - target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src) - if(MSVC AND protobuf_BUILD_SHARED_LIBS) - target_compile_definitions(libprotobuf-lite diff --git a/recipes/protobuf/all/patches/upstream-pr-7761-cmake-regex-fix.patch b/recipes/protobuf/all/patches/upstream-pr-7761-cmake-regex-fix.patch deleted file mode 100644 index 88b0c25718dbd..0000000000000 --- a/recipes/protobuf/all/patches/upstream-pr-7761-cmake-regex-fix.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 1786706c9b7f4b291caa77806c7daef229f9ca6e Mon Sep 17 00:00:00 2001 -From: Afshin Pir -Date: Wed, 29 Jul 2020 21:19:56 +0430 -Subject: [PATCH] Previously, I had incorrectly used some newer features of - CMake(version 3.14). But Now I have updated this code to work with older - versions of CMake too. - ---- - cmake/protobuf-config.cmake.in | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in -index 11b85d3c0..fac5efe44 100644 ---- a/cmake/protobuf-config.cmake.in -+++ b/cmake/protobuf-config.cmake.in -@@ -99,13 +99,17 @@ function(protobuf_generate) - foreach(_proto ${protobuf_generate_PROTOS}) - get_filename_component(_abs_file ${_proto} ABSOLUTE) - get_filename_component(_abs_dir ${_abs_file} DIRECTORY) -- get_filename_component(_basename ${_proto} NAME_WLE) -+ -+ get_filename_component(_file_full_name ${_proto} NAME) -+ string(FIND "${_file_full_name}" "." _file_last_ext_pos REVERSE) -+ string(SUBSTRING "${_file_full_name}" 0 ${_file_last_ext_pos} _basename) - - set(_suitable_include_found FALSE) - foreach(DIR ${_protobuf_include_path}) - if(NOT DIR STREQUAL "-I") - file(RELATIVE_PATH _rel_dir ${DIR} ${_abs_dir}) -- if(NOT "${_rel_dir}" MATCHES "^\.\.[/\\].*") -+ string(FIND "${_rel_dir}" "../" _is_in_parent_folder) -+ if (NOT ${_is_in_parent_folder} EQUAL 0) - set(_suitable_include_found TRUE) - break() - endif() --- diff --git a/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch b/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch deleted file mode 100644 index 63aa4daaae4e4..0000000000000 --- a/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/cmake/install.cmake -+++ b/cmake/install.cmake -@@ -30,7 +30,7 @@ endforeach() - - if (protobuf_BUILD_PROTOC_BINARIES) - install(TARGETS protoc EXPORT protobuf-targets -- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) - if (UNIX AND NOT APPLE) - set_property(TARGET protoc - PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index 9cf01fd2d0fe0..06d5305cf8a67 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -1,4 +1,6 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake import os @@ -7,7 +9,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "cmake_find_package_multi" def build_requirements(self): - if hasattr(self, "settings_build") and tools.cross_building(self): + if hasattr(self, "settings_build") and cross_building(self): self.build_requires(str(self.requires["protobuf"])) def build(self): @@ -17,6 +19,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): + if not cross_building(self): self.run("protoc --version", run_environment=True) self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 39a462c4cc468..ad95acbdb1bfe 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,27 +1,11 @@ versions: - "3.21.1": + "3.21.4": folder: all "3.20.0": folder: all "3.19.4": folder: all - "3.19.2": - folder: all "3.18.1": folder: all "3.17.1": folder: all - "3.16.0": - folder: all - "3.15.8": - folder: all - "3.15.5": - folder: all - "3.13.0": - folder: all - "3.12.4": - folder: all - "3.11.4": - folder: all - "3.9.1": - folder: all