From ea90ada5f5d9bce94ec07db3f345f0f313b7c733 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 6 Feb 2024 13:27:47 -0600 Subject: [PATCH] Revert "bazel: updates for garden (#513)" This reverts commit 10165398348111c0ac55e1af592c06fade1980a7. Signed-off-by: Michael Carroll --- BUILD.bazel | 130 ----------- bullet-featherstone/BUILD.bazel | 45 ---- dartsim/BUILD.bazel | 55 ----- include/gz/physics/config.hh.in | 1 - src/InstallationDirectories.cc | 24 +- test/BUILD.bazel | 269 ---------------------- test/common_test/CMakeLists.txt | 2 + test/include/test/TestLibLoader.hh | 28 +-- tpe/plugin/src/SimulationFeatures_TEST.cc | 1 + 9 files changed, 18 insertions(+), 537 deletions(-) delete mode 100644 BUILD.bazel delete mode 100644 bullet-featherstone/BUILD.bazel delete mode 100644 dartsim/BUILD.bazel delete mode 100644 test/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel deleted file mode 100644 index a4296ba48..000000000 --- a/BUILD.bazel +++ /dev/null @@ -1,130 +0,0 @@ -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 = "physics_config_hh", - 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", -]) - -sources = glob( - ["src/*.cc"], - exclude = [ - "src/*_TEST.cc", - ], -) - -gz_include_header( - name = "physics_hh_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 = [ - "heightmap/include/gz/physics/heightmap/HeightmapShape.hh", - "heightmap/include/gz/physics/heightmap/detail/HeightmapShape.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( - include = ["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:test_headers", - "@gtest", - "@gtest//:gtest_main", - ], -) for src in test_sources] diff --git a/bullet-featherstone/BUILD.bazel b/bullet-featherstone/BUILD.bazel deleted file mode 100644 index 1296d4658..000000000 --- a/bullet-featherstone/BUILD.bazel +++ /dev/null @@ -1,45 +0,0 @@ -load( - "@gz//bazel/skylark:build_defs.bzl", - "GZ_FEATURES", - "GZ_ROOT", - "GZ_VISIBILITY", -) - -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", - ], -) diff --git a/dartsim/BUILD.bazel b/dartsim/BUILD.bazel deleted file mode 100644 index 17a14c709..000000000 --- a/dartsim/BUILD.bazel +++ /dev/null @@ -1,55 +0,0 @@ -load( - "@gz//bazel/skylark:build_defs.bzl", - "GZ_FEATURES", - "GZ_ROOT", - "GZ_VISIBILITY", - "gz_configure_header", - "gz_export_header", - "gz_include_header", -) - -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", - ], -) diff --git a/include/gz/physics/config.hh.in b/include/gz/physics/config.hh.in index 332fb10e4..d0c68462d 100644 --- a/include/gz/physics/config.hh.in +++ b/include/gz/physics/config.hh.in @@ -27,7 +27,6 @@ #define GZ_PHYSICS_VERSION "${PROJECT_VERSION}" #define GZ_PHYSICS_VERSION_FULL "${PROJECT_VERSION_FULL}" -#define GZ_PHYSICS_VERSION_NAMESPACE v${PROJECT_VERSION_MAJOR} #define GZ_PHYSICS_ENGINE_INSTALL_DIR _Pragma ("GCC warning \"'GZ_PHYSICS_ENGINE_INSTALL_DIR' macro is deprecated, use gz::physics::getEngineInstallDir() function instead. \"") "${GZ_PHYSICS_ENGINE_INSTALL_DIR}" diff --git a/src/InstallationDirectories.cc b/src/InstallationDirectories.cc index 56735383f..7b9bcf459 100644 --- a/src/InstallationDirectories.cc +++ b/src/InstallationDirectories.cc @@ -28,7 +28,7 @@ namespace gz { namespace physics { -namespace { +inline namespace GZ_PHYSICS_VERSION_NAMESPACE { // We locally import the gz::common::joinPaths function // See https://github.com/gazebosim/gz-physics/pull/507#discussion_r1186919267 @@ -36,20 +36,19 @@ namespace { // Function imported from // https://github.com/gazebosim/gz-common/blob/ignition-common4_4.6.2/src/FilesystemBoost.cc#L507 -#ifndef _WIN32 -const char preferred_separator = '/'; +#ifndef WIN32 +static const char preferred_separator = '/'; #else // Windows static const char preferred_separator = '\\'; #endif -std::string separator(const std::string &_p) +const std::string separator(const std::string &_p) { return _p + preferred_separator; } -#ifdef _WIN32 // Function imported from // https://github.com/gazebosim/gz-common/blob/ignition-common4_4.6.2/src/Filesystem.cc#L227 -std::string checkWindowsPath(const std::string &_path) +std::string checkWindowsPath(const std::string _path) { if (_path.empty()) return _path; @@ -76,7 +75,6 @@ std::string checkWindowsPath(const std::string &_path) result, std::regex("[<>:\"|?*]"), ""); return result; } -#endif // Function imported from // https://github.com/gazebosim/gz-common/blob/ignition-common4_4.6.2/src/Filesystem.cc#L256 @@ -144,18 +142,14 @@ std::string joinPaths(const std::string &_path1, #endif // _WIN32 return path; } -} // namespace -inline namespace GZ_PHYSICS_VERSION_NAMESPACE { -#ifdef GZ_PHYSICS_BAZEL_BUILD -std::string getInstallPrefix() { return "physics"; } -#endif std::string getEngineInstallDir() { return gz::physics::joinPaths( getInstallPrefix(), GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR); } -} // namespace GZ_PHYSICS_VERSION_NAMESPACE -} // namespace physics -} // namespace gz + +} +} +} diff --git a/test/BUILD.bazel b/test/BUILD.bazel deleted file mode 100644 index 3bb662543..000000000 --- a/test/BUILD.bazel +++ /dev/null @@ -1,269 +0,0 @@ -load( - "@gz//bazel/skylark:build_defs.bzl", - "GZ_ROOT", - "GZ_VISIBILITY", -) - -cc_library( - name = "test_headers", - srcs = glob(["include/**/*.hh"]), - includes = ["include"], - visibility = GZ_VISIBILITY, - deps = [ - GZ_ROOT + "common", - GZ_ROOT + "common/testing", - GZ_ROOT + "physics", - GZ_ROOT + "plugin:loader", - ], -) - -cc_library( - name = "common_test", - hdrs = ["common_test/Worlds.hh"], - includes = ["common_test"], - data = [ - ":resources", - "common_test/worlds", - ], - deps = [ - ":test_headers", - ] -) - -cc_library( - name = "common_test_dartsim", - data = [ - GZ_ROOT + "physics/dartsim:libgz-physics-dartsim-plugin.so", - ], - deps = [ - ":common_test" - ] -) - -cc_library( - name = "common_test_bullet-featherstone", - data = [ - GZ_ROOT + "physics/bullet-featherstone:libgz-physics-bullet-featherstone-plugin.so", - ], - deps = [ - ":common_test" - ] -) - -physics_engines = [ - "dartsim", - "bullet-featherstone", -] - -[cc_test( - name = "addexternalforcetorque_%s" % engine, - srcs = [ - "common_test/addexternalforcetorque.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "basic_test_%s" % engine, - srcs = [ - "common_test/basic_test.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "collisions_%s" % engine, - srcs = [ - "common_test/collisions.cc", - ], - defines = [ - 'GZ_PHYSICS_RESOURCE_DIR=\\"physics/resources/\\"', - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "common/graphics", - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:mesh", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "construct_empty_world_%s" % engine, - srcs = [ - "common_test/construct_empty_world.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "free_joint_features_%s" % engine, - srcs = [ - "common_test/free_joint_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "joint_features_%s" % engine, - srcs = [ - "common_test/joint_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "kinematic_features_%s" % engine, - srcs = [ - "common_test/kinematic_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "physics:sdf", - "@eigen3", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "link_features_%s" % engine, - srcs = [ - "common_test/link_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "shape_features_%s" % engine, - srcs = [ - "common_test/shape_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "simulation_features_%s" % engine, - srcs = [ - "common_test/simulation_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -[cc_test( - name = "world_features_%s" % engine, - srcs = [ - "common_test/world_features.cc", - ], - env = { - "GZ_BAZEL": "1", - "GZ_BAZEL_PATH": "physics", - "LIB_TO_TEST": "physics/%s/libgz-physics-%s-plugin.so" % (engine, engine), - }, - deps = [ - ":common_test_%s" % engine, - GZ_ROOT + "math/eigen3", - GZ_ROOT + "physics:sdf", - "@gtest", - "@gtest//:gtest_main", - ], -) for engine in physics_engines] - -exports_files(["resources"]) diff --git a/test/common_test/CMakeLists.txt b/test/common_test/CMakeLists.txt index 49c904635..a35e2127a 100644 --- a/test/common_test/CMakeLists.txt +++ b/test/common_test/CMakeLists.txt @@ -44,6 +44,7 @@ function(configure_common_test PHYSICS_ENGINE_NAME test_name) endif() endfunction() + # Get bullet version using pkg_check_modules as it is not available # through the cmake module gz_pkg_check_modules_quiet(bullet_version_check "bullet") @@ -70,6 +71,7 @@ foreach(test ${tests}) ) endif() + install(TARGETS ${test_executable} DESTINATION ${TEST_INSTALL_DIR}) configure_common_test("bullet" ${test_executable}) configure_common_test("bullet-featherstone" ${test_executable}) diff --git a/test/include/test/TestLibLoader.hh b/test/include/test/TestLibLoader.hh index b07d05528..a7f27abd3 100644 --- a/test/include/test/TestLibLoader.hh +++ b/test/include/test/TestLibLoader.hh @@ -41,29 +41,13 @@ class TestLibLoader { if (argc != 2) { - std::string envLibToTest; - if(!gz::utils::env("LIB_TO_TEST", envLibToTest)) - { - std::cerr << "Please provide the path to an engine plugin.\n" - << "Usage " << argv[0] << " \n"; - return false; - } - else - { - std::string &libToTest = LibToTest(); - libToTest = envLibToTest; - - std::cout << std::filesystem::current_path() << std::endl; - std::cout << envLibToTest << std::endl; - return true; - } - } - else - { - std::string &libToTest = LibToTest(); - libToTest = argv[1]; - return true; + std::cerr << "Please provide the path to an engine plugin.\n" + << "Usage " << argv[0] << " \n"; + return false; } + std::string &libToTest = LibToTest(); + libToTest = argv[1]; + return true; } /// \brief Get the name of the library to test diff --git a/tpe/plugin/src/SimulationFeatures_TEST.cc b/tpe/plugin/src/SimulationFeatures_TEST.cc index 25fff9ecc..ddecee5de 100644 --- a/tpe/plugin/src/SimulationFeatures_TEST.cc +++ b/tpe/plugin/src/SimulationFeatures_TEST.cc @@ -52,6 +52,7 @@ #include "World.hh" + using namespace gz; struct TestFeatureList : physics::FeatureList<