Skip to content

Commit

Permalink
Merge pull request #1313 from gocarlos/feat--add-cn-cbor
Browse files Browse the repository at this point in the history
add cn-cbor/1.0.0
  • Loading branch information
danimtb authored Apr 14, 2020
2 parents 056341c + 63df96e commit bd29036
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/cn-cbor/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
5 changes: 5 additions & 0 deletions recipes/cn-cbor/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
"1.0.0":
sha256: eca2bcc15b8400037fd95748724287afbb966e34d4d0275a496b4872bcea9d77
url: https://github.com/jimsch/cn-cbor/archive/1.0.0.zip

83 changes: 83 additions & 0 deletions recipes/cn-cbor/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 9 additions & 0 deletions recipes/cn-cbor/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions recipes/cn-cbor/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions recipes/cn-cbor/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "cn-cbor/cn-cbor.h"
#include <stdio.h>

#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;
}
4 changes: 4 additions & 0 deletions recipes/cn-cbor/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"1.0.0":
folder: "all"

0 comments on commit bd29036

Please sign in to comment.