Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cn-cbor/1.0.0 #1313

Merged
merged 7 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
4 changes: 4 additions & 0 deletions recipes/cn-cbor/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200326":
uilianries marked this conversation as resolved.
Show resolved Hide resolved
sha256: 7cc228a7ac56494f95b74dcf94c254f920aada736793cdf647f9a644f6c67c66
url: https://github.com/jimsch/cn-cbor/archive/e2b410487ab76a1b9ee639716c01622290a46dcb.zip
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
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 + "-" + 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
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
self._cmake.definitions["build_docs"] = False

self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def build(self):
cmake = self._configure_cmake()
uilianries marked this conversation as resolved.
Show resolved Hide resolved
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"]
uilianries marked this conversation as resolved.
Show resolved Hide resolved
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:
"20200326":
folder: "all"