Skip to content

Commit fc736ea

Browse files
authored
bzlmod migration Part 2 - Enable graphics and geospatial component (#681)
Signed-off-by: Ian Chen <[email protected]>
1 parent 3251c6a commit fc736ea

File tree

12 files changed

+138
-118
lines changed

12 files changed

+138
-118
lines changed

BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ gz_export_header(
3838
public_headers_no_gen = glob([
3939
"include/gz/common/*.hh",
4040
"include/gz/common/detail/*.hh",
41-
"include/gz/common/graph/*.hh",
4241
])
4342

4443
private_headers = glob(

MODULE.bazel

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ module(
44
repo_name = "org_gazebosim_gz-common",
55
)
66

7+
bazel_dep(name = "assimp", version = "5.4.3")
78
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
9+
bazel_dep(name = "cdt", version = "1.4.0")
10+
bazel_dep(name = "freeimage", version = "3.19.10")
811
bazel_dep(name = "googletest", version = "1.14.0")
12+
bazel_dep(name = "remotery", version = "1.0.0")
913
bazel_dep(name = "rules_license", version = "1.0.0")
1014
bazel_dep(name = "tinyxml2", version = "10.0.0")
1115
bazel_dep(name = "libuuid", version = "2.39.3.bcr.1")
@@ -17,12 +21,12 @@ bazel_dep(name = "gz-math")
1721

1822
archive_override(
1923
module_name = "gz-utils",
20-
strip_prefix = "gz-utils-main",
21-
urls = ["https://github.com/gazebosim/gz-utils/archive/refs/heads/main.tar.gz"],
24+
strip_prefix = "gz-utils-gz-utils3",
25+
urls = ["https://github.com/gazebosim/gz-utils/archive/refs/heads/gz-utils3.tar.gz"],
2226
)
2327

2428
archive_override(
2529
module_name = "gz-math",
26-
strip_prefix = "gz-math-main",
27-
urls = ["https://github.com/gazebosim/gz-math/archive/refs/heads/main.tar.gz"],
30+
strip_prefix = "gz-math-gz-math8",
31+
urls = ["https://github.com/gazebosim/gz-math/archive/refs/heads/gz-math8.tar.gz"],
2832
)

av/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],
@@ -32,6 +31,7 @@ public_headers = public_headers_no_gen + [
3231
"include/gz/common/av/Export.hh",
3332
]
3433

34+
# \todo(iche033) Add av component once ffmpeg dep is available in BCR
3535
# cc_library(
3636
# name = "av",
3737
# srcs = sources,

events/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],

geospatial/BUILD.bazel

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],
@@ -9,17 +8,27 @@ package(
98
],
109
)
1110

12-
public_headers_no_gen = glob([
13-
"include/gz/common/*.hh",
14-
"include/gz/common/**/*.hh",
15-
])
11+
public_headers_no_gen = glob(
12+
include = [
13+
"include/gz/common/**/*.hh",
14+
],
15+
exclude = ["include/gz/common/geospatial/Dem.hh"],
16+
)
1617

1718
sources = glob(
18-
["src/*.cc"],
19-
exclude = ["src/*_TEST.cc"],
19+
include = ["src/*.cc"],
20+
exclude = [
21+
"src/*_TEST.cc",
22+
# \todo(iche033) include Dem.cc once gdal dep is available.
23+
"src/Dem.cc"
24+
],
2025
)
2126

22-
test_sources = glob(["src/*_TEST.cc"])
27+
test_sources = glob(
28+
include = ["src/*_TEST.cc"],
29+
# \todo(iche033) include this test once gdal dep is available.
30+
exclude = ["src/Dem_TEST.cc"]
31+
)
2332

