Skip to content

Commit 4b51fc2

Browse files
Deishelonuilianriesfranramirez688
authored
Add libsocketcan recipe (#28685)
* Add libsocketcan recipe * Do not open socket in test package Signed-off-by: Uilian Ries <[email protected]> * Avoid adding cmake patch Signed-off-by: Uilian Ries <[email protected]> * Remove patch from data list Signed-off-by: Uilian Ries <[email protected]> * Use autotools to build the project Signed-off-by: Uilian Ries <[email protected]> * Trim recipe Signed-off-by: Uilian Ries <[email protected]> * Fix Linux Build, as libtool was not defined. ``` libsocketcan/0.0.12: Calling build() libsocketcan/0.0.12: RUN: autoreconf --force --install configure.ac:45: warning: The macro 'AC_HEADER_STDC' is obsolete. configure.ac:45: You should run autoupdate. /home/conan/workspace/cci_prod_PR-25786/conan-home/p/b/autoc14c7d1516d3b8/b/src/lib/autoconf/headers.m4:663: AC_HEADER_STDC is expanded from... configure.ac:45: the top level configure.ac:70: warning: The macro 'AC_HEADER_TIME' is obsolete. configure.ac:70: You should run autoupdate. /home/conan/workspace/cci_prod_PR-25786/conan-home/p/b/autoc14c7d1516d3b8/b/src/lib/autoconf/headers.m4:702: AC_HEADER_TIME is expanded from... configure.ac:70: the top level configure.ac:33: installing 'config/autoconf/compile' configure.ac:10: installing 'config/autoconf/config.guess' configure.ac:10: installing 'config/autoconf/config.sub' configure.ac:36: installing 'config/autoconf/install-sh' configure.ac:36: installing 'config/autoconf/missing' src/GNUmakefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined src/GNUmakefile.am:1: The usual way to define 'LIBTOOL' is to add 'LT_INIT' src/GNUmakefile.am:1: to 'configure.ac' and run 'aclocal' and 'autoconf' again. src/GNUmakefile.am:1: If 'LT_INIT' is in 'configure.ac', make sure src/GNUmakefile.am:1: its definition is in aclocal's search path. src/GNUmakefile.am: installing 'config/autoconf/depcomp' autoreconf: error: automake failed with exit status: 1 libsocketcan/0.0.12: ERROR: Package 'b647c43bfefae3f830561ca202b6cfd935b56205' build failed libsocketcan/0.0.12: WARN: Build folder /home/npustovoi/.conan2/p/b/libso54d0599d81851/b/build-release ERROR: libsocketcan/0.0.12: Error in build() method, line 57 autotools.autoreconf() ConanException: Error 1 while executing ``` Also pin autoconf to a specifc version, due to conflict with libtool. * Remove autoconf from tool_requires as libtool covers it * Update recipes/libsocketcan/all/conanfile.py * Update recipes/libsocketcan/all/conanfile.py --------- Signed-off-by: Uilian Ries <[email protected]> Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Francisco Ramírez <[email protected]>
1 parent 59649a8 commit 4b51fc2

File tree

6 files changed

+118
-0
lines changed

6 files changed

+118
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"0.0.12":
3+
url: "https://github.com/linux-can/libsocketcan/archive/refs/tags/v0.0.12.tar.gz"
4+
sha256: "e4432d32afa6f34d34521ae8c65d237cd175ae4510372792cb7952b62a4ea44c"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.files import copy, get, rm, rmdir
4+
from conan.tools.gnu import Autotools, AutotoolsToolchain
5+
from conan.tools.layout import basic_layout
6+
import os
7+
8+
9+
required_conan_version = ">=2.4.0"
10+
11+
12+
class PackageConan(ConanFile):
13+
name = "libsocketcan"
14+
description = "Library to control some basic functions in SocketCAN from userspace"
15+
license = "LGPL-2.1-or-later"
16+
url = "https://github.com/conan-io/conan-center-index"
17+
homepage = "https://github.com/linux-can/libsocketcan"
18+
topics = ("socket", "socketcan", "canbus")
19+
package_type = "library"
20+
settings = "os", "arch", "compiler", "build_type"
21+
languages = "C"
22+
options = {
23+
"shared": [True, False],
24+
"fPIC": [True, False],
25+
}
26+
default_options = {
27+
"shared": False,
28+
"fPIC": True,
29+
}
30+
implements = ["auto_shared_fpic"]
31+
32+
def layout(self):
33+
basic_layout(self, src_folder="src")
34+
35+
def validate(self):
36+
if self.settings.os not in ["Linux", "FreeBSD", "Android"]:
37+
raise ConanInvalidConfiguration("Only supported on Linux, FreeBSD and Android.")
38+
39+
def build_requirements(self):
40+
self.tool_requires("libtool/2.4.7")
41+
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
42+
self.tool_requires("pkgconf/[>=2.2 <3]")
43+
44+
def source(self):
45+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
46+
47+
def generate(self):
48+
tc = AutotoolsToolchain(self)
49+
tc.generate()
50+
51+
def build(self):
52+
autotools = Autotools(self)
53+
autotools.autoreconf()
54+
autotools.configure()
55+
autotools.make()
56+
57+
def package(self):
58+
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
59+
autotools = Autotools(self)
60+
autotools.install()
61+
62+
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
63+
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
64+
rmdir(self, os.path.join(self.package_folder, "share"))
65+
66+
def package_info(self):
67+
self.cpp_info.libs = ["socketcan"]
68+
self.cpp_info.set_property("pkg_config_name", "libsocketcan")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(test_package LANGUAGES C)
3+
4+
find_package(libsocketcan CONFIG REQUIRED)
5+
6+
add_executable(${PROJECT_NAME} test_package.c)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE libsocketcan::libsocketcan)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
4+
import os
5+
6+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "arch", "compiler", "build_type"
9+
generators = "CMakeDeps", "CMakeToolchain"
10+
11+
def layout(self):
12+
cmake_layout(self)
13+
14+
def requirements(self):
15+
self.requires(self.tested_reference_str)
16+
17+
def build(self):
18+
cmake = CMake(self)
19+
cmake.configure()
20+
cmake.build()
21+
22+
def test(self):
23+
if can_run(self):
24+
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
25+
self.run(bin_path, env="conanrun")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
4+
#include <libsocketcan.h>
5+
6+
7+
int main() {
8+
printf("Test package for libsocketcan\n");
9+
(void)&can_do_start;
10+
return EXIT_SUCCESS;
11+
}

recipes/libsocketcan/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"0.0.12":
3+
folder: all

0 commit comments

Comments
 (0)