Skip to content

Commit 4a2b05a

Browse files
Migrate bazel build setup to use bzlmod (#176)
Signed-off-by: Shameek Ganguly <shameek@intrinsic.ai>
1 parent 61fcd15 commit 4a2b05a

File tree

6 files changed

+99
-70
lines changed

6 files changed

+99
-70
lines changed

.bazelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
common --enable_bzlmod
2+
common --lockfile_mode=off
3+
4+
# Add C++17 compiler flags.
5+
build --cxxopt=-std=c++17
6+
build --host_cxxopt=-std=c++17
7+
8+
build --force_pic
9+
build --strip=never
10+
build --strict_system_includes
11+
build --fission=dbg
12+
build --features=per_object_debug_info

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.3.1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ build_*
55
# OS generated files
66
.DS_Store
77
*.swp
8+
9+
# Bazel generated files
10+
bazel-*

BUILD.bazel

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
load(
2-
"@gz//bazel/skylark:build_defs.bzl",
3-
"GZ_ROOT",
4-
"GZ_VISIBILITY",
5-
"gz_configure_header",
6-
"gz_export_header",
7-
"gz_include_header",
8-
)
1+
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
2+
load("@rules_license//rules:license.bzl", "license")
93

104
package(
11-
default_visibility = GZ_VISIBILITY,
5+
default_applicable_licenses = [":license"],
6+
features = [
7+
"layering_check",
8+
"parse_headers",
9+
],
10+
)
11+
12+
license(
13+
name = "license",
14+
package_name = "gz-plugin",
1215
)
1316

14-
licenses(["notice"]) # Apache-2.0
17+
licenses(["notice"])
1518

1619
gz_configure_header(
17-
name = "config",
20+
name = "Config",
1821
src = "core/include/gz/plugin/config.hh.in",
19-
cmakelists = ["CMakeLists.txt"],
20-
package = "plugin",
22+
out = "core/include/gz/plugin/config.hh",
23+
package_xml = "package.xml",
2124
)
2225

2326
gz_export_header(
24-
name = "core/include/gz/plugin/Export.hh",
27+
name = "Export",
28+
out = "core/include/gz/plugin/Export.hh",
2529
export_base = "GZ_PLUGIN",
2630
lib_name = "gz-plugin",
27-
visibility = ["//visibility:private"],
2831
)
2932

3033
public_headers_no_gen = glob([
@@ -37,28 +40,19 @@ sources = glob(
3740
exclude = ["core/src/*_TEST.cc"],
3841
)
3942

40-
gz_include_header(
41-
name = "pluginhh_genrule",
42-
out = "core/include/gz/plugin.hh",
43-
hdrs = public_headers_no_gen + [
44-
"core/include/gz/plugin/Export.hh",
45-
"core/include/gz/plugin/config.hh",
46-
],
47-
)
48-
4943
public_headers = public_headers_no_gen + [
5044
"core/include/gz/plugin/config.hh",
5145
"core/include/gz/plugin/Export.hh",
52-
"core/include/gz/plugin.hh",
5346
]
5447

5548
cc_library(
5649
name = "core",
5750
srcs = sources,
5851
hdrs = public_headers,
5952
includes = ["core/include"],
53+
visibility = ["//visibility:public"],
6054
deps = [
61-
GZ_ROOT + "utils",
55+
"@gz-utils",
6256
],
6357
)
6458

@@ -67,8 +61,7 @@ cc_library(
6761
srcs = [src],
6862
deps = [
6963
":core",
70-
"@gtest",
71-
"@gtest//:gtest_main",
64+
"@googletest//:gtest_main",
7265
],
7366
) for src in glob(
7467
[
@@ -89,17 +82,18 @@ cc_library(
8982
includes = [
9083
"register/include",
9184
],
85+
visibility = ["//visibility:public"],
9286
deps = [
9387
":core",
9488
":loader",
9589
],
9690
)
9791

9892
gz_export_header(
99-
name = "loader/include/gz/plugin/loader/Export.hh",
93+
name = "loader_export",
94+
out = "loader/include/gz/plugin/loader/Export.hh",
10095
export_base = "GZ_PLUGIN_LOADER",
10196
lib_name = "gz-plugin-loader",
102-
visibility = ["//visibility:private"],
10397
)
10498

10599
cc_library(
@@ -117,26 +111,25 @@ cc_library(
117111
"loader/include/gz/plugin/loader/Export.hh",
118112
],
119113
includes = ["loader/include"],
114+
visibility = ["//visibility:public"],
120115
deps = [
121116
":core",
122-
GZ_ROOT + "utils",
117+
"@gz-utils",
123118
],
124119
)
125120

126121
cc_test(
127122
name = "Loader_TEST",
128123
srcs = [
129124
"loader/src/Loader_TEST.cc",
130-
":config",
131125
],
132126
defines = [
133-
'GzDummyPlugins_LIB=\\"./plugin/test/libGzDummyPlugins.so\\"',
127+
'GzDummyPlugins_LIB=\\"./test/libGzDummyPlugins.so\\"',
134128
],
135129
deps = [
136130
":core",
137131
":loader",
138-
GZ_ROOT + "plugin/test:test_plugins",
139-
"@gtest",
140-
"@gtest//:gtest_main",
132+
"//test:test_plugins",
133+
"@googletest//:gtest_main",
141134
],
142135
)

MODULE.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## MODULE.bazel
2+
module(
3+
name = "gz-plugin",
4+
repo_name = "org_gazebosim_gz-plugin",
5+
)
6+
7+
bazel_dep(name = "googletest", version = "1.14.0")
8+
bazel_dep(name = "rules_license", version = "1.0.0")
9+
10+
# Gazebo Dependencies
11+
bazel_dep(name = "rules_gazebo", version = "0.0.2")
12+
bazel_dep(name = "gz-utils")
13+
14+
archive_override(
15+
module_name = "gz-utils",
16+
strip_prefix = "gz-utils-gz-utils3",
17+
urls = ["https://github.com/gazebosim/gz-utils/archive/refs/heads/gz-utils3.tar.gz"],
18+
)

test/BUILD.bazel

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
load(
2-
"@gz//bazel/skylark:build_defs.bzl",
3-
"GZ_ROOT",
4-
"GZ_VISIBILITY",
1+
package(
2+
default_applicable_licenses = ["//:license"],
3+
features = [
4+
"layering_check",
5+
"parse_headers",
6+
],
57
)
68

79
cc_library(
@@ -26,7 +28,7 @@ cc_binary(
2628
linkshared = 1,
2729
deps = [
2830
":test_plugins_core",
29-
GZ_ROOT + "plugin:register",
31+
"//:register",
3032
],
3133
)
3234

@@ -39,7 +41,7 @@ cc_binary(
3941
linkshared = 1,
4042
deps = [
4143
":test_plugins_core",
42-
GZ_ROOT + "plugin:register",
44+
"//:register",
4345
],
4446
)
4547

@@ -52,7 +54,7 @@ cc_binary(
5254
linkshared = 1,
5355
deps = [
5456
":test_plugins_core",
55-
GZ_ROOT + "plugin:register",
57+
"//:register",
5658
],
5759
)
5860

@@ -65,7 +67,7 @@ cc_binary(
6567
linkshared = 1,
6668
deps = [
6769
":test_plugins_core",
68-
GZ_ROOT + "plugin:register",
70+
"//:register",
6971
],
7072
)
7173

@@ -78,7 +80,7 @@ cc_binary(
7880
linkshared = 1,
7981
deps = [
8082
":test_plugins_core",
81-
GZ_ROOT + "plugin:register",
83+
"//:register",
8284
],
8385
)
8486

@@ -91,7 +93,7 @@ cc_binary(
9193
linkshared = 1,
9294
deps = [
9395
":test_plugins_core",
94-
GZ_ROOT + "plugin:register",
96+
"//:register",
9597
],
9698
)
9799

@@ -104,7 +106,7 @@ cc_binary(
104106
linkshared = 1,
105107
deps = [
106108
":test_plugins_core",
107-
GZ_ROOT + "plugin:register",
109+
"//:register",
108110
],
109111
)
110112

@@ -118,7 +120,7 @@ cc_binary(
118120
linkshared = 1,
119121
deps = [
120122
":test_plugins_core",
121-
GZ_ROOT + "plugin:register",
123+
"//:register",
122124
],
123125
)
124126

@@ -136,16 +138,16 @@ cc_library(
136138
":libGzTemplatedPlugins.so",
137139
],
138140
defines = [
139-
'GzDummyPlugins_LIB=\\"./plugin/test/libGzDummyPlugins.so\\"',
140-
'GzFactoryPlugins_LIB=\\"./plugin/test/libGzFactoryPlugins.so\\"',
141-
'GzTemplatedPlugins_LIB=\\"./plugin/test/libGzTemplatedPlugins.so\\"',
142-
'GzBadPluginAlign_LIB=\\"./plugin/test/lbGzBadPluginAlign.so\\"',
143-
'GzBadPluginNoInfo_LIB=\\"./plugin/test/lbGzBadPluginNoInfo.so\\"',
144-
'GzBadPluginSize_LIB=\\"./plugin/test/lbGzBadPluginSize.so\\"',
145-
'GzBadPluginAPIVersionOld_LIB=\\"./plugin/test/lbGzBadPluginAPIVersionOld.so\\"',
146-
'GzBadPluginAPIVersionNew_LIB=\\"./plugin/test/lbGzBadPluginAPIVersionNew.so\\"',
147-
],
148-
visibility = GZ_VISIBILITY,
141+
'GzDummyPlugins_LIB=\\"./test/libGzDummyPlugins.so\\"',
142+
'GzFactoryPlugins_LIB=\\"./test/libGzFactoryPlugins.so\\"',
143+
'GzTemplatedPlugins_LIB=\\"./test/libGzTemplatedPlugins.so\\"',
144+
'GzBadPluginAlign_LIB=\\"./test/lbGzBadPluginAlign.so\\"',
145+
'GzBadPluginNoInfo_LIB=\\"./test/lbGzBadPluginNoInfo.so\\"',
146+
'GzBadPluginSize_LIB=\\"./test/lbGzBadPluginSize.so\\"',
147+
'GzBadPluginAPIVersionOld_LIB=\\"./test/lbGzBadPluginAPIVersionOld.so\\"',
148+
'GzBadPluginAPIVersionNew_LIB=\\"./test/lbGzBadPluginAPIVersionNew.so\\"',
149+
],
150+
visibility = ["//:__subpackages__"],
149151
deps = [
150152
":test_plugins_core",
151153
],
@@ -156,8 +158,8 @@ cc_test(
156158
srcs = ["integration/aliases.cc"],
157159
deps = [
158160
":test_plugins",
159-
GZ_ROOT + "plugin:loader",
160-
"@gtest//:gtest_main",
161+
"//:loader",
162+
"@googletest//:gtest_main",
161163
],
162164
)
163165

@@ -169,8 +171,8 @@ cc_test(
169171
],
170172
deps = [
171173
":test_plugins",
172-
GZ_ROOT + "plugin:loader",
173-
"@gtest//:gtest_main",
174+
"//:loader",
175+
"@googletest//:gtest_main",
174176
],
175177
)
176178

@@ -182,8 +184,8 @@ cc_test(
182184
],
183185
deps = [
184186
":test_plugins",
185-
GZ_ROOT + "plugin:loader",
186-
"@gtest//:gtest_main",
187+
"//:loader",
188+
"@googletest//:gtest_main",
187189
],
188190
)
189191

@@ -195,8 +197,8 @@ cc_test(
195197
],
196198
deps = [
197199
":test_plugins",
198-
GZ_ROOT + "plugin:loader",
199-
"@gtest//:gtest_main",
200+
"//:loader",
201+
"@googletest//:gtest_main",
200202
],
201203
)
202204

@@ -208,8 +210,8 @@ cc_test(
208210
],
209211
deps = [
210212
":test_plugins",
211-
GZ_ROOT + "plugin:loader",
212-
"@gtest//:gtest_main",
213+
"//:loader",
214+
"@googletest//:gtest_main",
213215
],
214216
)
215217

@@ -221,7 +223,7 @@ cc_test(
221223
],
222224
deps = [
223225
":test_plugins",
224-
GZ_ROOT + "plugin:loader",
225-
"@gtest//:gtest_main",
226+
"//:loader",
227+
"@googletest//:gtest_main",
226228
],
227229
)

0 commit comments

Comments
 (0)