2433
gz_export_header(
2534
name = "Export",
@@ -32,35 +41,44 @@ public_headers = public_headers_no_gen + [
3241
"include/gz/common/geospatial/Export.hh",
3342
]
3443

35-
# cc_library(
36-
# name = "geospatial",
37-
# srcs = sources,
38-
# hdrs = public_headers,
39-
# copts = [
40-
# "-Wno-unused-value",
41-
# "-fexceptions",
42-
# ],
43-
# includes = ["include"],
44-
# visibility = ["//visibility:public"],
45-
# deps = [
46-
# "//:gz-common",
47-
# "//graphics:graphics",
48-
# "@gz-utils//:ImplPtr",
49-
# "@gdal",
50-
# ],
51-
# )
52-
#
53-
# [cc_test(
54-
# name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
55-
# srcs = [src],
56-
# data = ["//test:data"],
57-
# env = {
58-
# "GZ_BAZEL": "1",
59-
# },
60-
# deps = [
61-
# ":geospatial",
62-
# "//testing:testing",
63-
# "@googletest//:gtest",
64-
# "@googletest//:gtest_main",
65-
# ],
66-
# ) for src in test_sources]
44+
cc_library(
45+
name = "geospatial",
46+
srcs = sources,
47+
hdrs = public_headers,
48+
copts = [
49+
"-Wno-unused-value",
50+
"-fexceptions",
51+
],
52+
includes = ["include"],
53+
visibility = ["//visibility:public"],
54+
deps = [
55+
"//:gz-common",
56+
"//graphics:graphics",
57+
"@gz-utils//:ImplPtr",
58+
# \todo(iche033) gdal is not in BCR yet
59+
# "@gdal",
60+
],
61+
# \todo(iche033) remove this macro once gdal dep is available.
62+
defines = [
63+
"BAZEL_DISABLE_DEM_LOADER=1"
64+
]
65+
)
66+
67+
[cc_test(
68+
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
69+
srcs = [src],
70+
data = ["//test:data"],
71+
env = {
72+
"GZ_BAZEL": "1",
73+
},
74+
deps = [
75+
":geospatial",
76+
"//testing:testing",
77+
"@googletest//:gtest",
78+
"@googletest//:gtest_main",
79+
],
80+
# \todo(iche033) remove this macro once gdal dep is available.
81+
defines = [
82+
"BAZEL_DISABLE_DEM_LOADER=1"
83+
]
84+
) for src in test_sources]

geospatial/src/HeightmapUtil.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include "gz/common/StringUtils.hh"
2525
#include "gz/common/Util.hh"
2626

27+
#ifndef BAZEL_DISABLE_DEM_LOADER
2728
#include "gz/common/geospatial/Dem.hh"
29+
#endif
30+
2831
#include "gz/common/geospatial/HeightmapUtil.hh"
2932
#include "gz/common/geospatial/ImageHeightmap.hh"
3033

@@ -69,6 +72,9 @@ std::unique_ptr<HeightmapData> loadHeightmapData(
6972
}
7073
else
7174
{
75+
// This macro is used by bazel build only. Dem classes are not built
76+
// due to missing gdal dependency in BCR. So diable loading Dem heightmaps.
77+
#ifndef BAZEL_DISABLE_DEM_LOADER
7278
// try loading as DEM
7379
auto dem = std::make_unique<Dem>();
7480
dem->SetSphericalCoordinates(_sphericalCoordinates);
@@ -79,6 +85,10 @@ std::unique_ptr<HeightmapData> loadHeightmapData(
7985
return nullptr;
8086
}
8187
data = std::move(dem);
88+
#else
89+
(void)_sphericalCoordinates;
90+
gzerr << "Unable to load heightmap. DEM loading disabled." << std::endl;
91+
#endif
8292
}
8393

8494
return data;

geospatial/src/HeightmapUtil_TEST.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ TEST_F(HeightmapLoaderTest, LoadImage)
5151
EXPECT_NE(nullptr, data);
5252
}
5353

54+
#ifndef BAZEL_DISABLE_DEM_LOADER
5455
/////////////////////////////////////////////////
5556
TEST_F(HeightmapLoaderTest, LoadDEM)
5657
{
@@ -59,6 +60,7 @@ TEST_F(HeightmapLoaderTest, LoadDEM)
5960
common::loadHeightmapData(path);
6061
EXPECT_NE(nullptr, data);
6162
}
63+
#endif
6264

