-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconanfile.py
More file actions
98 lines (83 loc) · 3.48 KB
/
conanfile.py
File metadata and controls
98 lines (83 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from conan import ConanFile
from conan import tools
from conan.tools.files import mkdir, chdir, copy
from conan.tools.gnu import Autotools, AutotoolsToolchain
import os
class MainProject(ConanFile):
name = "libosal"
license = "GPLv3"
author = "Robert Burger <robert.burger@dlr.de>"
url = f"https://rmc-github.robotic.dlr.de/common/{name}"
description = """"This library provides an Operating System Abstraction Layer
(OSAL) for other programs so they do not need to take care
about the underlying implementation"""
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["*", "!.gitignore", "!bindings"]
options = {"shared": [True, False],
"coverage" : [True, False]}
default_options = {"shared": True,
"coverage" : False}
def build_requirements(self):
if self.options.coverage == True:
self.tool_requires("gcovr/6.0@pip/stable")
def generate(self):
tc = AutotoolsToolchain(self)
tc.autoreconf_args = [ "--install", ]
if self.settings.os == "pikeos":
tc.update_configure_args({
"--host": "%s-%s" % (self.settings.arch, self.settings.os), # update flag '--host=my-gnu-triplet
})
tc.generate()
def build(self):
autotools = Autotools(self)
autotools.libs=[]
autotools.include_paths=[]
autotools.library_paths=[]
args = []
if self.settings.build_type == "Debug":
autotools.flags = ["-O0", "-g"]
args.append("--enable-assert")
else:
if self.options.coverage != True:
autotools.flags = ["-O2"]
args.append("--disable-assert")
if self.options.coverage == True:
if self.settings.build_type == "Debug":
autotools.flags.append("--coverage")
else:
autotools.flags = ["-O0", "-g", "--coverage"]
if self.options.shared:
args.append("--enable-shared")
args.append("--disable-static")
else:
args.append("--disable-shared")
args.append("--enable-static")
self.run(f'sed "s|PACKAGE_VERSION|{self.version}|" configure.ac.in > configure.ac')
autotools.autoreconf()
autotools.configure(args=args)
autotools.make()
if self.options.coverage:
autotools.make(target="check")
mkdir(self, "tests/posix/coverage")
with chdir(self, "tests/posix"):
self.run(r"gcovr -v --decisions --html-details coverage/details.html -r . \
--filter '(.+)\.((c)|(cc))$' --gcov-ignore-parse-errors=all \
. ../../src ../../src/posix ")
def package(self):
autotools = Autotools(self)
autotools.install()
if self.options.coverage:
src = os.path.join(self.build_folder,
"tests",
"posix",
"coverage")
dst = os.path.join(self.package_folder,
"doc",
"coverage")
copy(self, "*.html", src, dst)
copy(self, "*.css", src, dst)
def package_info(self):
self.cpp_info.includedirs = ['include']
self.cpp_info.libs = ["osal"]
self.cpp_info.bindirs = ['bin']
self.cpp_info.resdirs = ['share']