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 Canary recipe - wrapper over the SocketCAN API #14011

Merged
merged 25 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1e7bb5d
Add Canary recipe - wrapper over the SocketCAN API
klimkin Nov 3, 2022
8c82b4d
Add test_v1_package
klimkin Nov 4, 2022
8704609
Silence warning about the empty build()
klimkin Nov 4, 2022
2e7bc9b
Validate c++11 requirement
klimkin Nov 4, 2022
5093c4b
Validate c++11 requirement
klimkin Nov 4, 2022
4c813a2
Fix missing import
klimkin Nov 4, 2022
18462df
Fix missing imports
klimkin Nov 4, 2022
e39bbda
Use new imports
klimkin Nov 4, 2022
6d6b36c
Canary only supports Linux
klimkin Nov 15, 2022
e0034f6
Update recipes/canary/all/conanfile.py
klimkin Nov 19, 2022
cb42cc5
Update recipes/canary/all/conanfile.py
klimkin Nov 19, 2022
df688f7
Update recipes/canary/all/test_package/conanfile.py
klimkin Nov 19, 2022
be0247e
Update recipes/canary/all/test_package/conanfile.py
klimkin Nov 19, 2022
e8f3350
Update recipes/canary/all/test_v1_package/conanfile.py
klimkin Nov 19, 2022
6849ac7
Fix missing imports
klimkin Nov 19, 2022
f10488b
Remove compiler check, since the recipe is only for Linux
klimkin Nov 19, 2022
a154fa1
Update recipes/canary/all/conanfile.py
klimkin Nov 19, 2022
d7021f8
Fix test binary path
klimkin Nov 20, 2022
82c6c41
Update recipes/canary/all/conandata.yml
klimkin Nov 21, 2022
d57647f
Update recipes/canary/config.yml
klimkin Nov 21, 2022
10333d6
Revert "Update recipes/canary/config.yml"
klimkin Nov 21, 2022
0e814f1
Revert "Update recipes/canary/all/conandata.yml"
klimkin Nov 21, 2022
239ac3e
Add missing upstream component
klimkin Nov 21, 2022
610a0b5
Update recipes/canary/all/conanfile.py
klimkin Nov 22, 2022
00febee
Use original version tag
klimkin Nov 22, 2022
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
4 changes: 4 additions & 0 deletions recipes/canary/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"v1":
url: "https://github.com/djarek/canary/archive/refs/tags/v1.tar.gz"
sha256: "f3e2e80f5c01b4d60aed4b5ec73663158b495caa4f9324a10d05e55ea8f3938c"
61 changes: 61 additions & 0 deletions recipes/canary/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain
from conan.tools.files import copy, get, rmdir

required_conan_version = ">=1.53.0"


class SocketcanCanaryConan(ConanFile):
name = "canary"
description = "A lightweight implementation of Linux SocketCAN bindings for ASIO/Boost.ASIO"
url = "https://github.com/conan-io/conan-center-index"
license = "BSL-1.0"
homepage = "https://github.com/djarek/canary"
topics = ("socketcan", "can-bus", "can")

settings = "os", "compiler", "build_type", "arch"
no_copy_source = True

@property
def _min_cppstd(self):
return 11

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration(f"{self.ref} only supports Linux.")
klimkin marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

def requirements(self):
self.requires("boost/1.74.0", transitive_headers=True)
klimkin marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()

def build(self):
pass

def package(self):
copy(self, "LICENSE_1_0.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib"))

def package_id(self):
self.info.clear()

def package_info(self):
self.cpp_info.requires = ["boost::headers", "boost::system"]
self.cpp_info.set_property("cmake_file_name", "canary")
self.cpp_info.set_property("cmake_target_name", "canary::canary")
8 changes: 8 additions & 0 deletions recipes/canary/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

find_package(canary REQUIRED)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package PUBLIC canary::canary)
target_compile_features(test_package PRIVATE cxx_std_11)
27 changes: 27 additions & 0 deletions recipes/canary/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout


class TestPackage(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
15 changes: 15 additions & 0 deletions recipes/canary/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <canary/interface_index.hpp>

int main()
{
try {
auto index = canary::get_interface_index("vcan0");
std::cout << "vcan0 interface index: " << index << "\n";
}
catch (std::exception& exc) {
std::cout << "unable to find vcan0: " << exc.what() << "\n";
}

return 0;
}
8 changes: 8 additions & 0 deletions recipes/canary/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

find_package(canary REQUIRED)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package PUBLIC canary::canary)
target_compile_features(test_package PRIVATE cxx_std_11)
18 changes: 18 additions & 0 deletions recipes/canary/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import CMake, ConanFile, tools


class TestPackage(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join(".", "test_package")
self.run(bin_path, run_environment=True)
klimkin marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions recipes/canary/all/test_v1_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <canary/interface_index.hpp>

int main()
{
try {
auto index = canary::get_interface_index("vcan0");
std::cout << "vcan0 interface index: " << index << "\n";
}
catch (std::exception& exc) {
std::cout << "unable to find vcan0: " << exc.what() << "\n";
}

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