6365
/////////////////////////////////////////////////
6466
TEST_F(HeightmapLoaderTest, LoadInvalidFile)

graphics/BUILD.bazel

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],
@@ -14,7 +13,8 @@ public_headers_no_gen = glob([
1413
"include/gz/common/**/*.hh",
1514
])
1615

17-
private_headers = glob(["src/VHACD/*.h"])
16+
vhacd_header = ["src/VHACD/VHACD.h"]
17+
tiny_obj_loader_header = ["src/tiny_obj_loader.h"]
1818

1919
sources = glob(
2020
["src/*.cc"],
@@ -32,42 +32,39 @@ gz_export_header(
3232

3333
public_headers = public_headers_no_gen + [
3434
"include/gz/common/graphics/Export.hh",
35-
"src/tiny_obj_loader.h",
3635
]
3736

38-
# cc_library(
39-
# name = "graphics",
40-
# srcs = sources + private_headers,
41-
# hdrs = public_headers,
42-
# copts = [
43-
# "-Wno-implicit-fallthrough",
44-
# "-Wno-unused-value",
45-
# ],
46-
# includes = ["include"],
47-
# visibility = ["//visibility:public"],
48-
# deps = [
49-
# "//:gz-common",
50-
# "@gz-utils//:ImplPtr",
51-
# #"@assimp",
52-
# #"@freeimage//:freeimage",
53-
# #"@glib",
54-
# #"@gts",
55-
# "@tinyxml2",
56-
# ],
57-
# )
58-
#
59-
# [cc_test(
60-
# name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
61-
# srcs = [src],
62-
# data = ["//test:data"],
63-
# env = {
64-
# "GZ_BAZEL": "1",
65-
# },
66-
# deps = [
67-
# ":graphics",
68-
# GZ_ROOT + "common/testing",
69-
# "//testing:testing",
70-
# "@googletest//:gtest",
71-
# "@googletest//:gtest_main",
72-
# ],
73-
# ) for src in test_sources]
37+
cc_library(
38+
name = "graphics",
39+
srcs = sources + vhacd_header + tiny_obj_loader_header,
40+
hdrs = public_headers,
41+
copts = [
42+
"-Wno-implicit-fallthrough",
43+
"-Wno-unused-value",
44+
],
45+
includes = ["include"],
46+
visibility = ["//visibility:public"],
47+
deps = [
48+
"//:gz-common",
49+
"@assimp",
50+
"@cdt",
51+
"@freeimage//:freeimage",
52+
"@gz-utils//:ImplPtr",
53+
"@tinyxml2",
54+
],
55+
)
56+
57+
[cc_test(
58+
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
59+
srcs = [src],
60+
data = ["//test:data"],
61+
env = {
62+
"GZ_BAZEL": "1",
63+
},
64+
deps = [
65+
":graphics",
66+
"//testing:testing",
67+
"@googletest//:gtest",
68+
"@googletest//:gtest_main",
69+
],
70+
) for src in test_sources]

io/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],

profiler/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
2-
load("@rules_license//rules:license.bzl", "license")
32

43
package(
54
default_applicable_licenses = ["//:license"],
@@ -63,13 +62,6 @@ private_headers = [
6362
"include/RemoteryConfig.h",
6463
]
6564

66-
cc_library(
67-
name = "remotery",
68-
srcs = ["src/Remotery/lib/Remotery.c"],
69-
hdrs = ["src/Remotery/lib/Remotery.h"],
70-
includes = ["src/Remotery/lib"],
71-
)
72-
7365
cc_library(
7466
name = "profiler",
7567
srcs = sources,
@@ -82,7 +74,7 @@ cc_library(
8274
visibility = ["//visibility:public"],
8375
deps = [
8476
"//:gz-common",
85-
":remotery",
77+
"@remotery",
8678
],
8779
)
8880

0 commit comments

Comments
 (0)