Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc add version 1.65 #24215

Merged
merged 13 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions recipes/grpc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.65.0":
url: "https://github.com/grpc/grpc/archive/v1.65.0.tar.gz"
sha256: "ebc3acfde70cfae3f4f04b8dbb72259540cb1dc427be362569fbc2607dabfe39"
"1.54.3":
url: "https://github.com/grpc/grpc/archive/v1.54.3.tar.gz"
sha256: "17e4e1b100657b88027721220cbfb694d86c4b807e9257eaf2fb2d273b41b1b1"
Expand All @@ -8,19 +11,12 @@
"1.50.0":
url: "https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"
sha256: "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a"
"1.48.4":
url: "https://github.com/grpc/grpc/archive/v1.48.4.tar.gz"
sha256: "0c3faa83e39d4f1ab55fe1476362b9ac3b81632a46dce7fd4d50271bce816b53"
patches:
"1.54.3":
- patch_file: "patches/v1.50.x/002-CMake-Add-gRPC_USE_SYSTEMD-option-34384.patch"
patch_type: "backport"

Check warning on line 17 in recipes/grpc/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. found arbitrary text in patch_type: backport ^ (line: 17)
patch_source: "https://github.com/grpc/grpc/commit/5c3400e8dc08d0810e3301d7e8cd8a718c82eeed"
"1.50.1":
- patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch"

Check warning on line 20 in recipes/grpc/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description' not found in - patch_file: patches/v1.50.x/ ... ^ (line: 20)
"1.50.0":
- patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch"

Check warning on line 22 in recipes/grpc/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description' not found in - patch_file: patches/v1.50.x/ ... ^ (line: 22)
"1.48.4":
- patch_file: "patches/v1.48.x/001-disable-cppstd-override.patch"
patch_description: "disable cpp std override"
patch_type: "portability"
203 changes: 60 additions & 143 deletions recipes/grpc/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import yaml

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
Expand Down Expand Up @@ -56,6 +57,7 @@
}

short_paths = True
_target_info = None

@property
def _grpc_plugin_template(self):
Expand All @@ -73,6 +75,9 @@
def _supports_libsystemd(self):
return self.settings.os in ["Linux", "FreeBSD"] and Version(self.version) >= "1.52"

def export(self):
copy(self, f"target_info/grpc_{self.version}.yml", src=self.recipe_folder, dst=self.export_folder)

def export_sources(self):
copy(self, "conan_cmake_project_include.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))
copy(self, f"cmake/{self._grpc_plugin_template}", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))
Expand All @@ -97,16 +102,14 @@

def requirements(self):
# abseil is public. See https://github.com/conan-io/conan-center-index/pull/17284#issuecomment-1526082638
if Version(self.version) < "1.47":
if is_msvc(self):
self.requires("abseil/20211102.0", transitive_headers=True, transitive_libs=True)
else:
self.requires("abseil/20220623.1", transitive_headers=True, transitive_libs=True)
if Version(self.version) >= "1.62.0":
self.requires("protobuf/5.27.0", transitive_headers=True)
self.requires("abseil/[>=20240116.1 <20240117.0]", transitive_headers=True)
else:
self.requires("abseil/20230125.3", transitive_headers=True, transitive_libs=True)
self.requires("c-ares/1.19.1")
self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True)
self.requires("protobuf/3.21.12", transitive_headers=True)
self.requires("c-ares/[>=1.19.1 <2]")
self.requires("openssl/[>=1.1 <4]")
self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True)
self.requires("re2/20230301")
self.requires("zlib/[>=1.2.11 <2]")
if self.options.get_safe("with_libsystemd"):
Expand Down Expand Up @@ -190,9 +193,6 @@
# workaround for: install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
tc.cache_variables["CMAKE_MACOSX_BUNDLE"] = False

if is_msvc(self) and Version(self.version) >= "1.48":
tc.cache_variables["CMAKE_SYSTEM_VERSION"] = "10.0.18362.0"

if self._supports_libsystemd:
tc.cache_variables["gRPC_USE_SYSTEMD"] = self.options.with_libsystemd

Expand All @@ -210,17 +210,42 @@
# - using `make` as the cmake generator
# Make will run commands via `/bin/sh` which will strip all env vars that start with `DYLD*`
# This workaround wraps the protoc command to be invoked by CMake with a modified environment
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
settings_build = getattr(self, "settings_build", self.settings)
if settings_build.os == "Macos":
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
replace_in_file(self, cmakelists,
"COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}",
'COMMAND ${CMAKE_COMMAND} -E env "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}" ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}')
elif not cross_building(self) and settings_build.os == "Linux":
# we are not cross-building, but protobuf or abseil may be shared
# so we need to set LD_LIBRARY_PATH to find them
# Note: if protobuf used RPATH instead of RUNPATH this is not needed
replace_in_file(self, cmakelists,
"COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}",
'COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$<JOIN:${CMAKE_LIBRARY_PATH},:>" ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}')
if self.settings.os == "Macos" and Version(self.version) >= "1.64":
# See https://github.com/grpc/grpc/issues/36654#issuecomment-2228569158
replace_in_file(self, cmakelists, "target_compile_features(upb_textformat_lib PUBLIC cxx_std_14)",
"""target_compile_features(upb_textformat_lib PUBLIC cxx_std_14)
target_link_options(upb_textformat_lib PRIVATE -Wl,-undefined,dynamic_lookup)
target_link_options(upb_json_lib PRIVATE -Wl,-undefined,dynamic_lookup)
""")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()

@property
def target_info(self):
if self._target_info:
return self._target_info
target_info_file = os.path.join(self.recipe_folder, "target_info", f"grpc_{self.version}.yml")
with open(target_info_file) as f:

