Skip to content

Commit b4b3550

Browse files
committed
Incorporate feedback
Signed-off-by: Michael Carroll <michael@openrobotics.org>
1 parent 60420bd commit b4b3550

File tree

2 files changed

+60
-53
lines changed

2 files changed

+60
-53
lines changed

BUILD.bazel

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
load(
2-
"//ign_bazel:cmake_configure_file.bzl",
2+
"//ign_bazel:build_defs.bzl",
3+
"IGNITION_ROOT",
4+
"IGNITION_VISIBILITY",
35
"cmake_configure_file",
4-
)
5-
load(
6-
"//ign_bazel:generate_include_header.bzl",
76
"generate_include_header",
8-
)
9-
load(
10-
"//ign_bazel:ign_export_header.bzl",
7+
"ign_config_header",
118
"ign_export_header",
129
)
10+
1311
load(
1412
":ign_msg_gen.bzl",
1513
"get_proto_headers",
1614
"ign_msg_gen",
1715
)
1816

19-
package(default_visibility = ["//visibility:public"])
17+
package(
18+
default_visibility = IGNITION_VISIBILITY,
19+
features = [
20+
"-parse_headers",
21+
"-layering_check",
22+
],
23+
)
24+
25+
licenses(["notice"])
26+
27+
exports_files(["LICENSE"])
2028

2129
PROJECT_NAME = "ignition-msgs"
2230

@@ -27,23 +35,12 @@ PROJECT_MINOR = 0
2735
PROJECT_PATCH = 0
2836

2937
# Generates config.hh based on the version numbers in CMake code.
30-
cmake_configure_file(
38+
ign_config_header(
3139
name = "config",
3240
src = "include/ignition/msgs/config.hh.in",
33-
out = "include/ignition/msgs/config.hh",
3441
cmakelists = ["CMakeLists.txt"],
35-
defines = [
36-
"PROJECT_VERSION_MAJOR=%d" % PROJECT_MAJOR,
37-
"PROJECT_VERSION_MINOR=%d" % PROJECT_MINOR,
38-
"PROJECT_VERSION_PATCH=%d" % PROJECT_PATCH,
39-
"PROJECT_MAJOR_VERSION=%d" % PROJECT_MAJOR,
40-
"PROJECT_MINOR_VERSION=%d" % PROJECT_MINOR,
41-
"PROJECT_PATCH_VERSION=%d" % PROJECT_PATCH,
42-
"PROJECT_VERSION=%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR),
43-
"PROJECT_VERSION_FULL=%d.%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), # noqa
44-
"PROJECT_NAME_NO_VERSION=%s" % PROJECT_NAME,
45-
],
46-
visibility = ["//visibility:public"],
42+
project_name = PROJECT_NAME,
43+
project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH),
4744
)
4845

