Repository navigation
Expand file tree
/
Copy pathconanfile.py
More file actions
203 lines (183 loc) · 8.61 KB
/
Copy pathconanfile.py
File metadata and controls
203 lines (183 loc) · 8.61 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
from conan import ConanFile
from conan.tools.gnu import Autotools, AutotoolsToolchain
import re, os
class MainProject(ConanFile):
name = "libethercat"
license = "GPLv3"
author = "Robert Burger <robert.burger@dlr.de>"
url = f"https://rmc-github.robotic.dlr.de/common/{name}"
description = "This library provides all functionality to communicate with EtherCAT slaves attached to a Network interface"
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["*", "!.gitignore", "!bindings"]
options = {
"shared": [True, False],
"max_slaves": ["ANY"],
"max_groups": ["ANY"],
"max_pdlen": ["ANY"],
"max_mbx_entries": ["ANY"],
"max_init_cmd_data": ["ANY"],
"max_slave_fmmu": ["ANY"],
"max_slave_sm": ["ANY"],
"max_datagrams": ["ANY"],
"max_eeprom_cat_sm": ["ANY"],
"max_eeprom_cat_fmmu": ["ANY"],
"max_eeprom_cat_pdo": ["ANY"],
"max_eeprom_cat_pdo_entries": ["ANY"],
"max_eeprom_cat_strings": ["ANY"],
"max_eeprom_cat_dc": ["ANY"],
"max_string_len": ["ANY"],
"max_data": ["ANY"],
"max_ds402_subdevs": ["ANY"],
"max_coe_emergencies": ["ANY"],
"max_coe_emergency_msg_len": ["ANY"],
"hw_device_file": [ True, False ],
"hw_device_sock_raw": [ True, False ],
"hw_device_sock_raw_mmaped": [ True, False ],
"hw_device_bpf": [ True, False ],
"hw_device_pikeos": [ True, False ],
"mbx_support_eoe" : [ True, False ],
"mbx_support_coe" : [ True, False ],
"mbx_support_foe" : [ True, False ],
"mbx_support_soe" : [ True, False ],
"mbx_gateway_support" : [ True, False ],
}
requires = [ "libosal/[>=0.2.0]@common/stable", ]
generators = "PkgConfigDeps"
def config_options(self):
self.options.shared = True
self.options.max_slaves = 256
self.options.max_groups = 8
self.options.max_pdlen = 3036
self.options.max_mbx_entries = 16
self.options.max_init_cmd_data = 2048
self.options.max_slave_fmmu = 8
self.options.max_slave_sm = 8
self.options.max_datagrams = 100
self.options.max_eeprom_cat_sm = 8
self.options.max_eeprom_cat_fmmu = 8
self.options.max_eeprom_cat_pdo = 128
self.options.max_eeprom_cat_pdo_entries = 32
self.options.max_eeprom_cat_strings = 128
self.options.max_eeprom_cat_dc = 8
self.options.max_string_len = 128
self.options.max_data = 4096
self.options.max_ds402_subdevs = 4
self.options.max_coe_emergencies = 10
self.options.max_coe_emergency_msg_len = 32
self.options.mbx_support_eoe = True
self.options.mbx_support_coe = True
self.options.mbx_support_foe = True
self.options.mbx_support_soe = True
self.options.mbx_gateway_support = True
if self.settings.os == "pikeos":
self.options.hw_device_file = False
self.options.hw_device_sock_raw = False
self.options.hw_device_sock_raw_mmaped = False
self.options.hw_device_bpf = False
self.options.hw_device_pikeos = True
else:
self.options.hw_device_file = True
self.options.hw_device_sock_raw = True
self.options.hw_device_sock_raw_mmaped = True
self.options.hw_device_bpf = False
self.options.hw_device_pikeos = False
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):
print("os %s, compiler %s, build_type %s, arch %s" % (self.settings.os, self.settings.compiler, self.settings.build_type, self.settings.arch))
autotools = Autotools(self)
autotools.libs=[]
autotools.include_paths=[]
autotools.library_paths=[]
args = []
if self.settings.build_type == "Debug":
print("doing libethercat DEBUG build!\n")
autotools.flags = ["-O0", "-g"]
args.append("--enable-assert")
args.append("--enable-debug")
else:
autotools.flags = ["-O2"]
args.append("--disable-assert")
if self.options.shared:
args.append("--enable-shared")
args.append("--disable-static")
else:
args.append("--disable-shared")
args.append("--enable-static")
if self.options.hw_device_file:
args.append("--enable-device-file")
if self.options.hw_device_sock_raw:
args.append("--enable-device-sock-raw")
if self.options.hw_device_sock_raw_mmaped:
args.append("--enable-device-sock-raw-mmaped")
if self.options.hw_device_bpf:
args.append("--enable-device-bpf")
if self.options.hw_device_pikeos:
args.append("--enable-device-pikeos")
if not self.options.mbx_support_eoe:
args.append("--disable-mbx-support-eoe")
if not self.options.mbx_support_coe:
args.append("--disable-mbx-support-coe")
if not self.options.mbx_support_foe:
args.append("--disable-mbx-support-foe")
if not self.options.mbx_support_soe:
args.append("--disable-mbx-support-soe")
if not self.options.mbx_gateway_support:
args.append("--disable-mbx-gateway-support")
args.append("--with-max-slaves=%d" % (self.options.max_slaves))
args.append("--with-max-groups=%d" % (self.options.max_groups))
args.append("--with-max-pdlen=%d" % (self.options.max_pdlen))
args.append("--with-max-mbx-entries=%d" % (self.options.max_mbx_entries))
args.append("--with-max-init-cmd-data=%d" % (self.options.max_init_cmd_data))
args.append("--with-max-slave-fmmu=%d" % (self.options.max_slave_fmmu))
args.append("--with-max-slave-sm=%d" % (self.options.max_slave_sm))
args.append("--with-max-datagrams=%d" % (self.options.max_datagrams))
args.append("--with-max-eeprom-cat-sm=%d" % (self.options.max_eeprom_cat_sm))
args.append("--with-max-eeprom-cat-fmmu=%d" % (self.options.max_eeprom_cat_fmmu))
args.append("--with-max-eeprom-cat-pdo=%d" % (self.options.max_eeprom_cat_pdo))
args.append("--with-max-eeprom-cat-pdo-entries=%d" % (self.options.max_eeprom_cat_pdo_entries))
args.append("--with-max-eeprom-cat-strings=%d" % (self.options.max_eeprom_cat_strings))
args.append("--with-max-eeprom-cat-dc=%d" % (self.options.max_eeprom_cat_dc))
args.append("--with-max-string-len=%d" % (self.options.max_string_len))
args.append("--with-max-data=%d" % (self.options.max_data))
args.append("--with-max-ds402-subdevs=%d" % (self.options.max_ds402_subdevs))
args.append("--with-max-coe-emergencies=%d" % (self.options.max_coe_emergencies))
args.append("--disable-silent-rules")
configure_ac_in = os.path.join(self.source_folder, "configure.ac.in")
if os.path.exists(configure_ac_in):
configure_ac = os.path.join(self.source_folder, "configure.ac")
self.run(
f'sed "s|PACKAGE_VERSION|{self.version}|" configure.ac.in > configure.ac',
cwd=self.source_folder
)
print(f"[INFO] Created configure.ac from configure.ac.in")
else:
print(f"[WARNING] configure.ac.in not found at {configure_ac_in}")
autotools = Autotools(self)
autotools.autoreconf(args = [ self.source_folder, ])
autotools.configure(build_script_folder=self.source_folder, args=args)
autotools.make()
def package(self):
autotools = Autotools(self)
autotools.install()
def package_info(self):
self.cpp_info.includedirs = ['include']
self.cpp_info.libs = ["ethercat"]
self.cpp_info.bindirs = ['bin']
self.cpp_info.resdirs = ['share']
def layout(self):
self.folders.source = "."
self.folders.build = "build"
self.folders.generators = "conan"
# In the local folder (when the package is in development, or "editable") the artifacts can be found:
self.cpp.source.includedirs = ["include", os.path.join(self.folders.build, "include")]
self.cpp.build.libdirs = ["src/.libs"]
self.cpp.build.libs = [ "ethercat" ]
# In the Conan cache, we packaged everything at the default standard directories
self.cpp.package.libs = [ "ethercat" ]