-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ad96cd7
feat: add initial libcoap
gocarlos 7bd0fa5
chore: add some code to libcoap test package
gocarlos 69ab89a
chore: add support for tls lib
gocarlos 2ddc51c
chore: simplify recipe
gocarlos e9b988f
chore: patch openssl stuff
gocarlos 0c517eb
fix: test package
gocarlos ad5f4bb
fix: path to license
gocarlos 47f678f
chore: bump version
gocarlos 0015c81
chore: use dtls_backend
gocarlos a027ad3
chore: rename to dtls_backend
gocarlos d1931ef
fix: conan exceptions
gocarlos 822dab5
remove support for windows and mac
gocarlos ed57604
Update recipes/libcoap/all/conanfile.py
gocarlos ca1f675
Update recipes/libcoap/all/conanfile.py
gocarlos efac372
Update recipes/libcoap/all/conanfile.py
gocarlos 5305607
fix: pkgconfig
gocarlos f76707c
style: fix new hooks
gocarlos 582cfbd
style: fix new hooks
gocarlos ac6e219
Update recipes/libcoap/all/conanfile.py
gocarlos 5f55700
Update conandata.yml
gocarlos 0db20ff
Update config.yml
gocarlos f1ae576
Update CMakeLists.txt
gocarlos 940d478
Update CMakeLists.txt
gocarlos c785fda
Update conanfile.py
gocarlos c3ea065
Update recipes/libcoap/all/conanfile.py
gocarlos 8809346
Update recipes/libcoap/all/conanfile.py
gocarlos a917a60
Update recipes/libcoap/all/conanfile.py
gocarlos 62074c0
Update recipes/libcoap/all/conanfile.py
gocarlos 13d1458
Apply suggestions from code review
gocarlos 7feb798
Apply suggestions from code review
gocarlos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20200424": | ||
sha256: 8402bf2dd9979d6d5f823a050cd3533619fe9b21e76be8c69a9b7d8b8ea175ab | ||
url: https://github.com/obgm/libcoap/archive/17957e1e687c2218b7752a8a959eac36dbf5cb62.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/obgm/libcoap" | ||
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], | ||
"with_epoll": [True, False], | ||
"dtls_backend": [None, "openssl", "gnutls", "tinydtls", "mbedtls"], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_epoll": False, | ||
"dtls_backend": "openssl", | ||
} | ||
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.dtls_backend == "openssl": | ||
self.requires("openssl/1.1.1h") | ||
elif self.options.dtls_backend == "mbedtls": | ||
self.requires("mbedtls/2.16.3-apache") | ||
elif self.options.dtls_backend == "gnutls": | ||
raise ConanInvalidConfiguration("gnu tls not available yet") | ||
elif self.options.dtls_backend == "tinydtls": | ||
raise ConanInvalidConfiguration("tinydtls not available yet") | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.settings.os in ("Windows", "Macos"): | ||
raise ConanInvalidConfiguration("Platform is currently not supported") | ||
if self.options.shared: | ||
del self.options.fPIC | ||
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["WITH_EPOLL"] = self.options.with_epoll | ||
self._cmake.definitions["ENABLE_DTLS"] = self.options.dtls_backend != None | ||
self._cmake.definitions["DTLS_BACKEND"] = self.options.dtls_backend | ||
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", src=self._source_subfolder, dst="licenses") | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def package_info(self): | ||
pkgconfig_filename = "libcoap-2{}".format("-{}".format(self.options.dtls_backend) if self.options.dtls_backend else "") | ||
self.cpp_info.names["pkg_config"] = pkgconfig_filename | ||
self.cpp_info.components["coap"].names["cmake_find_package"] = "coap" | ||
self.cpp_info.components["coap"].names["cmake_find_package_multi"] = "coap" | ||
self.cpp_info.components["coap"].names["pkg_config"] = pkgconfig_filename | ||
self.cpp_info.components["coap"].libs = ["coap"] | ||
if self.settings.os == "Linux": | ||
self.cpp_info.components["coap"].system_libs = ["pthread"] | ||
gocarlos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if self.options.dtls_backend == "openssl": | ||
self.cpp_info.components["coap"].requires = ["openssl::openssl"] | ||
elif self.options.dtls_backend == "mbedtls": | ||
self.cpp_info.components["coap"].requires = ["mbedtls::mbedtls"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
find_package(libcoap REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} libcoap::coap) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class TestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "coap2/coap.h" | ||
#include <iostream> | ||
|
||
int main() { | ||
std::cout << "starting" << std::endl; | ||
coap_startup(); | ||
|
||
// create CoAP context and a client session | ||
coap_context_t *ctx = coap_new_context(nullptr); | ||
|
||
coap_free_context(ctx); | ||
coap_cleanup(); | ||
std::cout << "stopping" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
versions: | ||
"cci.20200424": | ||
folder: "all" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if its supported but there 2.23 in CCI now