Check warning on line 245 in recipes/grpc/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Using open without explicitly specifying an encoding
self._target_info = yaml.safe_load(f)
return self._target_info

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
Expand All @@ -230,46 +255,14 @@
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

# Create one custom module file per executable in order to emulate
# CMake executables imported targets of grpc
for plugin_option, values in self._grpc_plugins.items():
if self.options.get_safe(plugin_option):
target = values["target"]
executable = values["executable"]
# CMake executables imported targets of grpc plugins.
for plugin_info in self.target_info["grpc_plugins"]:
target = plugin_info["target"]
executable = plugin_info["executable"]
option_name = executable.replace("grpc_", "")
if self.options.get_safe(option_name):
self._create_executable_module_file(target, executable)

@property
def _grpc_plugins(self):
return {
"cpp_plugin": {
"target": "gRPC::grpc_cpp_plugin",
"executable": "grpc_cpp_plugin",
},
"csharp_plugin": {
"target": "gRPC::grpc_csharp_plugin",
"executable": "grpc_csharp_plugin",
},
"node_plugin": {
"target": "gRPC::grpc_node_plugin",
"executable": "grpc_node_plugin",
},
"objective_c_plugin": {
"target": "gRPC::grpc_objective_c_plugin",
"executable": "grpc_objective_c_plugin",
},
"php_plugin": {
"target": "gRPC::grpc_php_plugin",
"executable": "grpc_php_plugin",
},
"python_plugin": {
"target": "gRPC::grpc_python_plugin",
"executable": "grpc_python_plugin",
},
"ruby_plugin": {
"target": "gRPC::grpc_ruby_plugin",
"executable": "grpc_ruby_plugin",
},
}

def _create_executable_module_file(self, target, executable):
module_abs_path = os.path.join(self.package_folder, self._module_path)

Expand Down Expand Up @@ -316,96 +309,19 @@
def wsock32():
return ["wsock32"] if self.settings.os == "Windows" else []

def corefoundation():
return ["CoreFoundation"] if is_apple_os(self) else []

components = {
"address_sorting": {
"lib": "address_sorting",
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"gpr": {
"lib": "gpr",
"requires": [
"upb", "abseil::absl_base", "abseil::absl_memory",
"abseil::absl_status", "abseil::absl_str_format",
"abseil::absl_strings", "abseil::absl_synchronization",
"abseil::absl_time", "abseil::absl_optional",
"abseil::absl_flags"
] + libsystemd(),
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"_grpc": {
"lib": "grpc",
"requires": [
"address_sorting", "gpr", "upb", "abseil::absl_bind_front",
"abseil::absl_flat_hash_map", "abseil::absl_inlined_vector",
"abseil::absl_statusor", "abseil::absl_random_random",
"c-ares::cares", "openssl::crypto",
"openssl::ssl", "re2::re2", "zlib::zlib",
],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
"frameworks": corefoundation(),
},
"grpc++": {
"lib": "grpc++",
"requires": ["_grpc", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"grpc++_alts": {
"lib": "grpc++_alts",
"requires": ["grpc++", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"grpc++_error_details": {
"lib": "grpc++_error_details",
"requires": ["grpc++", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"upb": {
"lib": "upb",
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"grpc_plugin_support": {
"lib": "grpc_plugin_support",
"requires": ["protobuf::libprotoc", "protobuf::libprotobuf"],
targets = self.target_info['grpc_targets']
components = {}
for target in targets:
if self.options.secure and target['name'] in ["grpc_unsecure", "grpc++_unsecure"]:
continue
if not self.options.codegen and target['name'] in ["grpc++_reflection", "grpcpp_channelz"]:
continue
components[target['name']] = {
"lib": target['lib'],
"requires": target.get('requires', []) + libsystemd(),
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
}

if not self.options.secure:
components.update({
"grpc_unsecure": {
"lib": "grpc_unsecure",
"requires": [
"address_sorting", "gpr", "upb", "abseil::absl_flat_hash_map",
"abseil::absl_inlined_vector", "abseil::absl_statusor",
"c-ares::cares", "re2::re2", "zlib::zlib",
"abseil::absl_random_random",
],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
"frameworks": corefoundation(),
},
"grpc++_unsecure": {
"lib": "grpc++_unsecure",
"requires": ["grpc_unsecure", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
})

if self.options.codegen:
components.update({
"grpc++_reflection": {
"lib": "grpc++_reflection",
"requires": ["grpc++", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
"grpcpp_channelz": {
"lib": "grpcpp_channelz",
"requires": ["grpc++", "protobuf::libprotobuf"],
"system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(),
},
})
"frameworks": target.get('frameworks', []),
}

return components

Expand Down Expand Up @@ -433,9 +349,11 @@
# Executable imported targets are added through custom CMake module files,
# since conan generators don't know how to emulate these kind of targets.
grpc_modules = []
for plugin_option, values in self._grpc_plugins.items():
if self.options.get_safe(plugin_option):
grpc_module_filename = "{}.cmake".format(values["executable"])
for plugin_info in self.target_info["grpc_plugins"]:
executable = plugin_info["executable"]
option_name = executable.replace("grpc_", "")
if self.options.get_safe(option_name):
grpc_module_filename = "{}.cmake".format(executable)
grpc_modules.append(os.path.join(self._module_path, grpc_module_filename))
self.cpp_info.set_property("cmake_build_modules", grpc_modules)

Expand All @@ -446,5 +364,4 @@
if grpc_modules:
self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package"] = grpc_modules
self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package_multi"] = grpc_modules
if any(self.options.get_safe(plugin_option) for plugin_option in self._grpc_plugins.keys()):
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
39 changes: 0 additions & 39 deletions recipes/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch

This file was deleted.

Loading
Loading