-
Notifications
You must be signed in to change notification settings - Fork 22
/
plugin.bzl
98 lines (83 loc) · 2.24 KB
/
plugin.bzl
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
CLOE_PLUGINS = [
"//plugins/basic",
"//plugins/clothoid_fit",
# "//plugins/esmini",
"//plugins/gndtruth_extractor",
"//plugins/minimator",
"//plugins/mocks:demo_stuck",
"//plugins/mocks:demo_printer",
"//plugins/noisy_sensor:noisy_object_sensor",
"//plugins/noisy_sensor:noisy_lane_sensor",
"//plugins/speedometer",
"//plugins/virtue",
]
def cloe_plugin(
name,
copts = None,
visibility = None,
**kwargs,
):
"""
Defines a cc_binary target for a cloe plugin.
See: https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary
Args:
name: plugin name
**kwargs: additional cc_binary args
Defaults:
copts: ["-fvisibility=hidden", "-fvisibility-inlines-hidden"]
visibility: ["//visibility:public"]
linkshared: True (forced)
"""
# Set default for copts:
if copts == None:
copts = []
copts += [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
]
# Set default for visibility:
if visibility == None:
visibility = ["//visibility:public"]
# Check correct usage:
if "linkshared" in kwargs:
fail("cloe_plugin: linkshared must be True, do not set it yourself")
# Create target:
native.cc_binary(
name = name,
copts = copts,
linkshared = True,
visibility = visibility,
**kwargs,
)
def cloe_plugin_library(
name,
copts = None,
**kwargs,
):
"""
Defines a cc_library target for a cloe plugin.
See: https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library
Args:
name: plugin name
**kwargs: additional cc_binary args
Defaults:
copts: ["-fvisibility=hidden", "-fvisibility-inlines-hidden"]
alwayslink: True (forced)
"""
# Set default for copts:
if copts == None:
copts = []
copts += [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
]
# Check correct usage:
if "alwayslink" in kwargs:
fail("cloe_plugin_library: alwayslink must be True, do not set it yourself")
# Create target:
native.cc_library(
name = name,
copts = copts,
alwayslink = True,
**kwargs,
)