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

asio-grpc: add version 3.2.0 #22910

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions recipes/asio-grpc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"3.1.0":
url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v3.1.0.tar.gz"
sha256: "b5d9440dad653dcb9e5ac82cb9c4f6d01a33bc30bba996d9647f38258cbe75ee"
"2.9.2":
url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.9.2.tar.gz"
sha256: "a025587278b3332f4c5dd0464b3d5313fbecb89fc58a6ec1d611f693d6b51ef2"
Expand Down
24 changes: 15 additions & 9 deletions recipes/asio-grpc/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,35 @@
"apple-clang": "11",
}

def config_options(self):
if Version(self.version) >= "3.0.0":
del self.options.local_allocator

def configure(self):
self._local_allocator_option = self.options.local_allocator
self._local_allocator_option = self.options.get_safe("local_allocator")

Check warning on line 51 in recipes/asio-grpc/all/conanfile.py

View workflow job for this annotation

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

Attribute '_local_allocator_option' defined outside __init__
if self._local_allocator_option == "auto":
libcxx = self.settings.compiler.get_safe("libcxx")
compiler_version = Version(self.settings.compiler.version)
prefer_boost_container = libcxx and str(libcxx) == "libc++" or \
(self.settings.compiler == "gcc" and compiler_version < "9") or \
(self.settings.compiler == "clang" and compiler_version < "12" and libcxx and str(libcxx) == "libstdc++")
self._local_allocator_option = "boost_container" if prefer_boost_container else "memory_resource"

Check warning on line 58 in recipes/asio-grpc/all/conanfile.py

View workflow job for this annotation

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

Attribute '_local_allocator_option' defined outside __init__
if self._local_allocator_option == "recycling_allocator" and self.options.backend == "unifex":
raise ConanInvalidConfiguration(f"{self.name} 'recycling_allocator' cannot be used in combination with the 'unifex' backend.")

def requirements(self):
self.requires("grpc/1.54.3", transitive_libs=True)
if self._local_allocator_option == "boost_container" or self.options.backend == "boost":
self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True)
if (self._local_allocator_option == "boost_container" and Version(self.version) < "3.0.0") or self.options.backend == "boost":
self.requires("boost/1.83.0", transitive_headers=True)
if self.options.backend == "asio":
self.requires("asio/1.29.0", transitive_headers=True)
if self.options.backend == "unifex":
self.requires("libunifex/0.4.0")
self.requires("libunifex/0.4.0", transitive_headers=True, transitive_libs=True)

def package_id(self):
self.info.clear()
self.info.options.local_allocator = self._local_allocator_option
if self._local_allocator_option:
self.info.options.local_allocator = self._local_allocator_option
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def layout(self):
cmake_layout(self, src_folder="src")
Expand Down Expand Up @@ -95,8 +100,9 @@

def generate(self):
tc = CMakeToolchain(self)
tc.variables["ASIO_GRPC_USE_BOOST_CONTAINER"] = self._local_allocator_option == "boost_container"
tc.variables["ASIO_GRPC_USE_RECYCLING_ALLOCATOR"] = self._local_allocator_option == "recycling_allocator"
if Version(self.version) < "3.0.0":
tc.variables["ASIO_GRPC_USE_BOOST_CONTAINER"] = self._local_allocator_option == "boost_container"
tc.variables["ASIO_GRPC_USE_RECYCLING_ALLOCATOR"] = self._local_allocator_option == "recycling_allocator"
tc.generate()

def build(self):
Expand All @@ -115,7 +121,7 @@

build_modules = [os.path.join("lib", "cmake", "asio-grpc", "AsioGrpcProtobufGenerator.cmake")]

self.cpp_info.requires = ["grpc::grpc++_unsecure"]
self.cpp_info.requires = ["grpc::grpc++"]
if self.options.backend == "boost":
self.cpp_info.defines = ["AGRPC_BOOST_ASIO"]
self.cpp_info.requires.append("boost::headers")
Expand All @@ -126,7 +132,7 @@
self.cpp_info.defines = ["AGRPC_UNIFEX"]
self.cpp_info.requires.append("libunifex::unifex")

if self._local_allocator_option == "boost_container":
if self._local_allocator_option == "boost_container" and Version(self.version) < "3.0.0":
self.cpp_info.requires.append("boost::container")

self.cpp_info.set_property("cmake_file_name", "asio-grpc")
Expand Down
4 changes: 0 additions & 4 deletions recipes/asio-grpc/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE asio-grpc::asio-grpc)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

# See https://github.com/chriskohlhoff/asio/issues/955
target_compile_definitions(${PROJECT_NAME}
PRIVATE BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC)

if(${asio-grpc_VERSION} VERSION_GREATER_EQUAL 2)
target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_GRPC_V2)
endif()
Expand Down
17 changes: 3 additions & 14 deletions recipes/asio-grpc/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,10 @@ int main() {
boost::asio::post(grpc_context, [] {});

#ifndef CROSSCOMPILING
std::unique_ptr<test::Test::Stub> stub;
grpc::ClientContext client_context;
std::unique_ptr<grpc::ClientAsyncResponseReader<test::TestReply>> reader;
test::TestRequest request;
test::TestReply response;
grpc::Status status;

boost::asio::post(grpc_context, [&]() {
stub = test::Test::NewStub(grpc::CreateChannel(
boost::asio::post(grpc_context, []() {
[[maybe_unused]] auto stub = test::Test::NewStub(grpc::CreateChannel(
"localhost:50051", grpc::InsecureChannelCredentials()));
request.set_message("hello");
reader = agrpc::request(&test::Test::Stub::AsyncUnary, *stub,
client_context, request, grpc_context);
agrpc::finish(reader, response, status,
boost::asio::bind_executor(grpc_context, [](bool) {}));
[[maybe_unused]] test::TestRequest request;
});
#endif
}
2 changes: 2 additions & 0 deletions recipes/asio-grpc/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"3.1.0":
folder: all
"2.9.2":
folder: all
"2.7.0":
Expand Down
Loading