From eed689c2c6bf1409bd5b8e9238947a8160711128 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Fri, 1 Jul 2022 13:04:01 +0800 Subject: [PATCH 1/8] modern-cpp-kafka: new recipe --- recipes/modern-cpp-kafka/all/conandata.yml | 4 ++ recipes/modern-cpp-kafka/all/conanfile.py | 38 +++++++++++++++++++ .../all/test_package/CMakeLists.txt | 10 +++++ .../all/test_package/conanfile.py | 19 ++++++++++ .../all/test_package/test_package.cpp | 8 ++++ recipes/modern-cpp-kafka/config.yml | 3 ++ 6 files changed, 82 insertions(+) create mode 100644 recipes/modern-cpp-kafka/all/conandata.yml create mode 100644 recipes/modern-cpp-kafka/all/conanfile.py create mode 100644 recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt create mode 100644 recipes/modern-cpp-kafka/all/test_package/conanfile.py create mode 100644 recipes/modern-cpp-kafka/all/test_package/test_package.cpp create mode 100644 recipes/modern-cpp-kafka/config.yml diff --git a/recipes/modern-cpp-kafka/all/conandata.yml b/recipes/modern-cpp-kafka/all/conandata.yml new file mode 100644 index 0000000000000..3a94bd663e381 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2022.06.15": + url: https://github.com/morganstanley/modern-cpp-kafka/archive/refs/tags/v2022.06.15.tar.gz + sha256: 478fcf560057b7cf7b4be851838ebf0520806d057b172de23261606fce088d27 diff --git a/recipes/modern-cpp-kafka/all/conanfile.py b/recipes/modern-cpp-kafka/all/conanfile.py new file mode 100644 index 0000000000000..b147d6b4e0abc --- /dev/null +++ b/recipes/modern-cpp-kafka/all/conanfile.py @@ -0,0 +1,38 @@ +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.33.0" + + +class ModernCppKafkaConan(ConanFile): + name = "modern-cpp-kafka" + description = "A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)" + license = "Apache License 2.0" + topics = ("kafka", "librdkafka", "kafkaproducer", "kafkaconsumer") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/morganstanley/modern-cpp-kafka" + settings = "arch", "build_type", "compiler", "os" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.set_property("cmake_target_name", "ModernCppKafka::ModernCppKafka") + + self.cpp_info.names["cmake_find_package"] = "ModernCppKafka" + self.cpp_info.names["cmake_find_package_multi"] = "ModernCppKafka" + + if self.settings.os in ["Linux", "Macos"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f27d98d0d5855 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(RdKafka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py new file mode 100644 index 0000000000000..44ae7560745c3 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def requirements(self): + self.requires("librdkafka/1.8.2") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/modern-cpp-kafka/all/test_package/test_package.cpp b/recipes/modern-cpp-kafka/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b9fb4f0bea6d8 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include "kafka/Utility.h" + +#include + +int main() +{ + std::cout << "librdkafka version: " << kafka::utility::getLibRdKafkaVersion() << std::endl; +} diff --git a/recipes/modern-cpp-kafka/config.yml b/recipes/modern-cpp-kafka/config.yml new file mode 100644 index 0000000000000..191f269934ad8 --- /dev/null +++ b/recipes/modern-cpp-kafka/config.yml @@ -0,0 +1,3 @@ +versions: + "2022.06.15": + folder: all From 01a8503a83f691bc24593e800b8297193e309cb1 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:00:29 +0800 Subject: [PATCH 2/8] Apply suggestions from code review Co-authored-by: Uilian Ries --- recipes/modern-cpp-kafka/all/conanfile.py | 2 +- recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/modern-cpp-kafka/all/conanfile.py b/recipes/modern-cpp-kafka/all/conanfile.py index b147d6b4e0abc..30cadbc48bf97 100644 --- a/recipes/modern-cpp-kafka/all/conanfile.py +++ b/recipes/modern-cpp-kafka/all/conanfile.py @@ -23,7 +23,7 @@ def source(self): def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) def package_id(self): self.info.header_only() diff --git a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt index f27d98d0d5855..93439fecd8099 100644 --- a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt +++ b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt @@ -5,6 +5,7 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() find_package(RdKafka REQUIRED CONFIG) +find_package(ModernCppKafka REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka) +target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka ModernCppKafka::ModernCppKafka) From 6b8c0e8f93ece0b9c4224d21451a639ee65e17a3 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Tue, 5 Jul 2022 15:24:14 +0800 Subject: [PATCH 3/8] Update recipes/modern-cpp-kafka/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/modern-cpp-kafka/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/modern-cpp-kafka/all/conanfile.py b/recipes/modern-cpp-kafka/all/conanfile.py index 30cadbc48bf97..59c31e9eeaf29 100644 --- a/recipes/modern-cpp-kafka/all/conanfile.py +++ b/recipes/modern-cpp-kafka/all/conanfile.py @@ -7,7 +7,7 @@ class ModernCppKafkaConan(ConanFile): name = "modern-cpp-kafka" description = "A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)" - license = "Apache License 2.0" + license = "Apache-2.0" topics = ("kafka", "librdkafka", "kafkaproducer", "kafkaconsumer") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/morganstanley/modern-cpp-kafka" From 3fc99027fc557dcfcf03ab5be763c6d41e10657c Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Tue, 12 Jul 2022 13:32:41 +0800 Subject: [PATCH 4/8] modern-cpp-kafka: new recipe -- build test with c++17 --- recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt index 93439fecd8099..61b6b4a34dbe8 100644 --- a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt +++ b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt @@ -4,6 +4,8 @@ project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() +set(CMAKE_CXX_STANDARD 17) + find_package(RdKafka REQUIRED CONFIG) find_package(ModernCppKafka REQUIRED CONFIG) From 1396f749dc7f2fff7c6ed69b4abdfbed757b465a Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:45:04 +0800 Subject: [PATCH 5/8] modern-cpp-kafka: update the requirements & validate, fix the text --- recipes/modern-cpp-kafka/all/conanfile.py | 7 +++++++ recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt | 3 +-- recipes/modern-cpp-kafka/all/test_package/conanfile.py | 6 ++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/recipes/modern-cpp-kafka/all/conanfile.py b/recipes/modern-cpp-kafka/all/conanfile.py index 59c31e9eeaf29..eebf2c5395b60 100644 --- a/recipes/modern-cpp-kafka/all/conanfile.py +++ b/recipes/modern-cpp-kafka/all/conanfile.py @@ -14,6 +14,9 @@ class ModernCppKafkaConan(ConanFile): settings = "arch", "build_type", "compiler", "os" no_copy_source = True + def requirements(self): + self.requires("librdkafka/1.8.2") + @property def _source_subfolder(self): return "source_subfolder" @@ -21,6 +24,10 @@ def _source_subfolder(self): def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) diff --git a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt index 61b6b4a34dbe8..0d36924d633da 100644 --- a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt +++ b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt @@ -6,8 +6,7 @@ conan_basic_setup() set(CMAKE_CXX_STANDARD 17) -find_package(RdKafka REQUIRED CONFIG) find_package(ModernCppKafka REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka ModernCppKafka::ModernCppKafka) +target_link_libraries(${PROJECT_NAME} ModernCppKafka::ModernCppKafka) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py index 44ae7560745c3..74b89721f768c 100644 --- a/recipes/modern-cpp-kafka/all/test_package/conanfile.py +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -1,3 +1,4 @@ +# pylint: skip-file from conans import ConanFile, CMake, tools import os @@ -5,15 +6,12 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" - def requirements(self): - self.requires("librdkafka/1.8.2") - def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self): + if not tools.cross_building(self.settings): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) From f5c2989fe76506745abc218916897f3836f6f7a4 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Wed, 20 Jul 2022 22:32:38 +0800 Subject: [PATCH 6/8] Update recipes/modern-cpp-kafka/all/test_package/conanfile.py Co-authored-by: Javier G. Sogo --- recipes/modern-cpp-kafka/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py index 74b89721f768c..6e5f761d818ff 100644 --- a/recipes/modern-cpp-kafka/all/test_package/conanfile.py +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) From 49a5db37b4a8a788fa031a6d013d8f42f6a44aed Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Wed, 20 Jul 2022 22:32:50 +0800 Subject: [PATCH 7/8] Update recipes/modern-cpp-kafka/all/test_package/conanfile.py Co-authored-by: Javier G. Sogo --- recipes/modern-cpp-kafka/all/test_package/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py index 6e5f761d818ff..8fac75d4dd693 100644 --- a/recipes/modern-cpp-kafka/all/test_package/conanfile.py +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -1,5 +1,6 @@ # pylint: skip-file -from conans import ConanFile, CMake, tools +from conans import ConanFile, CMake +from conan.tools.build import cross_building import os class TestPackageConan(ConanFile): From acac5710be98e23a6fa34d062abc147dfa7370d1 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Wed, 20 Jul 2022 22:52:50 +0800 Subject: [PATCH 8/8] Update recipes/modern-cpp-kafka/all/test_package/conanfile.py Co-authored-by: Javier G. Sogo --- recipes/modern-cpp-kafka/all/test_package/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py index 8fac75d4dd693..81a08015e01f1 100644 --- a/recipes/modern-cpp-kafka/all/test_package/conanfile.py +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -1,4 +1,3 @@ -# pylint: skip-file from conans import ConanFile, CMake from conan.tools.build import cross_building import os