Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel updates for Garden #354

Draft
wants to merge 2 commits into
base: gz-sensors7
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)

package(
default_visibility = GZ_VISIBILITY,
features = GZ_FEATURES,
)

licenses(["notice"]) # Apache-2.0

exports_files(["LICENSE"])

gz_configure_header(
name = "sensors_config_hh",
src = "include/gz/sensors/config.hh.in",
cmakelists = ["CMakeLists.txt"],
package = "sensors",
)

gz_export_header(
name = "include/gz/sensors/Export.hh",
export_base = "GZ_SENSORS",
lib_name = "gz-sensors",
visibility = ["//visibility:private"],
)

sensors_to_generate = [
"altimeter",
"camera",
"force_torque",
"gpu_lidar",
"imu",
"lidar",
"magnetometer",
"navsat",
"air_pressure",
"logical_camera",
"wide_angle_camera",
"rgbd_camera",
"air_speed",
"thermal_camera",
"rendering",
"depth_camera",
"boundingbox_camera",
"segmentation_camera",
]

[
gz_export_header(
name = "include/gz/sensors/%s/Export.hh" % sensor,
export_base = "GZ_SENSORS_%s" % sensor.upper(),
lib_name = "gz-sensors-%s" % sensor,
visibility = ["//visibility:private"],
)
for sensor in sensors_to_generate
]

export_headers = ["include/gz/sensors/%s/Export.hh" % sensor for sensor in sensors_to_generate]

public_headers_no_gen = glob([
"include/gz/sensors/*.hh",
])

sources = glob(
[
"src/*.cc",
"src/*.hh",
],
exclude = [
"src/*_TEST.cc",
],
)

gz_include_header(
name = "sensors_hh_genrule",
out = "include/gz/sensors.hh",
hdrs = public_headers_no_gen + [
"include/gz/sensors/config.hh",
"include/gz/sensors/Export.hh",
] + export_headers,
)

public_headers = public_headers_no_gen + [
"include/gz/sensors/config.hh",
"include/gz/sensors/Export.hh",
] + export_headers

cc_library(
name = "sensors",
srcs = sources,
hdrs = public_headers,
includes = ["include"],
deps = [
GZ_ROOT + "msgs",
GZ_ROOT + "rendering",
GZ_ROOT + "sdformat",
GZ_ROOT + "transport",
GZ_ROOT + "common/profiler",
],
)

test_sources = glob(
include = ["src/*_TEST.cc"],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "sensors",
},
data = glob([
"test/sdf/*.sdf"
]),
deps = [
":sensors",
GZ_ROOT + "common/testing",
"@gtest",
"@gtest//:gtest_main",
],
) for src in test_sources]
5 changes: 2 additions & 3 deletions src/Util_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include <gtest/gtest.h>
#include <gz/common/Console.hh>
#include <gz/common/Filesystem.hh>
#include <gz/common/testing/TestPaths.hh>
#include <sdf/Root.hh>
#include <sdf/Link.hh>
#include <sdf/Model.hh>
#include <sdf/World.hh>

#include "test_config.hh" // NOLINT(build/include)
#include "gz/sensors/Util.hh"

/// \brief Test Util functions
Expand All @@ -42,8 +42,7 @@ using namespace sensors;
//////////////////////////////////////////////////
TEST_F(Util_TEST, customType)
{
auto sdfFile = gz::common::joinPaths(PROJECT_SOURCE_PATH, "test",
"sdf", "custom_sensors.sdf");
auto sdfFile = gz::common::testing::TestFile("sdf", "custom_sensors.sdf");

sdf::Root root;
auto errors = root.Load(sdfFile);
Expand Down