Skip to content

Commit

Permalink
asio-grpc: Add version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed May 23, 2024
1 parent 653cc79 commit 2123628
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
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.0.0":
url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v3.0.0.tar.gz"
sha256: "299b937cba0b515e7505840ffb891ce8745879365cd918635401f19bf4886591"
"2.9.2":
url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.9.2.tar.gz"
sha256: "a025587278b3332f4c5dd0464b3d5313fbecb89fc58a6ec1d611f693d6b51ef2"
Expand Down
20 changes: 11 additions & 9 deletions recipes/asio-grpc/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,22 @@ def configure(self):
(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 54 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":
if self._local_allocator_option == "recycling_allocator" and self.options.backend == "unifex" and Version(self.version) < "3.0.0":
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 Version(self.version) < "3.0.0":
self.info.options.local_allocator = self._local_allocator_option

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

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 +117,7 @@ def package_info(self):

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 +128,7 @@ def package_info(self):
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.0.0":
folder: all
"2.9.2":
folder: all
"2.7.0":
Expand Down

0 comments on commit 2123628

Please sign in to comment.