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..36c49a5492539 --- /dev/null +++ b/recipes/cn-cbor/all/conandata.yml @@ -0,0 +1,5 @@ +sources: + "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 new file mode 100644 index 0000000000000..ffb0e3a88f745 --- /dev/null +++ b/recipes/cn-cbor/all/conanfile.py @@ -0,0 +1,83 @@ +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", "nodes", "messaging") + 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 + + 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 + "-" + self.version + 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.definitions["build_docs"] = 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=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) + if 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..8f50af2b049ed --- /dev/null +++ b/recipes/cn-cbor/config.yml @@ -0,0 +1,4 @@ +--- +versions: + "1.0.0": + folder: "all"