-
Notifications
You must be signed in to change notification settings - Fork 2k
Add Canary recipe - wrapper over the SocketCAN API #14011
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
Merged
Merged
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 8c82b4d
Add test_v1_package
klimkin 8704609
Silence warning about the empty build()
klimkin 2e7bc9b
Validate c++11 requirement
klimkin 5093c4b
Validate c++11 requirement
klimkin 4c813a2
Fix missing import
klimkin 18462df
Fix missing imports
klimkin e39bbda
Use new imports
klimkin 6d6b36c
Canary only supports Linux
klimkin e0034f6
Update recipes/canary/all/conanfile.py
klimkin cb42cc5
Update recipes/canary/all/conanfile.py
klimkin df688f7
Update recipes/canary/all/test_package/conanfile.py
klimkin be0247e
Update recipes/canary/all/test_package/conanfile.py
klimkin e8f3350
Update recipes/canary/all/test_v1_package/conanfile.py
klimkin 6849ac7
Fix missing imports
klimkin f10488b
Remove compiler check, since the recipe is only for Linux
klimkin a154fa1
Update recipes/canary/all/conanfile.py
klimkin d7021f8
Fix test binary path
klimkin 82c6c41
Update recipes/canary/all/conandata.yml
klimkin d57647f
Update recipes/canary/config.yml
klimkin 10333d6
Revert "Update recipes/canary/config.yml"
klimkin 0e814f1
Revert "Update recipes/canary/all/conandata.yml"
klimkin 239ac3e
Add missing upstream component
klimkin 610a0b5
Update recipes/canary/all/conanfile.py
klimkin 00febee
Use original version tag
klimkin 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 hidden or 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: | ||
"v1": | ||
url: "https://github.com/djarek/canary/archive/refs/tags/v1.tar.gz" | ||
sha256: "f3e2e80f5c01b4d60aed4b5ec73663158b495caa4f9324a10d05e55ea8f3938c" |
This file contains hidden or 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,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.") | ||
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") |
This file contains hidden or 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,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) |
This file contains hidden or 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,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") |
This file contains hidden or 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 <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; | ||
} |
This file contains hidden or 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,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) |
This file contains hidden or 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,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
|
This file contains hidden or 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 <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; | ||
} |
This file contains hidden or 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,3 @@ | ||
versions: | ||
"v1": | ||
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.
Uh oh!
There was an error while loading. Please reload this page.