-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathBUILD.bazel
More file actions
188 lines (164 loc) · 4.16 KB
/
BUILD.bazel
File metadata and controls
188 lines (164 loc) · 4.16 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
load(
"//ign_bazel:build_defs.bzl",
"IGNITION_ROOT",
"IGNITION_VISIBILITY",
"cmake_configure_file",
"generate_include_header",
"generate_yaml",
"ign_config_header",
"ign_export_header",
)
load(
":ign_msg_gen.bzl",
"get_proto_headers",
"ign_msg_gen",
)
package(
default_visibility = IGNITION_VISIBILITY,
features = [
"-parse_headers",
"-layering_check",
],
)
licenses(["notice"])
exports_files(["LICENSE"])
PROJECT_NAME = "ignition-msgs"
PROJECT_MAJOR = 6
PROJECT_MINOR = 0
PROJECT_PATCH = 0
# Generates config.hh based on the version numbers in CMake code.
ign_config_header(
name = "config",
src = "include/ignition/msgs/config.hh.in",
cmakelists = ["CMakeLists.txt"],
project_name = PROJECT_NAME,
project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH),
)
ign_export_header(
name = "include/ignition/msgs/Export.hh",
export_base = "IGNITION_MSGS",
lib_name = "ignition-msgs",
visibility = ["//visibility:private"],
)
public_headers_no_gen = glob([
"include/ignition/msgs/*.hh",
"include/ignition/msgs/detail/*.hh",
])
protos = glob(["proto/ignition/msgs/*.proto"])
generate_include_header(
name = "messagetypeshh_genrule",
out = "include/ignition/msgs/MessageTypes.hh",
hdrs = get_proto_headers(protos),
strip_prefix = ["ign_msgs"],
)
generate_include_header(
name = "msghh_genrule",
out = "include/ignition/msgs.hh",
hdrs = public_headers_no_gen + [
"include/ignition/msgs/config.hh",
"include/ignition/msgs/Export.hh",
"include/ignition/msgs/MessageTypes.hh",
],
)
public_headers = public_headers_no_gen + [
"include/ignition/msgs/config.hh",
"include/ignition/msgs/Export.hh",
"include/ignition/msgs/MessageTypes.hh",
"include/ignition/msgs.hh",
]
# Custom Ignition Protoc plugin
cc_binary(
name = "ign_msgs_gen",
srcs = [
"src/Generator.cc",
"src/Generator.hh",
"src/generator_main.cc",
],
deps = [
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//:protoc_lib",
],
)
# Create a library of our protobuf message files
proto_library(
name = "ignmsgs_proto",
srcs = protos,
strip_import_prefix = "proto",
)
# Create a library of our protobuf message files
proto_library(
name = "ignmsgs_proto_public",
srcs = protos,
strip_import_prefix = "proto",
)
# Generate our custom CC files from the protos
ign_msg_gen(
name = "ignmsgs_proto_cc",
deps = [":ignmsgs_proto"],
)
cc_library(
name = "ign_msgs",
srcs = [
"src/Factory.cc",
"src/Filesystem.cc",
"src/Utility.cc",
":ignmsgs_proto_cc",
],
hdrs = public_headers,
includes = ["include"],
deps = [
":ignmsgs_proto_cc",
IGNITION_ROOT + "ign_math",
"@com_google_protobuf//:protobuf",
"@tinyxml2",
],
)
# use shared library only when absolutely needd
cc_binary(
name = "libignition-msgs.so",
srcs = [
"src/ign.cc",
"src/ign.hh",
],
includes = ["include"],
linkshared = True,
linkstatic = True,
deps = [
":ign_msgs",
],
)
[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
data = [IGNITION_ROOT + "ign_msgs/test:desc/stringmsg.desc"],
deps = [
":ign_msgs",
IGNITION_ROOT + "ign_math",
IGNITION_ROOT + "ign_msgs/test:test_utils",
"@gtest",
"@gtest//:gtest_main",
],
) for src in glob(
[
"src/*_TEST.cc",
],
)]
cmake_configure_file(
name = "msgs.rb",
src = "src/cmd/cmdmsgs.rb.in",
out = "cmdmsgs.rb",
cmakelists = ["CMakeLists.txt"],
defines = [
"library_location=libignition-msgs.so",
"PROJECT_VERSION_FULL=%d.%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), # noqa
"IGN_LIBRARY_NAME=%s" % [PROJECT_NAME],
],
)
CMDS = " - msg : Print information about messages."
generate_yaml(
name = "msgs",
commands = CMDS,
library_name = PROJECT_NAME,
library_version = "%d.%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH),
ruby_target = "msgs.rb",
)