diff --git a/recipes/asio-grpc/all/conandata.yml b/recipes/asio-grpc/all/conandata.yml index fceefbebebc47..82e6288a3b1b7 100644 --- a/recipes/asio-grpc/all/conandata.yml +++ b/recipes/asio-grpc/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.2.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v3.2.0.tar.gz" + sha256: "f281e84202cf75aae055d67c4200b794f240cd7bd9ff8ecc3f9670a8912edf4f" "2.9.2": url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.9.2.tar.gz" sha256: "a025587278b3332f4c5dd0464b3d5313fbecb89fc58a6ec1d611f693d6b51ef2" diff --git a/recipes/asio-grpc/all/conanfile.py b/recipes/asio-grpc/all/conanfile.py index c686e567d9288..19e1514deae2c 100644 --- a/recipes/asio-grpc/all/conanfile.py +++ b/recipes/asio-grpc/all/conanfile.py @@ -21,11 +21,11 @@ class AsioGrpcConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = { "backend": ["boost", "asio", "unifex"], - "local_allocator": ["auto", "memory_resource", "boost_container", "recycling_allocator"], + "local_allocator": ["memory_resource", "boost_container", "recycling_allocator"], } default_options = { "backend": "boost", - "local_allocator": "auto", + # local_allocator default handled in config_options } no_copy_source = True @@ -43,30 +43,37 @@ def _compilers_minimum_version(self): "apple-clang": "11", } - def configure(self): - self._local_allocator_option = self.options.local_allocator - if self._local_allocator_option == "auto": + def config_options(self): + if Version(self.version) >= "3.0.0": + del self.options.local_allocator + else: 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" - 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.") + (self.settings.compiler == "gcc" and compiler_version < "9") or \ + (self.settings.compiler == "clang" and compiler_version < "12" and libcxx and str(libcxx) == "libstdc++") + self.options.local_allocator = "boost_container" if prefer_boost_container else "memory_resource" 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("boost/1.83.0", transitive_headers=True) + use_latest = Version(self.version) > "2.8" + self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) + if (self.options.get_safe("local_allocator") == "boost_container" and Version(self.version) < "3.0.0") or self.options.backend == "boost": + version = "1.86.0" if use_latest else "1.83.0" + self.requires(f"boost/{version}", transitive_headers=True) if self.options.backend == "asio": - self.requires("asio/1.29.0", transitive_headers=True) + version = "1.31.0" if use_latest else "1.29.0" + self.requires(f"asio/{version}", 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): + local_allocator = None + if "local_allocator" in self.info.options: + local_allocator = self.info.options.local_allocator self.info.clear() - self.info.options.local_allocator = self._local_allocator_option + if local_allocator is not None: + # Keep the local_allocator option in the package_id + self.info.options.local_allocator = local_allocator def layout(self): cmake_layout(self, src_folder="src") @@ -81,22 +88,21 @@ def validate(self): raise ConanInvalidConfiguration( f"{self.name} requires C++{self._min_cppstd}, which your compiler does not support." ) - else: - self.output.warning( - f"{self.name} requires C++{self._min_cppstd}. Your compiler is unknown. Assuming it supports" - f" C++{self._min_cppstd}." - ) if Version(self.version) == "2.7.0" and self.settings.compiler == "gcc" and compiler_version.major == "11" and \ - compiler_version < "11.3": + compiler_version < "11.3": raise ConanInvalidConfiguration(f"{self.ref} does not support gcc 11.0-11.2") + if self.options.get_safe("local_allocator") == "recycling_allocator" and self.options.backend == "unifex": + raise ConanInvalidConfiguration(f'{self.name} -o="&:local_allocator=recycling_allocator" cannot be used in combination with the -o="&:backend=unifex" backend.') + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) 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.options.get_safe("local_allocator") == "boost_container" + tc.variables["ASIO_GRPC_USE_RECYCLING_ALLOCATOR"] = self.options.get_safe("local_allocator") == "recycling_allocator" tc.generate() def build(self): @@ -115,7 +121,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") @@ -126,7 +132,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.options.get_safe("local_allocator") == "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") diff --git a/recipes/asio-grpc/all/test_package/CMakeLists.txt b/recipes/asio-grpc/all/test_package/CMakeLists.txt index 3566d527f1ca9..c63f764daa261 100644 --- a/recipes/asio-grpc/all/test_package/CMakeLists.txt +++ b/recipes/asio-grpc/all/test_package/CMakeLists.txt @@ -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() diff --git a/recipes/asio-grpc/all/test_package/test_package.cpp b/recipes/asio-grpc/all/test_package/test_package.cpp index b784be03686dc..6b7094c7b7c60 100644 --- a/recipes/asio-grpc/all/test_package/test_package.cpp +++ b/recipes/asio-grpc/all/test_package/test_package.cpp @@ -16,21 +16,10 @@ int main() { boost::asio::post(grpc_context, [] {}); #ifndef CROSSCOMPILING - std::unique_ptr stub; - grpc::ClientContext client_context; - std::unique_ptr> 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 } diff --git a/recipes/asio-grpc/config.yml b/recipes/asio-grpc/config.yml index b9f64d2363051..e5e2925fb424e 100644 --- a/recipes/asio-grpc/config.yml +++ b/recipes/asio-grpc/config.yml @@ -1,4 +1,6 @@ versions: + "3.2.0": + folder: all "2.9.2": folder: all "2.7.0":