4946
ign_export_header(
@@ -67,6 +64,7 @@ generate_include_header(
6764
name = "messagetypeshh_genrule",
6865
out = "include/ignition/msgs/MessageTypes.hh",
6966
hdrs = get_proto_headers(protos),
67+
strip_prefix = ["ign_msgs"],
7068
)
7169

7270
generate_include_header(
@@ -120,50 +118,46 @@ ign_msg_gen(
120118
deps = [":ignmsgs_proto"],
121119
)
122120

123-
cc_binary(
124-
name = "libignition-msgs6.so",
121+
cc_library(
122+
name = "ign_msgs",
125123
srcs = [
126124
":ignmsgs_proto_cc",
127125
"src/Factory.cc",
128126
"src/Filesystem.cc",
129127
"src/Utility.cc",
130-
] + public_headers,
131-
includes = ["include"],
132-
linkopts = [
133-
"-Wl,-soname,libignition-msgs6.so",
134-
"-ltinyxml2",
135128
],
136-
linkshared = True,
137-
linkstatic = True,
138-
visibility = [],
129+
hdrs = public_headers,
130+
includes = ["include"],
139131
deps = [
140132
":ignmsgs_proto_cc",
141-
"//ign_math",
133+
IGNITION_ROOT + "ign_math",
134+
"@tinyxml2",
142135
"@com_google_protobuf//:protobuf",
143136
],
144137
)
145138

146-
cc_library(
147-
name = "ign_msgs",
148-
srcs = ["libignition-msgs6.so"],
149-
hdrs = public_headers + [":ignmsgs_proto_cc"],
139+
# use shared library only when absolutely needd
140+
cc_binary(
141+
name = "libignition-msgs6.so",
150142
includes = ["include"],
151-
visibility = ["//visibility:public"],
143+
linkopts = [
144+
"-Wl,-soname,libignition-msgs6.so",
145+
],
146+
linkshared = True,
147+
linkstatic = True,
152148
deps = [
153-
":ignmsgs_proto_cc",
154-
"//ign_math",
155-
"@com_google_protobuf//:protobuf",
156-
"@com_google_protobuf//:protoc_lib",
149+
":ign_msgs",
157150
],
158151
)
159152

160153
[cc_test(
161154
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
162155
srcs = [src],
163-
data = ["//ign_msgs/test:desc/stringmsg.desc"],
156+
data = [IGNITION_ROOT + "ign_msgs/test:desc/stringmsg.desc"],
164157
deps = [
165158
":ign_msgs",
166-
"//ign_msgs/test:test_utils",
159+
IGNITION_ROOT + "ign_math",
160+
IGNITION_ROOT + "ign_msgs/test:test_utils",
167161
"@gtest",
168162
"@gtest//:gtest_main",
169163
],
@@ -174,3 +168,5 @@ cc_library(
174168
)]
175169

176170
exports_files(["src/cmd/cmdmsgs.rb.in"])
171+
172+
exports_files(["CMakeLists.txt"])

test/BUILD.bazel

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
load(
2-
"//ign_bazel:cmake_configure_file.bzl",
2+
"//ign_bazel:build_defs.bzl",
3+
"IGNITION_ROOT",
4+
"IGNITION_VISIBILITY",
35
"cmake_configure_file",
46
)
57

6-
BINARY_DIR = "./ign_msgs/"
8+
package(
9+
default_visibility = IGNITION_VISIBILITY,
10+
features = [
11+
"-layering_check",
12+
],
13+
)
14+
15+
licenses(["notice"])
16+
17+
exports_files(["LICENSE"])
718

8-
SOURCE_DIR = "./ign_msgs/"
19+
MSGS_DIR = "./ign_msgs/"
920

1021
# Generates config.hh based on the version numbers in CMake code.
1122
cmake_configure_file(
@@ -14,9 +25,9 @@ cmake_configure_file(
1425
out = "test_config.h",
1526
cmakelists = ["CMakeLists.txt"],
1627
defines = [
17-
"CMAKE_BINARY_DIR=%s" % BINARY_DIR,
18-
"PROJECT_BINARY_DIR=%s" % BINARY_DIR,
19-
"PROJECT_SOURCE_DIR=%s" % SOURCE_DIR,
28+
"CMAKE_BINARY_DIR=%s" % (MSGS_DIR),
29+
"PROJECT_BINARY_DIR=%s" % (MSGS_DIR),
30+
"PROJECT_SOURCE_DIR=%s" % (MSGS_DIR),
2031
],
2132
visibility = ["//visibility:private"],
2233
)
@@ -25,10 +36,8 @@ cc_library(
2536
name = "test_utils",
2637
srcs = ["test_config.h"],
2738
includes = ["."],
28-
visibility = ["//visibility:public"],
2939
)
3040

31-
exports_files(["desc/stringmsg.desc"])
3241

3342
[
3443
cc_test(
@@ -40,10 +49,12 @@ exports_files(["desc/stringmsg.desc"])
4049
],
4150
deps = [
4251
":test_utils",
43-
"//ign_msgs",
52+
IGNITION_ROOT + "ign_msgs",
4453
"@gtest",
4554
"@gtest//:gtest_main",
4655
],
4756
)
4857
for test in glob(["integration/*.cc"])
4958
]
59+
60+
exports_files(["desc/stringmsg.desc"])

0 commit comments

Comments
 (0)