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 (minus ABI break) #598

Open
wants to merge 12 commits into
base: gz-physics6
Choose a base branch
from
140 changes: 140 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [GZ_ROOT + "physics:license"],
default_visibility = GZ_VISIBILITY,
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved
features = GZ_FEATURES,
)

license(
name = "license",
package_name = "gz-physics",
)

licenses(["notice"])

exports_files(["LICENSE"])

gz_configure_header(
name = "config",
src = "include/gz/physics/config.hh.in",
cmakelists = ["CMakeLists.txt"],
defines = {
# These definitions are unused,
# this is merely to suppress generator warnings
"GZ_PHYSICS_ENGINE_INSTALL_DIR": "unused",
},
package = "physics",
)

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

public_headers_no_gen = glob([
"include/gz/physics/*.hh",
"include/gz/physics/detail/*.hh",
])
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved

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

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

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

cc_library(
name = "physics",
srcs = sources,
hdrs = public_headers,
defines = [
'GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR=\\"unused\\"',
"GZ_PHYSICS_BAZEL_BUILD=true",
],
includes = ["include"],
deps = [
GZ_ROOT + "math",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "plugin:core",
GZ_ROOT + "plugin:loader",
GZ_ROOT + "utils",
],
)

cc_library(
name = "heightmap",
hdrs = glob([
"heightmap/include/gz/physics/heightmap/**/*.hh",
]),
includes = ["heightmap/include"],
)

cc_library(
name = "mesh",
hdrs = [
"mesh/include/gz/physics/mesh/MeshShape.hh",
"mesh/include/gz/physics/mesh/detail/MeshShape.hh",
],
includes = ["mesh/include"],
)

cc_library(
name = "sdf",
hdrs = glob([
"sdf/include/gz/physics/sdf/*.hh",
]),
includes = ["sdf/include"],
deps = [
GZ_ROOT + "sdformat",
],
)

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

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
deps = [
":physics",
GZ_ROOT + "physics/test:common_test",
"@gtest",
"@gtest//:gtest_main",
],
) for src in test_sources]

add_lint_tests()
50 changes: 50 additions & 0 deletions bullet-featherstone/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_ROOT",
"GZ_VISIBILITY",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)

private_headers = glob(["src/*.hh"])

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

cc_library(
name = "bullet-featherstone",
srcs = sources + private_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "common/graphics",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "third_party/bullet3:BulletCollision",
GZ_ROOT + "third_party/bullet3:BulletDynamics",
],
)

cc_binary(
name = "libgz-physics-bullet-featherstone-plugin.so",
srcs = [
"src/plugin.cc",
],
linkshared = True,
visibility = GZ_VISIBILITY,
deps = [
":bullet-featherstone",
GZ_ROOT + "plugin:register",
],
)

add_lint_tests()
206 changes: 206 additions & 0 deletions dartsim/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)

public_headers = ["include/gz/physics/dartsim/World.hh"]

private_headers = glob(["src/*.hh"])

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

cc_library(
name = "dartsim",
srcs = sources + private_headers,
hdrs = public_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "common/geospatial",
GZ_ROOT + "common/profiler",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:heightmap",
GZ_ROOT + "physics:mesh",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "third_party/dart:simulation",
GZ_ROOT + "third_party/dart:collision-bullet",
GZ_ROOT + "third_party/dart:collision-ode",
],
)

cc_binary(
name = "libgz-physics-dartsim-plugin.so",
srcs = [
"src/plugin.cc",
],
linkshared = True,
visibility = GZ_VISIBILITY,
deps = [
":dartsim",
GZ_ROOT + "plugin:register",
],
)
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved

# AddedMassFeatures_TEST must directly link with dart:simulation
cc_test(
name = "AddedMassFeatures_TEST",
srcs = ["src/AddedMassFeatures_TEST.cc"] + private_headers + public_headers, # noqa: 501
copts = ["-fexceptions"],
data = [
"worlds",
":libgz-physics-dartsim-plugin.so",
GZ_ROOT + "physics/test:resources",
],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
includes = [
"include",
"src",
],
local_defines = [
"TEST_WORLD_DIR='\"physics/dartsim/worlds/\"'",
"GZ_PHYSICS_RESOURCE_DIR='\"physics/test/resources/\"'",
"dartsim_plugin_LIB='\"physics/dartsim/libgz-physics-dartsim-plugin.so\"'", # noqa: 501
],
deps = [
GZ_ROOT + "common/geospatial",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:heightmap",
GZ_ROOT + "physics:mesh",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "physics/test:common_test",
GZ_ROOT + "third_party/dart:simulation",
"@gtest",
"@gtest//:gtest_main",
],
)

# Base_TEST directly links against the dartsim library while the others
# load the plugin library via gz-plugin
cc_test(
name = "Base_TEST",
srcs = ["src/Base_TEST.cc"] + private_headers + public_headers,
copts = ["-fexceptions"],
data = [
"worlds",
GZ_ROOT + "physics/test:resources",
],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
includes = [
"include",
"src",
],
deps = [
":dartsim",
GZ_ROOT + "physics/test:common_test",
"@gtest",
"@gtest//:gtest_main",
],
)

# SDFFeatures_TEST must directly link with dart:simulation
cc_test(
name = "SDFFeatures_TEST.cc",
srcs = ["src/SDFFeatures_TEST.cc"] + private_headers + public_headers,
copts = ["-fexceptions"],
data = [
"worlds",
":libgz-physics-dartsim-plugin.so",
GZ_ROOT + "physics/test:resources",
],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
includes = [
"include",
"src",
],
local_defines = [
"TEST_WORLD_DIR='\"physics/dartsim/worlds/\"'",
"GZ_PHYSICS_RESOURCE_DIR='\"physics/test/resources/\"'",
"dartsim_plugin_LIB='\"physics/dartsim/libgz-physics-dartsim-plugin.so\"'", # noqa: 501
],
deps = [
GZ_ROOT + "common/geospatial",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:heightmap",
GZ_ROOT + "physics:mesh",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "physics/test:common_test",
GZ_ROOT + "third_party/dart:simulation",
"@gtest",
"@gtest//:gtest_main",
],
)

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

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src] + private_headers + public_headers,
copts = ["-fexceptions"],
data = [
"worlds",
":libgz-physics-dartsim-plugin.so",
GZ_ROOT + "physics/test:resources",
],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
includes = [
"include",
"src",
],
local_defines = [
"TEST_WORLD_DIR='\"physics/dartsim/worlds/\"'",
"GZ_PHYSICS_RESOURCE_DIR='\"physics/test/resources/\"'",
"dartsim_plugin_LIB='\"physics/dartsim/libgz-physics-dartsim-plugin.so\"'", # noqa: 501
],
deps = [
GZ_ROOT + "common/geospatial",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:heightmap",
GZ_ROOT + "physics:mesh",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "physics/test:common_test",
GZ_ROOT + "third_party/dart:constraint_headers",
GZ_ROOT + "third_party/dart:simulation_headers",
"@gtest",
"@gtest//:gtest_main",
],
) for src in test_sources]

add_lint_tests()
Loading