From 07394b313d8a1e187aeec6fbccb99445e8466fee Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 8 Apr 2020 14:08:48 +0200 Subject: [PATCH 1/7] feat: add cn-cbor to cci --- recipes/cn-cbor/all/CMakeLists.txt | 7 ++ recipes/cn-cbor/all/conandata.yml | 4 ++ recipes/cn-cbor/all/conanfile.py | 70 +++++++++++++++++++ .../cn-cbor/all/test_package/CMakeLists.txt | 9 +++ recipes/cn-cbor/all/test_package/conanfile.py | 18 +++++ .../cn-cbor/all/test_package/test_package.cpp | 21 ++++++ recipes/cn-cbor/config.yml | 4 ++ 7 files changed, 133 insertions(+) create mode 100644 recipes/cn-cbor/all/CMakeLists.txt create mode 100644 recipes/cn-cbor/all/conandata.yml create mode 100644 recipes/cn-cbor/all/conanfile.py create mode 100644 recipes/cn-cbor/all/test_package/CMakeLists.txt create mode 100644 recipes/cn-cbor/all/test_package/conanfile.py create mode 100644 recipes/cn-cbor/all/test_package/test_package.cpp create mode 100644 recipes/cn-cbor/config.yml diff --git a/recipes/cn-cbor/all/CMakeLists.txt b/recipes/cn-cbor/all/CMakeLists.txt new file mode 100644 index 0000000000000..361b35d4c17d9 --- /dev/null +++ b/recipes/cn-cbor/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/cn-cbor/all/conandata.yml b/recipes/cn-cbor/all/conandata.yml new file mode 100644 index 0000000000000..55480b17bdb7e --- /dev/null +++ b/recipes/cn-cbor/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "20200326": + sha256: 7cc228a7ac56494f95b74dcf94c254f920aada736793cdf647f9a644f6c67c66 + url: https://github.com/jimsch/cn-cbor/archive/e2b410487ab76a1b9ee639716c01622290a46dcb.zip diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py new file mode 100644 index 0000000000000..a6e427885367d --- /dev/null +++ b/recipes/cn-cbor/all/conanfile.py @@ -0,0 +1,70 @@ +import os +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +class CnCborStackConan(ConanFile): + name = "cn-cbor" + license = "MIT" + homepage = "https://github.com/jimsch/cn-cbor/" + url = "https://github.com/conan-io/conan-center-index" + description = """A constrained node implementation of CBOR in C""" + topics = ("cbor") + exports_sources = ['CMakeLists.txt'] + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True + } + generators = "cmake", "cmake_find_package" + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0] + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["fatal_warnings"] = False + self._cmake.definitions["coveralls"] = False + self._cmake.definitions["build_tests"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst='licenses', src=os.path.join(self._source_subfolder, "license")) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32"] diff --git a/recipes/cn-cbor/all/test_package/CMakeLists.txt b/recipes/cn-cbor/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e3410dbe322b9 --- /dev/null +++ b/recipes/cn-cbor/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/cn-cbor/all/test_package/conanfile.py b/recipes/cn-cbor/all/test_package/conanfile.py new file mode 100644 index 0000000000000..933dbf96533ae --- /dev/null +++ b/recipes/cn-cbor/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + bin_path = self.run(bin_path, run_environment=True) diff --git a/recipes/cn-cbor/all/test_package/test_package.cpp b/recipes/cn-cbor/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2a95866542cb3 --- /dev/null +++ b/recipes/cn-cbor/all/test_package/test_package.cpp @@ -0,0 +1,21 @@ +#include "cn-cbor/cn-cbor.h" +#include + +#ifdef USE_CBOR_CONTEXT +#define CBOR_CONTEXT_PARAM , NULL +#else +#define CBOR_CONTEXT_PARAM +#endif + +int main(int argc, char *argv[]) { + + struct cn_cbor_errback back; + const char *buf = "asdf"; + const int len = 4; + const cn_cbor *ret = cn_cbor_decode((const uint8_t *)buf, len CBOR_CONTEXT_PARAM, &back); + if (ret) { + printf("oops 1"); + } + + return 0; +} \ No newline at end of file diff --git a/recipes/cn-cbor/config.yml b/recipes/cn-cbor/config.yml new file mode 100644 index 0000000000000..75813c4027094 --- /dev/null +++ b/recipes/cn-cbor/config.yml @@ -0,0 +1,4 @@ +--- +versions: + "20200326": + folder: "all" From 4f749d557da6c3c268964be602ba4584d773a3d9 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 8 Apr 2020 14:11:41 +0200 Subject: [PATCH 2/7] chore: fix typos --- recipes/cn-cbor/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index a6e427885367d..21a6255eabad8 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -66,5 +66,5 @@ def package(self): def package_info(self): self.cpp_info.libs = tools.collect_libs(self) - elif self.settings.os == "Windows": + if self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] From c7f5b57c9040813fb4cfd77dded78d5230475ab5 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 8 Apr 2020 14:33:04 +0200 Subject: [PATCH 3/7] chore: remvoe cmake config stuff --- recipes/cn-cbor/all/conanfile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index 21a6255eabad8..a248355651d07 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -60,9 +60,15 @@ def build(self): cmake.build() def package(self): - self.copy("LICENSE", dst='licenses', src=os.path.join(self._source_subfolder, "license")) + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() + os.remove(os.path.join(self.package_folder, "README.md")) + os.remove(os.path.join(self.package_folder, "LICENSE")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, + "lib", "cn-cbor", "cmake")) def package_info(self): self.cpp_info.libs = tools.collect_libs(self) From 43d3a82c1dc481a060c5a1e06180d579ca7d2e98 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 8 Apr 2020 15:05:06 +0200 Subject: [PATCH 4/7] chore: prevent shared builds on windows --- recipes/cn-cbor/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index a248355651d07..0fee0482ed8f2 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -40,6 +40,9 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Windows shared builds are not supported right now") + def source(self): tools.get(**self.conan_data["sources"][self.version]) extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0] @@ -59,6 +62,8 @@ def build(self): cmake = self._configure_cmake() cmake.build() + + def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() From bc7f6f1854a7665a60398f3d14d314a035a48899 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 8 Apr 2020 16:31:20 +0200 Subject: [PATCH 5/7] Apply suggestions from code review Co-Authored-By: Uilian Ries --- recipes/cn-cbor/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index 0fee0482ed8f2..c59fec620d1e9 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -9,7 +9,7 @@ class CnCborStackConan(ConanFile): homepage = "https://github.com/jimsch/cn-cbor/" url = "https://github.com/conan-io/conan-center-index" description = """A constrained node implementation of CBOR in C""" - topics = ("cbor") + topics = ("cbor", "nodes", "messaging") exports_sources = ['CMakeLists.txt'] settings = "os", "compiler", "build_type", "arch" options = { @@ -55,6 +55,8 @@ def _configure_cmake(self): self._cmake.definitions["fatal_warnings"] = False self._cmake.definitions["coveralls"] = False self._cmake.definitions["build_tests"] = False + self._cmake.definitions["build_docs"] = False + self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From ca9be3ac83717d2ac15457fce390a7bbd0ce993f Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Thu, 9 Apr 2020 00:41:53 +0200 Subject: [PATCH 6/7] chore: bump cn-cbor --- recipes/cn-cbor/all/conandata.yml | 6 +++--- recipes/cn-cbor/config.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/cn-cbor/all/conandata.yml b/recipes/cn-cbor/all/conandata.yml index 55480b17bdb7e..43cbeb75a8d40 100644 --- a/recipes/cn-cbor/all/conandata.yml +++ b/recipes/cn-cbor/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "20200326": - sha256: 7cc228a7ac56494f95b74dcf94c254f920aada736793cdf647f9a644f6c67c66 - url: https://github.com/jimsch/cn-cbor/archive/e2b410487ab76a1b9ee639716c01622290a46dcb.zip + "20200409": + sha256: 5a5c827177bf5f1bd3b667630eacd02f363e726dfcdd4c49094f594f3bcb82d8 + url: https://github.com/jimsch/cn-cbor/archive/ff195453c9d62f0a30f2d64436c2d614a2278ba7.zip diff --git a/recipes/cn-cbor/config.yml b/recipes/cn-cbor/config.yml index 75813c4027094..082057a674ff4 100644 --- a/recipes/cn-cbor/config.yml +++ b/recipes/cn-cbor/config.yml @@ -1,4 +1,4 @@ --- versions: - "20200326": + "20200409": folder: "all" From 63df96e6a9a743895c0d67c3c311095ff249812b Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Thu, 9 Apr 2020 01:09:04 +0200 Subject: [PATCH 7/7] chore: change to use version --- recipes/cn-cbor/all/conandata.yml | 7 ++++--- recipes/cn-cbor/all/conanfile.py | 2 +- recipes/cn-cbor/config.yml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/recipes/cn-cbor/all/conandata.yml b/recipes/cn-cbor/all/conandata.yml index 43cbeb75a8d40..36c49a5492539 100644 --- a/recipes/cn-cbor/all/conandata.yml +++ b/recipes/cn-cbor/all/conandata.yml @@ -1,4 +1,5 @@ sources: - "20200409": - sha256: 5a5c827177bf5f1bd3b667630eacd02f363e726dfcdd4c49094f594f3bcb82d8 - url: https://github.com/jimsch/cn-cbor/archive/ff195453c9d62f0a30f2d64436c2d614a2278ba7.zip + "1.0.0": + sha256: eca2bcc15b8400037fd95748724287afbb966e34d4d0275a496b4872bcea9d77 + url: https://github.com/jimsch/cn-cbor/archive/1.0.0.zip + diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index c59fec620d1e9..ffb0e3a88f745 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -45,7 +45,7 @@ def configure(self): def source(self): tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0] + extracted_dir = self.name + "-" + self.version os.rename(extracted_dir, self._source_subfolder) def _configure_cmake(self): diff --git a/recipes/cn-cbor/config.yml b/recipes/cn-cbor/config.yml index 082057a674ff4..8f50af2b049ed 100644 --- a/recipes/cn-cbor/config.yml +++ b/recipes/cn-cbor/config.yml @@ -1,4 +1,4 @@ --- versions: - "20200409": + "1.0.0": folder: "all"