Skip to content

Commit 5a127e8

Browse files
committed
Use message generation in downstream bazel builds
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
1 parent 633ce72 commit 5a127e8

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

BUILD.bazel

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
load(
2+
"@gz//bazel/skylark:build_defs.bzl",
3+
"GZ_FEATURES",
4+
"GZ_ROOT",
5+
"GZ_VISIBILITY",
6+
"gz_configure_header",
7+
"gz_export_header",
8+
"gz_include_header",
9+
)
10+
load(
11+
"@gz//msgs/tools:gz_msgs_generate.bzl",
12+
"gz_proto_library",
13+
"gz_proto_factory",
14+
)
15+
16+
package(
17+
default_visibility = GZ_VISIBILITY,
18+
features = GZ_FEATURES,
19+
)
20+
21+
licenses(["notice"]) # Apache-2.0
22+
23+
exports_files(["LICENSE"])
24+
25+
protos = glob(["src/proto/gz/sim/private_msgs/*.proto"])
26+
27+
# Create a library of our protobuf message files
28+
proto_library(
29+
name = "gzsim_proto",
30+
srcs = protos,
31+
strip_import_prefix = "src/proto",
32+
deps = [
33+
GZ_ROOT + "msgs:gzmsgs_proto"
34+
]
35+
)
36+
37+
gz_proto_library(
38+
name = "gzsim_cc_proto",
39+
proto_deps = [":gzsim_proto"],
40+
deps = [
41+
"@com_google_protobuf//:protobuf",
42+
GZ_ROOT + "msgs:gzmsgs_cc_proto"
43+
]
44+
)
45+
46+
gz_proto_factory(
47+
name = "gzsim_proto_factory",
48+
deps = [":gzsim_proto"],
49+
cc_output = "RegisterMsgs.cc",
50+
hh_output = "include/gz/sim/private_msgs/MessageTypes.hh"
51+
)
52+
53+
cc_binary(
54+
name = "test_executable",
55+
srcs = ["test_executable.cc", "RegisterMsgs.cc", "include/gz/sim/private_msgs/MessageTypes.hh"],
56+
includes = ["include"],
57+
deps = [
58+
":gzsim_cc_proto",
59+
GZ_ROOT + "msgs"
60+
]
61+
)

test_executable.cc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <gz/sim/private_msgs/peer_control.pb.h>
2+
3+
int main(int argc, char** argv)
4+
{
5+
gz::sim::private_msgs::PeerControl msg;
6+
}

0 commit comments

Comments
 (0)