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

WIP feat: add ot-commissioner #1285

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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/ot-commissioner/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/ot-commissioner/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200404":
sha256: 04a8cd1b3e79ef8f42341d50c32916806e1313bbcc76292f7f57c36ade371b18
url: https://github.com/gocarlos/ot-commissioner/archive/643e7e8cf803f3fd8daa09673d49badc43b4b385.zip
Comment on lines +2 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use your fork?

Let's use the upstream and the tagged version.
https://github.com/openthread/ot-commissioner/releases/tag/v0.0.1

73 changes: 73 additions & 0 deletions recipes/ot-commissioner/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
from conans.tools import Version


class OtCommissionerConan(ConanFile):
name = "ot-commissioner"
description = "OpenThread Commissioner, a Thread commissioner for joining new Thread devices and managing Thread networks."
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://giþthub.com/openthread/ot-commissioner"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
homepage = "https://giþthub.com/openthread/ot-commissioner"
homepage = "https://github.com/openthread/ot-commissioner"

topics = ("conan", "thread", "commissioning")
license = "MIT"
exports_sources = ["CMakeLists.txt", "patches/*"]
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False],
"fPIC": [True, False]}
default_options = {"shared": False,
"fPIC": True}

_cmake = None

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

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def requirements(self):
self.requires("libevent/2.1.11")
self.requires("mdns/20200331")
self.requires("nlohmann_json/3.7.3")
self.requires("mbedtls/2.16.3-gpl")
self.requires("fmt/6.1.2")
Comment on lines +33 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.requires("libevent/2.1.11")
self.requires("mdns/20200331")
self.requires("nlohmann_json/3.7.3")
self.requires("mbedtls/2.16.3-gpl")
self.requires("fmt/6.1.2")
self.requires("libevent/2.1.12")
self.requires("mdns/20200424")
self.requires("nlohmann_json/3.9.1")
self.requires("mbedtls/2.25.0")
self.requires("fmt/7.1.3")

# TODO: port to CCI
self.requires("cose-c/20200225@gocarlos/testing")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting for #1314

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wait is over.

Comment on lines +38 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO: port to CCI
self.requires("cose-c/20200225@gocarlos/testing")
self.requires("cose-c/cci.20200430")

Hopefully, cose-c is already in CCI, so let's try to use it.

self.requires("cn-cbor/1.0.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
# extracted_dir = self.name + "-" + self.version
extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0]
Comment on lines +44 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth using globbing?

os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["OT_COMM_USE_VENDORED_LIBS"] = False
self._cmake.definitions["OT_COMM_TEST"] = False
self._cmake.definitions["OT_COMM_APP"] = False
self._cmake.definitions["OT_COMM_COVERAGE"] = False
self._cmake.configure()
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()
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", "spdlog", "cmake"))

def package_info(self):
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
11 changes: 11 additions & 0 deletions recipes/ot-commissioner/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.11)
project(test_package)

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})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/ot-commissioner/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from conans import ConanFile, CMake, tools


class TestPackageConan(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")
self.run(bin_path, run_environment=True)
6 changes: 6 additions & 0 deletions recipes/ot-commissioner/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>

int main(){
std::cout << "hello world" << std::endl;
return 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

3 changes: 3 additions & 0 deletions recipes/ot-commissioner/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"20200404":
folder: "all"