Skip to content

Commit 744b29d

Browse files
shameekgangulyiche033
authored andcommitted
Bazel updates (#744)
* Bazel updates Signed-off-by: Shameek Ganguly <[email protected]>
1 parent 2acf501 commit 744b29d

File tree

5 files changed

+189
-49
lines changed

5 files changed

+189
-49
lines changed

BUILD.bazel

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
2+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
13
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
24
load("@rules_license//rules:license.bzl", "license")
35

@@ -26,6 +28,7 @@ gz_configure_header(
2628
name = "Config",
2729
src = "include/gz/transport/config.hh.in",
2830
out = "include/gz/transport/config.hh",
31+
defines = ["HAVE_IFADDRS=1"],
2932
package_xml = "package.xml",
3033
)
3134

@@ -63,6 +66,9 @@ cc_library(
6366
copts = [
6467
"-Wno-deprecated-declarations",
6568
],
69+
defines = [
70+
'GZ_TRANSPORT_DEFAULT_IMPLEMENTATION=\\"zeromq\\"',
71+
],
6672
features = [
6773
# Layering check fails for clang build due to no module exporting
6874
# `google/protobuf/stubs/common.h`. Unfortunately, the bazel target that
@@ -82,6 +88,17 @@ cc_library(
8288
],
8389
)
8490

91+
cc_library(
92+
name = "gz-transport-discovery-header",
93+
hdrs = ["src/Discovery.hh"],
94+
visibility = ["//:__subpackages__"],
95+
deps = [
96+
":gz-transport",
97+
"@gz-msgs",
98+
"@gz-msgs//:gzmsgs_cc_proto",
99+
],
100+
)
101+
85102
cc_binary(
86103
name = "topic",
87104
srcs = [
@@ -95,6 +112,7 @@ cc_binary(
95112
deps = [
96113
":gz-transport",
97114
"@com_google_protobuf//:json_util",
115+
"@com_google_protobuf//:protobuf",
98116
"@gz-msgs",
99117
"@gz-utils//cli:GzFormatter",
100118
"@gz-utils//cli:cli11",
@@ -114,28 +132,47 @@ cc_binary(
114132
deps = [
115133
":gz-transport",
116134
"@com_google_protobuf//:json_util",
135+
"@com_google_protobuf//:protobuf",
117136
"@gz-msgs",
118137
"@gz-utils//cli:GzFormatter",
119138
"@gz-utils//cli:cli11",
120139
],
121140
)
122141

123-
# test_sources = glob(
124-
# include = ["src/*_TEST.cc"],
125-
# )
126-
127-
# [cc_test(
128-
# name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
129-
# srcs = [src],
130-
# env = {
131-
# "GZ_BAZEL": "1",
132-
# "GZ_BAZEL_PATH": "transport",
133-
# },
134-
# deps = [
135-
# ":transport",
136-
# GZ_ROOT + "common/testing",
137-
# GZ_ROOT + "transport/test:utils",
138-
# "@gtest",
139-
# "@gtest//:gtest_main",
140-
# ],
141-
# ) for src in test_sources]
142+
test_sources = glob(
143+
include = ["src/*_TEST.cc"],
144+
)
145+
146+
[cc_test(
147+
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
148+
srcs = [src],
149+
env = {"GZ_BAZEL": "1"},
150+
deps = [
151+
":gz-transport",
152+
":gz-transport-discovery-header",
153+
"//test:utils",
154+
"@com_google_protobuf//:protobuf",
155+
"@googletest//:gtest",
156+
"@googletest//:gtest_main",
157+
"@gz-common//testing",
158+
"@gz-msgs//:gzmsgs_cc_proto",
159+
"@gz-utils//:Environment",
160+
"@gz-utils//:ExtraTestMacros",
161+
],
162+
) for src in test_sources]
163+
164+
buildifier(
165+
name = "buildifier.fix",
166+
exclude_patterns = ["./.git/*"],
167+
lint_mode = "fix",
168+
mode = "fix",
169+
)
170+
171+
buildifier_test(
172+
name = "buildifier.test",
173+
exclude_patterns = ["./.git/*"],
174+
lint_mode = "warn",
175+
mode = "diff",
176+
no_sandbox = True,
177+
workspace = "//:MODULE.bazel",
178+
)

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
## MODULE.bazel
21
module(
32
name = "gz-transport",
4-
repo_name = "org_gazebosim_gz-transport",
53
)
64

5+
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
76
bazel_dep(name = "cppzmq", version = "4.10.0.bcr.1")
8-
bazel_dep(name = "googletest", version = "1.14.0")
7+
bazel_dep(name = "googletest", version = "1.15.2")
98
bazel_dep(name = "libuuid", version = "2.39.3.bcr.1")
109
bazel_dep(name = "libzmq", version = "4.3.5.bcr.3")
11-
bazel_dep(name = "protobuf", version = "29.4", repo_name = "com_google_protobuf")
10+
bazel_dep(name = "protobuf", version = "30.1", repo_name = "com_google_protobuf")
1211
bazel_dep(name = "rules_license", version = "1.0.0")
1312
bazel_dep(name = "rules_proto", version = "7.1.0")
1413
bazel_dep(name = "sqlite3", version = "3.49.1")
14+
bazel_dep(name = "rules_cc", version = "0.1.2")
1515

1616
# Gazebo Dependencies
1717
bazel_dep(name = "rules_gazebo", version = "0.0.2")

log/BUILD.bazel

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
12
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
23

34
package(
@@ -56,30 +57,30 @@ cc_library(
5657
],
5758
)
5859

59-
# test_sources = glob(
60-
# include = ["src/*_TEST.cc"],
61-
# exclude = ["src/LogCommandAPI_TEST.cc"],
62-
# )
60+
test_sources = glob(
61+
include = ["src/*_TEST.cc"],
62+
exclude = ["src/LogCommandAPI_TEST.cc"],
63+
)
6364

64-
# [cc_test(
65-
# name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
66-
# srcs = [src],
67-
# data = [
68-
# "test/data/state.tlog",
69-
# ],
70-
# defines = [
71-
# 'GZ_TRANSPORT_LOG_TEST_PATH=\\"transport/log/test\\"',
72-
# 'CORRUPT_DB_TEST_PATH=\\"transport/log/test/data/state.tlog\\"',
73-
# ],
74-
# env = {
75-
# "GZ_BAZEL": "1",
76-
# "GZ_BAZEL_PATH": "transport",
77-
# },
78-
# deps = [
79-
# ":log",
80-
# GZ_ROOT + "common/testing",
81-
# GZ_ROOT + "transport/test:utils",
82-
# "@gtest",
83-
# "@gtest//:gtest_main",
84-
# ],
85-
# ) for src in test_sources]
65+
[cc_test(
66+
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
67+
srcs = [src],
68+
copts = [
69+
"-Wno-private-header", # Required for Descriptor_TEST
70+
],
71+
data = [
72+
"test/data/state.tlog",
73+
],
74+
defines = ['CORRUPT_DB_TEST_PATH=\\"log/test/data/state.tlog\\"'],
75+
env = {
76+
"GZ_BAZEL": "1",
77+
"GZ_TRANSPORT_LOG_SQL_PATH": "log/sql",
78+
},
79+
deps = [
80+
":log",
81+
"//test:utils",
82+
"@googletest//:gtest",
83+
"@googletest//:gtest_main",
84+
"@gz-common//testing",
85+
],
86+
) for src in test_sources]

parameters/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
12
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
23

34
package(

test/BUILD.bazel

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
2+
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header")
3+
14
package(
25
default_applicable_licenses = ["//:license"],
36
features = [
@@ -6,6 +9,14 @@ package(
69
],
710
)
811

12+
gz_configure_header(
13+
name = "Config",
14+
src = "test_config.hh.in",
15+
out = "include/test_config.hh",
16+
package_xml = "//:package.xml",
17+
visibility = ["//:__subpackages__"],
18+
)
19+
920
cc_library(
1021
name = "utils",
1122
hdrs = ["test_utils.hh"],
@@ -15,3 +26,93 @@ cc_library(
1526
"@gz-utils",
1627
],
1728
)
29+
30+
test_executables = [
31+
"authPubSubSubscriberInvalid_aux",
32+
"fastPub_aux",
33+
"pub_aux",
34+
"pub_aux_throttled",
35+
"scopedTopicSubscriber_aux",
36+
"twoProcsPublisher_aux",
37+
"twoProcsPubSubMixedSubscribers_aux",
38+
"twoProcsPubSubSingleSubscriber_aux",
39+
"twoProcsPubSubSubscriber_aux",
40+
"twoProcsSrvCallReplier_aux",
41+
"twoProcsSrvCallReplierInc_aux",
42+
"twoProcsSrvCallWithoutInputReplier_aux",
43+
"twoProcsSrvCallWithoutInputReplierInc_aux",
44+
"twoProcsSrvCallWithoutOutputReplier_aux",
45+
"twoProcsSrvCallWithoutOutputReplierInc_aux",
46+
]
47+
48+
[cc_binary(
49+
name = name,
50+
srcs = ["integration/test_executables/" + name + ".cc"],
51+
deps = [
52+
":Config",
53+
"//:gz-transport",
54+
"@googletest//:gtest",
55+
"@gz-msgs//:gzmsgs_cc_proto",
56+
"@gz-utils//:Environment",
57+
],
58+
) for name in test_executables]
59+
60+
integration_test_sources = [
61+
"authPubSub.cc",
62+
"scopedTopic.cc",
63+
"callback_scope_TEST.cc",
64+
"statistics.cc",
65+
"twoProcsPubSub.cc",
66+
"twoProcsPubSubStats.cc",
67+
"twoProcsSrvCall.cc",
68+
"twoProcsSrvCallStress.cc",
69+
"twoProcsSrvCallSync1.cc",
70+
"twoProcsSrvCallWithoutInput.cc",
71+
"twoProcsSrvCallWithoutInputStress.cc",
72+
"twoProcsSrvCallWithoutInputSync1.cc",
73+
"twoProcsSrvCallWithoutOutput.cc",
74+
"twoProcsSrvCallWithoutOutputStress.cc",
75+
]
76+
77+
# Found with
78+
# bazel test test:all --runs_per_test 10
79+
flaky_test_srcs = [
80+
"twoProcsPubSub.cc",
81+
"twoProcsSrvCall.cc",
82+
"twoProcsSrvCallWithoutInput.cc",
83+
"twoProcsSrvCallWithoutOutput.cc",
84+
]
85+
86+
[cc_test(
87+
name = "INTEGRATION_" + src.replace(".cc", ""),
88+
srcs = ["integration/" + src],
89+
data = [":" + name for name in test_executables],
90+
defines = [
91+
'AUTH_PUB_SUB_SUBSCRIBER_INVALID_EXE=\\"./test/authPubSubSubscriberInvalid_aux\\"',
92+
'FAST_PUB_EXE=\\"./test/fastPub_aux\\"',
93+
'PUB_EXE=\\"./test/pub_aux\\"',
94+
'PUB_THROTTLED_EXE=\\"./test/pub_aux_throttled\\"',
95+
'SCOPED_TOPIC_SUBSCRIBER_EXE=\\"./test/scopedTopicSubscriber_aux\\"',
96+
'TWO_PROCS_PUBLISHER_EXE=\\"./test/twoProcsPublisher_aux\\"',
97+
'TWO_PROCS_PUB_SUB_MIXED_SUBSCRIBERS_EXE=\\"./test/twoProcsPubSubMixedSubscribers_aux\\"',
98+
'TWO_PROCS_PUB_SUB_SINGLE_SUBSCRIBER_EXE=\\"./test/twoProcsPubSubSingleSubscriber_aux\\"',
99+
'TWO_PROCS_PUB_SUB_SUBSCRIBER_EXE=\\"./test/twoProcsPubSubSubscriber_aux\\"',
100+
'TWO_PROCS_SRV_CALL_REPLIER_EXE=\\"./test/twoProcsSrvCallReplier_aux\\"',
101+
'TWO_PROCS_SRV_CALL_REPLIER_INC_EXE=\\"./test/twoProcsSrvCallReplierInc_aux\\"',
102+
'TWO_PROCS_SRV_CALL_WITHOUT_INPUT_REPLIER_EXE=\\"./test/twoProcsSrvCallWithoutInputReplier_aux\\"',
103+
'TWO_PROCS_SRV_CALL_WITHOUT_INPUT_REPLIER_INC_EXE=\\"./test/twoProcsSrvCallWithoutInputReplierInc_aux\\"',
104+
'TWO_PROCS_SRV_CALL_WITHOUT_OUTPUT_REPLIER_EXE=\\"./test/twoProcsSrvCallWithoutOutputReplier_aux\\"',
105+
'TWO_PROCS_SRV_CALL_WITHOUT_OUTPUT_REPLIER_INC_EXE=\\"./test/twoProcsSrvCallWithoutOutputReplierInc_aux\\"',
106+
],
107+
env = {"GZ_BAZEL": "1"},
108+
deps = [
109+
":Config",
110+
":utils",
111+
"//:gz-transport",
112+
"@googletest//:gtest",
113+
"@googletest//:gtest_main",
114+
"@gz-msgs//:gzmsgs_cc_proto",
115+
"@gz-utils//:Environment",
116+
"@gz-utils//:Subprocess",
117+
],
118+
) for src in integration_test_sources if src not in flaky_test_srcs]

0 commit comments

Comments
 (0)