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

feat: add initial libcoap #929

Merged
merged 30 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ad96cd7
feat: add initial libcoap
gocarlos Feb 20, 2020
7bd0fa5
chore: add some code to libcoap test package
gocarlos Feb 20, 2020
69ab89a
chore: add support for tls lib
gocarlos Feb 20, 2020
2ddc51c
chore: simplify recipe
gocarlos Feb 27, 2020
e9b988f
chore: patch openssl stuff
gocarlos Mar 23, 2020
0c517eb
fix: test package
gocarlos Mar 23, 2020
ad5f4bb
fix: path to license
gocarlos Mar 23, 2020
47f678f
chore: bump version
gocarlos Apr 24, 2020
0015c81
chore: use dtls_backend
gocarlos Apr 24, 2020
a027ad3
chore: rename to dtls_backend
gocarlos Apr 24, 2020
d1931ef
fix: conan exceptions
gocarlos Apr 26, 2020
822dab5
remove support for windows and mac
gocarlos Apr 26, 2020
ed57604
Update recipes/libcoap/all/conanfile.py
gocarlos Apr 27, 2020
ca1f675
Update recipes/libcoap/all/conanfile.py
gocarlos Apr 28, 2020
efac372
Update recipes/libcoap/all/conanfile.py
gocarlos May 1, 2020
5305607
fix: pkgconfig
gocarlos Jun 13, 2020
f76707c
style: fix new hooks
gocarlos Jun 13, 2020
582cfbd
style: fix new hooks
gocarlos Jun 13, 2020
ac6e219
Update recipes/libcoap/all/conanfile.py
gocarlos Jul 7, 2020
5f55700
Update conandata.yml
gocarlos Aug 23, 2020
0db20ff
Update config.yml
gocarlos Aug 23, 2020
f1ae576
Update CMakeLists.txt
gocarlos Aug 23, 2020
940d478
Update CMakeLists.txt
gocarlos Aug 23, 2020
c785fda
Update conanfile.py
gocarlos Aug 24, 2020
c3ea065
Update recipes/libcoap/all/conanfile.py
gocarlos Aug 26, 2020
8809346
Update recipes/libcoap/all/conanfile.py
gocarlos Aug 26, 2020
a917a60
Update recipes/libcoap/all/conanfile.py
gocarlos Aug 26, 2020
62074c0
Update recipes/libcoap/all/conanfile.py
gocarlos Aug 27, 2020
13d1458
Apply suggestions from code review
gocarlos Sep 23, 2020
7feb798
Apply suggestions from code review
gocarlos Sep 29, 2020
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/libcoap/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/libcoap/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200220":
sha256: ace3be84bfdf0e31e892bfaeaf442d5062d590a533fc39f64c2ef96549c614bc
url: https://github.com/gocarlos/libcoap/archive/21ea160d0f4aa832e2d545fce39ea9b60d0b8c12.zip
100 changes: 100 additions & 0 deletions recipes/libcoap/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import os
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration


class LibCoapConan(ConanFile):
name = "libcoap"
license = "BSD-2-Clause"
homepage = "https://github.com/gocarlos/libcoap/"
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
url = "https://github.com/conan-io/conan-center-index"
description = """A CoAP (RFC 7252) implementation in C"""
topics = ("coap")
exports_sources = "CMakeLists.txt"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"enable_dtls": [True, False],
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
"with_openssl": [True, False],
"with_gnutls": [True, False],
"with_tinydtls": [True, False],
"with_mbedtls": [True, False],
"with_epoll": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"enable_dtls": True,
"with_openssl": True,
"with_gnutls": False,
"with_tinydtls": False,
"with_mbedtls": False,
"with_epoll": False,
}
generators = "cmake", "cmake_find_package"

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def requirements(self):
if self.options.enable_dtls and self.options.with_openssl:
self.requires.add("openssl/1.1.1d")
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
if self.options.enable_dtls and self.options.with_mbedtls:
self.requires.add("mbedtls/2.16.3-apache")
if self.options.enable_dtls and self.options.with_gnutls:
raise ConanInvalidConfiguration("gnu tls not available yet")
if self.options.enable_dtls and self.options.with_tinydtls:
raise ConanInvalidConfiguration("tinydtls not available yet")

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["ENABLE_DTLS"] = self.options.enable_dtls
self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl
self._cmake.definitions["WITH_GNUTLS"] = self.options.with_gnutls
self._cmake.definitions["WITH_TINYDTLS"] = self.options.with_tinydtls
self._cmake.definitions["WITH_EPOLL"] = self.options.with_epoll
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()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder,
"lib", "libcoap", "cmake"))
gocarlos marked this conversation as resolved.
Show resolved Hide resolved

def package_info(self):
self.cpp_info.libs = ["coap"]
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
11 changes: 11 additions & 0 deletions recipes/libcoap/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
18 changes: 18 additions & 0 deletions recipes/libcoap/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"
gocarlos marked this conversation as resolved.
Show resolved Hide resolved

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)
13 changes: 13 additions & 0 deletions recipes/libcoap/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "coap2/coap.h"

int main(int argc, char *argv[]) {
coap_startup();

// create CoAP context and a client session
coap_context_t *ctx = coap_new_context(nullptr);

coap_free_context(ctx);
coap_cleanup();

return 0;
}
4 changes: 4 additions & 0 deletions recipes/libcoap/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"20200220":
folder: "all"