diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 000000000..54221ec94 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,232 @@ +load( + "//ign_bazel:cmake_configure_file.bzl", + "cmake_configure_file", +) +load( + "//ign_bazel:generate_include_header.bzl", + "generate_include_header", +) +load( + "//ign_bazel:generate_file.bzl", + "generate_file", +) + +package(default_visibility = ["//visibility:public"]) + +RESOURCE_PATH = "~/.ignition" +PROJECT_NAME = "ignition-physics" +PROJECT_MAJOR = 2 +PROJECT_MINOR = 1 +PROJECT_PATCH = 0 +IGN_DESIGNATION_UPPER = "TEST" +PHYSICS_ENGINE_INSTALL_DIR = "/tmp" + +# Generates config.hh based on the version numbers in CMake code. +cmake_configure_file( + name = "config", + src = "include/ignition/physics/config.hh.in", + out = "include/ignition/physics/config.hh", + cmakelists = ["CMakeLists.txt"], + defines = [ + "PROJECT_VERSION_MAJOR=%d" % (PROJECT_MAJOR), + "PROJECT_VERSION_MINOR=%d" % (PROJECT_MINOR), + "PROJECT_VERSION_PATCH=%d" % (PROJECT_PATCH), + "PROJECT_MAJOR_VERSION=%d" % (PROJECT_MAJOR), + "PROJECT_MINOR_VERSION=%d" % (PROJECT_MINOR), + "PROJECT_PATCH_VERSION=%d" % (PROJECT_PATCH), + "PROJECT_VERSION=%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR), + "PROJECT_VERSION_FULL=%d.%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), # noqa + "PROJECT_NAME_NO_VERSION=%s" % (PROJECT_NAME), + "PROJECT_NAME=%s" % (PROJECT_NAME), + "IGN_PROJECT_NAME=%s" % (PROJECT_NAME), + "IGN_RENDERING_RESOURCE_PATH=%s" % (RESOURCE_PATH), + "IGN_DESIGNATION_UPPER=%s" % (IGN_DESIGNATION_UPPER), + "IGNITION_PHYSICS_ENGINE_INSTALL_DIR=%s" % (PHYSICS_ENGINE_INSTALL_DIR), + ], + visibility = ["//visibility:private"], +) + +generate_file( + name = "include/ignition/physics/Export.hh", + content = """ +#pragma once +// IGN_DEPRECATED is defined by all ignition libraries, but the version below +// is a simplified version. When mixing the regular ignition libraries and +// the drake compiled ignition libraries, the compiler throws a warning about +// the macro being multiply defined. We undefine it before redefining it here +// to work around that issue. Note that the IGNITION_PHYSICS_VISIBLE macro +// shouldn't be defined multiple times, but we undefine it just in case. +#ifdef IGNITION_PHYSICS_VISIBLE +#undef IGNITION_PHYSICS_VISIBLE +#endif +#define IGNITION_PHYSICS_VISIBLE __attribute__ ((visibility("default"))) +#ifdef IGN_DEPRECATED +#undef IGN_DEPRECATED +#endif +#define IGN_DEPRECATED(version) __attribute__ ((__deprecated__)) + """, + visibility = ["//visibility:private"], +) + +public_headers_no_gen = [ + "include/ignition/physics/BoxShape.hh", + "include/ignition/physics/CanReadData.hh", + "include/ignition/physics/CanWriteData.hh", + "include/ignition/physics/Cloneable.hh", + "include/ignition/physics/CompositeData.hh", + "include/ignition/physics/ConstructEmpty.hh", + "include/ignition/physics/CylinderShape.hh", + "include/ignition/physics/DataStatusMask.hh", + "include/ignition/physics/DeclareJointType.hh", + "include/ignition/physics/DeclareShapeType.hh", + "include/ignition/physics/Entity.hh", + "include/ignition/physics/Feature.hh", + "include/ignition/physics/FeatureList.hh", + "include/ignition/physics/FeaturePolicy.hh", + "include/ignition/physics/FindFeatures.hh", + "include/ignition/physics/FixedJoint.hh", + "include/ignition/physics/ForwardStep.hh", + "include/ignition/physics/FrameData.hh", + "include/ignition/physics/FrameID.hh", + "include/ignition/physics/FrameSemantics.hh", + "include/ignition/physics/FreeGroup.hh", + "include/ignition/physics/FreeJoint.hh", + "include/ignition/physics/Geometry.hh", + "include/ignition/physics/GetBoundingBox.hh", + "include/ignition/physics/GetContacts.hh", + "include/ignition/physics/GetEntities.hh", + "include/ignition/physics/Implements.hh", + "include/ignition/physics/Joint.hh", + "include/ignition/physics/Link.hh", + "include/ignition/physics/OperateOnSpecifiedData.hh", + "include/ignition/physics/PlaneShape.hh", + "include/ignition/physics/PrismaticJoint.hh", + "include/ignition/physics/Register.hh", + "include/ignition/physics/RegisterMore.hh", + "include/ignition/physics/RelativeQuantity.hh", + "include/ignition/physics/RemoveEntities.hh", + "include/ignition/physics/RequestEngine.hh", + "include/ignition/physics/RequestFeatures.hh", + "include/ignition/physics/RevoluteJoint.hh", + "include/ignition/physics/Shape.hh", + "include/ignition/physics/SpecifyData.hh", + "include/ignition/physics/SphereShape.hh", + "include/ignition/physics/TemplateHelpers.hh", + "include/ignition/physics/detail/BoxShape.hh", + "include/ignition/physics/detail/CanReadData.hh", + "include/ignition/physics/detail/CanWriteData.hh", + "include/ignition/physics/detail/Cloneable.hh", + "include/ignition/physics/detail/CompositeData.hh", + "include/ignition/physics/detail/ConstructEmpty.hh", + "include/ignition/physics/detail/CylinderShape.hh", + "include/ignition/physics/detail/DeclareDerivedType.hh", + "include/ignition/physics/detail/Entity.hh", + "include/ignition/physics/detail/FeatureList.hh", + "include/ignition/physics/detail/FindFeatures.hh", + "include/ignition/physics/detail/FixedJoint.hh", + "include/ignition/physics/detail/FrameData.hh", + "include/ignition/physics/detail/FrameSemantics.hh", + "include/ignition/physics/detail/FreeGroup.hh", + "include/ignition/physics/detail/FreeJoint.hh", + "include/ignition/physics/detail/GetBoundingBox.hh", + "include/ignition/physics/detail/GetContacts.hh", + "include/ignition/physics/detail/GetEntities.hh", + "include/ignition/physics/detail/Identity.hh", + "include/ignition/physics/detail/InspectFeatures.hh", + "include/ignition/physics/detail/Joint.hh", + "include/ignition/physics/detail/Link.hh", + "include/ignition/physics/detail/OperateOnSpecifiedData.hh", + "include/ignition/physics/detail/PlaneShape.hh", + "include/ignition/physics/detail/PrismaticJoint.hh", + "include/ignition/physics/detail/PrivateSpecifyData.hh", + "include/ignition/physics/detail/Register.hh", + "include/ignition/physics/detail/RelativeQuantity.hh", + "include/ignition/physics/detail/RemoveEntities.hh", + "include/ignition/physics/detail/RequestEngine.hh", + "include/ignition/physics/detail/RequestFeatures.hh", + "include/ignition/physics/detail/RevoluteJoint.hh", + "include/ignition/physics/detail/Shape.hh", + "include/ignition/physics/detail/SpecifyData.hh", + "include/ignition/physics/detail/SphereShape.hh", +] + +test_sources = [ + "src/Cloneable_TEST.cc", + "src/CompositeData_TEST.cc", + "src/FeatureList_TEST.cc", + "src/Feature_TEST.cc", + "src/FindFeatures_TEST.cc", + "src/SpecifyData_TEST.cc", +] + +sources = [ + "src/CanReadData.cc", + "src/CanWriteData.cc", + "src/CompositeData.cc", + "src/DataStatusMask.cc", + "src/FrameID.cc", + "src/Identity.cc", +] + +generate_include_header( + name = "physicshh_genrule", + out = "include/ignition/physics.hh", + hdrs = public_headers_no_gen + [ + "include/ignition/physics/config.hh", + "include/ignition/physics/Export.hh", + ], +) + +public_headers = public_headers_no_gen + [ + "include/ignition/physics/config.hh", + "include/ignition/physics/Export.hh", + "include/ignition/physics.hh", + "src/utils/TestDataTypes.hh", + "src/TestUtilities.hh", +] + +cc_binary( + name = "libignition-physics2.so", + srcs = sources + public_headers, + includes = ["include", "src"], + linkopts = ["-Wl,-soname,libignition-physics2.so"], + linkshared = True, + visibility = [], + deps = [ + "//ign_common", + "//ign_common/graphics", + "//ign_common/events", + "//ign_plugin/loader", + "//ign_plugin/core:ign_plugin", + "//ign_math", + "//ign_bazel:utilities", + ], +) + +cc_library( + name = "ign_physics", + srcs = ["libignition-physics2.so"], + hdrs = public_headers, + includes = ["include"], + deps = [ + "//ign_plugin/loader", + ], + visibility = ["//visibility:public"], +) + +[cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), + srcs = [src], + deps = [ + ":ign_physics", + "//ign_physics/test:test_utils", + "//ign_math", + "//ign_bazel:utilities", + "//ign_plugin/core:ign_plugin", + "//ign_plugin/loader", + "@gtest//:gtest", + "@gtest//:gtest_main", + ] +) for src in test_sources] + +exports_files(["resources"]) diff --git a/dartsim/BUILD.bazel b/dartsim/BUILD.bazel new file mode 100644 index 000000000..5b565dba9 --- /dev/null +++ b/dartsim/BUILD.bazel @@ -0,0 +1,109 @@ +load( + "//ign_bazel:cmake_configure_file.bzl", + "cmake_configure_file", +) +load( + "//ign_bazel:generate_include_header.bzl", + "generate_include_header", +) +load( + "//ign_bazel:generate_file.bzl", + "generate_file", +) + +test_sources = [ + "src/Base_TEST.cc", + "src/Collisions_TEST.cc", + "src/EntityManagement_TEST.cc", + "src/JointFeatures_TEST.cc", + "src/LinkFeatures_TEST.cc", + "src/SDFFeatures_TEST.cc", + "src/SimulationFeatures_TEST.cc", +] + +sources = [ + "src/CustomFeatures.cc", + "src/CustomMeshShape.cc", + "src/EntityManagementFeatures.cc", + "src/FreeGroupFeatures.cc", + "src/JointFeatures.cc", + "src/KinematicsFeatures.cc", + "src/LinkFeatures.cc", + "src/plugin.cc", + "src/SDFFeatures.cc", + "src/ShapeFeatures.cc", + "src/SimulationFeatures.cc", +] + +public_headers = [ + "src/Base.hh", + "src/CustomFeatures.hh", + "src/CustomMeshShape.hh", + "src/EntityManagementFeatures.hh", + "src/FreeGroupFeatures.hh", + "src/JointFeatures.hh", + "src/KinematicsFeatures.hh", + "src/LinkFeatures.hh", + "src/SDFFeatures.hh", + "src/ShapeFeatures.hh", + "src/SimulationFeatures.hh", + "include/ignition/physics/dartsim/World.hh", +] + +cc_binary( + name = "libignition-physics2-dartsim.so", + srcs = sources + public_headers, + includes = ["include", "src"], + linkopts = ["-Wl,-soname,libignition-physics2-dartsim.so"], + linkshared = True, + visibility = [], + deps = [ + "//ign_bazel:utilities", + "//ign_plugin/core:ign_plugin", + "//ign_plugin/register", + "//ign_physics", + "//ign_physics/sdf", + "//ign_physics/mesh", + "//ign_common", + "//ign_common/graphics", + "//ign_common/profiler", + "//ign_math", + "//ign_math/eigen3", + "//sdformat", + "@eigen3", + "//dart", + ], +) + +cc_library( + name = "dartsim", + srcs = ["libignition-physics2-dartsim.so"], + hdrs = public_headers, + includes = ["include", "src"], + visibility = ["//visibility:public"], + deps = [ + "//ign_common", + "//ign_common/graphics", + "//ign_physics/mesh", + "//ign_physics/sdf", + "//sdformat", + ], +) + +[cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), + srcs = [src], + deps = [ + ":dartsim", + "//ign_physics/test:test_utils", + "@gtest//:gtest", + "@gtest//:gtest_main", + ], + data = [ "worlds", "//ign_physics:resources" ], + local_defines = [ + "tpe_plugin_LIB='\"\"'", + "bullet_plugin_LIB='\"\"'", + "TEST_WORLD_DIR='\"./ign_physics/dartsim/worlds/\"'", + "IGNITION_PHYSICS_RESOURCE_DIR='\"./ign_physics/resources/\"'", + ], +) for src in test_sources] diff --git a/dartsim/src/Collisions_TEST.cc b/dartsim/src/Collisions_TEST.cc index 33e4d5ca8..b9d5aab17 100644 --- a/dartsim/src/Collisions_TEST.cc +++ b/dartsim/src/Collisions_TEST.cc @@ -58,7 +58,7 @@ std::unordered_set LoadWorlds( const WorldConstructor &_constructor) { ignition::plugin::Loader loader; - loader.LoadLib(_library); + loader.LoadLib(resolveLibrary(_library)); const std::set pluginNames = ignition::physics::FindFeatures3d::From(loader); @@ -85,8 +85,10 @@ class Collisions_TEST public ::testing::WithParamInterface {}; -INSTANTIATE_TEST_CASE_P(PhysicsPlugins, Collisions_TEST, - ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries),); // NOLINT +INSTANTIATE_TEST_SUITE_P( + PhysicsPlugins, + Collisions_TEST, + ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries)); // NOLINT TestWorldPtr ConstructMeshPlaneWorld( const ignition::physics::Engine3dPtr &_engine, diff --git a/dartsim/src/EntityManagement_TEST.cc b/dartsim/src/EntityManagement_TEST.cc index 3fa84a53c..0125f8c93 100644 --- a/dartsim/src/EntityManagement_TEST.cc +++ b/dartsim/src/EntityManagement_TEST.cc @@ -32,6 +32,8 @@ #include "KinematicsFeatures.hh" #include "ShapeFeatures.hh" +#include "test/Utils.hh" + struct TestFeatureList : ignition::physics::FeatureList< ignition::physics::dartsim::EntityManagementFeatureList, ignition::physics::dartsim::JointFeatureList, @@ -42,7 +44,7 @@ struct TestFeatureList : ignition::physics::FeatureList< TEST(EntityManagement_TEST, ConstructEmptyWorld) { ignition::plugin::Loader loader; - loader.LoadLib(dartsim_plugin_LIB); + loader.LoadLib(DartsimPluginLib()); ignition::plugin::PluginPtr dartsim = loader.Instantiate("ignition::physics::dartsim::Plugin"); @@ -188,7 +190,7 @@ TEST(EntityManagement_TEST, ConstructEmptyWorld) TEST(EntityManagement_TEST, RemoveEntities) { ignition::plugin::Loader loader; - loader.LoadLib(dartsim_plugin_LIB); + loader.LoadLib(DartsimPluginLib()); ignition::plugin::PluginPtr dartsim = loader.Instantiate("ignition::physics::dartsim::Plugin"); diff --git a/dartsim/src/JointFeatures_TEST.cc b/dartsim/src/JointFeatures_TEST.cc index f64e9aa7f..672563187 100644 --- a/dartsim/src/JointFeatures_TEST.cc +++ b/dartsim/src/JointFeatures_TEST.cc @@ -70,7 +70,7 @@ class JointFeaturesFixture : public ::testing::Test protected: void SetUp() override { ignition::plugin::Loader loader; - loader.LoadLib(dartsim_plugin_LIB); + loader.LoadLib(DartsimPluginLib()); ignition::plugin::PluginPtr dartsim = loader.Instantiate("ignition::physics::dartsim::Plugin"); diff --git a/dartsim/src/LinkFeatures_TEST.cc b/dartsim/src/LinkFeatures_TEST.cc index 8d654d7a7..a309ebd1c 100644 --- a/dartsim/src/LinkFeatures_TEST.cc +++ b/dartsim/src/LinkFeatures_TEST.cc @@ -60,7 +60,7 @@ class LinkFeaturesFixture : public ::testing::Test protected: void SetUp() override { ignition::plugin::Loader loader; - loader.LoadLib(dartsim_plugin_LIB); + loader.LoadLib(DartsimPluginLib()); ignition::plugin::PluginPtr dartsim = loader.Instantiate("ignition::physics::dartsim::Plugin"); diff --git a/dartsim/src/SDFFeatures_TEST.cc b/dartsim/src/SDFFeatures_TEST.cc index 455464e02..1d6dc37d7 100644 --- a/dartsim/src/SDFFeatures_TEST.cc +++ b/dartsim/src/SDFFeatures_TEST.cc @@ -59,7 +59,7 @@ using WorldPtr = ignition::physics::World3dPtr; auto LoadEngine() { ignition::plugin::Loader loader; - loader.LoadLib(dartsim_plugin_LIB); + loader.LoadLib(DartsimPluginLib()); ignition::plugin::PluginPtr dartsim = loader.Instantiate("ignition::physics::dartsim::Plugin"); diff --git a/dartsim/src/SimulationFeatures_TEST.cc b/dartsim/src/SimulationFeatures_TEST.cc index 5c68f3304..e3566ed44 100644 --- a/dartsim/src/SimulationFeatures_TEST.cc +++ b/dartsim/src/SimulationFeatures_TEST.cc @@ -60,7 +60,7 @@ std::unordered_set LoadWorlds( const std::string &_world) { ignition::plugin::Loader loader; - loader.LoadLib(_library); + loader.LoadLib(resolveLibrary(_library)); const std::set pluginNames = ignition::physics::FindFeatures3d::From(loader); @@ -286,8 +286,8 @@ TEST_P(SimulationFeatures_TEST, RetrieveContacts) } } -INSTANTIATE_TEST_CASE_P(PhysicsPlugins, SimulationFeatures_TEST, - ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries),); // NOLINT +INSTANTIATE_TEST_SUITE_P(PhysicsPlugins, SimulationFeatures_TEST, + ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries)); // NOLINT int main(int argc, char *argv[]) { diff --git a/mesh/BUILD.bazel b/mesh/BUILD.bazel new file mode 100644 index 000000000..a8c2b6565 --- /dev/null +++ b/mesh/BUILD.bazel @@ -0,0 +1,12 @@ +public_headers = [ + "include/ignition/physics/mesh/MeshShape.hh", + "include/ignition/physics/mesh/detail/MeshShape.hh", +] + +cc_library( + name = "mesh", + srcs = public_headers, + hdrs = public_headers, + includes = ["include"], + visibility = ["//visibility:public"], +) diff --git a/sdf/BUILD.bazel b/sdf/BUILD.bazel new file mode 100644 index 000000000..f62ce80d7 --- /dev/null +++ b/sdf/BUILD.bazel @@ -0,0 +1,16 @@ +public_headers = [ + "include/ignition/physics/sdf/ConstructCollision.hh", + "include/ignition/physics/sdf/ConstructJoint.hh", + "include/ignition/physics/sdf/ConstructLink.hh", + "include/ignition/physics/sdf/ConstructModel.hh", + "include/ignition/physics/sdf/ConstructVisual.hh", + "include/ignition/physics/sdf/ConstructWorld.hh", +] + +cc_library( + name = "sdf", + srcs = public_headers, + hdrs = public_headers, + includes = ["include"], + visibility = ["//visibility:public"], +) diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 000000000..7e20b5bc4 --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,36 @@ +public_headers = [ + "integration/FrameSemantics.hh", + "integration/JointTypes.hh", + "MockCenterOfMass.hh", + "MockCreateEntities.hh", + "MockDoublePendulum.hh", + "MockFeatures.hh", + "MockFrameSemantics.hh", + "MockGetByName.hh", + "MockJoints.hh", + "MockSetName.hh", + "PhysicsPluginsList.hh", + "Utils.hh", +] + +cc_library( + name = "test_utils", + hdrs = public_headers, + includes = ["."], + visibility = ["//visibility:public"], + deps = [ + "//ign_common", + "//ign_physics", + "//ign_math", + "//ign_math/eigen3", + "//ign_plugin/core:ign_plugin", + "//ign_plugin/register", + "//ign_plugin/loader", + "//ign_bazel:utilities", + "@eigen3", + ], + include_prefix = "test", + local_defines = [ + "IGNITION_PHYSICS_RESOURCE_DIR='\"./ign_physics/resources/\"'", + ], +) diff --git a/test/PhysicsPluginsList.hh b/test/PhysicsPluginsList.hh index 99c80f652..2d6b19e4b 100644 --- a/test/PhysicsPluginsList.hh +++ b/test/PhysicsPluginsList.hh @@ -21,8 +21,11 @@ #include #include +#include +#include + #ifndef dartsim_plugin_LIB -#define dartsim_plugin_LIB "" +#define dartsim_plugin_LIB "__main__/ign_physics/dartsim/libignition-physics2-dartsim.so" #endif #ifndef bullet_plugin_LIB @@ -30,9 +33,42 @@ #endif #ifndef tpe_plugin_LIB -#define tpe_plugin_LIB "" +#define tpe_plugin_LIB "__main__/ign_physics/tpe/libignition-physics2-tpe.so" #endif +///////////////////////////////////////////////// +std::string resolveLibrary(const std::string &_path) +{ + auto it = _path.find("__main__"); + if(it != std::string::npos && it == 0) + { + std::string dataDir; + if (ignition::common::env("TEST_SRCDIR", dataDir)) + { + return ignition::common::joinPaths(dataDir, _path); + } + } + return _path; +} + +///////////////////////////////////////////////// +std::string DartsimPluginLib() +{ + return resolveLibrary(dartsim_plugin_LIB); +} + +///////////////////////////////////////////////// +std::string TpePluginLib() +{ + return resolveLibrary(tpe_plugin_LIB); +} + +///////////////////////////////////////////////// +std::string BulletPluginLib() +{ + return resolveLibrary(bullet_plugin_LIB); +} + namespace ignition { namespace physics diff --git a/test/Utils.hh b/test/Utils.hh index 6abbb2915..d0cd7f6ca 100644 --- a/test/Utils.hh +++ b/test/Utils.hh @@ -22,6 +22,8 @@ #include #include +#include "test/PhysicsPluginsList.hh" + namespace ignition { namespace physics diff --git a/tpe/BUILD.bazel b/tpe/BUILD.bazel new file mode 100644 index 000000000..e963ff4b5 --- /dev/null +++ b/tpe/BUILD.bazel @@ -0,0 +1,145 @@ +load( + "//ign_bazel:generate_file.bzl", + "generate_file", +) + +lib_test_sources = glob(["lib/src/*_TEST.cc"]) +lib_sources = glob(["lib/src/*.cc"], exclude=["lib/src/*_TEST.cc"]) +lib_headers = glob(["lib/src/*.hh"]) + +plugin_test_sources = glob(["plugin/src/*_TEST.cc"]) +plugin_sources = glob(["plugin/src/*.cc"], exclude=["plugin/src/*_TEST.cc"]) +plugin_headers = glob(["plugin/src/*.hh"]) + +generate_file( + name = "include/ignition/physics/tpelib/Export.hh", + content = """ +#pragma once +// IGN_DEPRECATED is defined by all ignition libraries, but the version below +// is a simplified version. When mixing the regular ignition libraries and +// the drake compiled ignition libraries, the compiler throws a warning about +// the macro being multiply defined. We undefine it before redefining it here +// to work around that issue. Note that the IGNITION_PHYSICS_VISIBLE macro +// shouldn't be defined multiple times, but we undefine it just in case. +#ifdef IGNITION_PHYSICS_TPELIB_VISIBLE +#undef IGNITION_PHYSICS_TPELIB_VISIBLE +#endif +#define IGNITION_PHYSICS_TPELIB_VISIBLE __attribute__ ((visibility("default"))) +#ifdef IGN_DEPRECATED +#undef IGN_DEPRECATED +#endif +#define IGN_DEPRECATED(version) __attribute__ ((__deprecated__)) + """, + visibility = ["//visibility:private"], +) + +cc_binary( + name = "libignition-physics2-tpelib.so", + srcs = + lib_sources + + lib_headers + ["include/ignition/physics/tpelib/Export.hh"], + includes = ["lib/src", "include", "."], + linkopts = ["-Wl,-soname,libignition-physics2-tpelib.so"], + linkshared = True, + visibility = [], + deps = [ + "//ign_bazel:utilities", + "//ign_plugin/core:ign_plugin", + "//ign_plugin/register", + "//ign_physics", + "//ign_physics/sdf", + "//ign_physics/mesh", + "//ign_common", + "//ign_common/graphics", + "//ign_common/profiler", + "//ign_math", + "//ign_math/eigen3", + "//sdformat", + ], +) + +cc_library( + name = "tpelib", + srcs = ["libignition-physics2-tpelib.so"], + hdrs = lib_headers + ["include/ignition/physics/tpelib/Export.hh"], + includes = ["lib/src", "include", "."], + visibility = ["//visibility:private"], + deps = [ + "//ign_bazel:utilities", + "//ign_common", + "//ign_common/graphics", + "//ign_physics/sdf", + "//sdformat", + ], +) + +[ + cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("lib_src_", ""), + srcs = [src], + includes = [".", "lib/src"], + deps = [ + ":tpelib", + "@gtest//:gtest", + "@gtest//:gtest_main", + ], +) for src in lib_test_sources] + +cc_binary( + name = "libignition-physics2-tpe.so", + srcs = plugin_sources + plugin_headers, + includes = ["plugin/src", "include"], + linkopts = ["-Wl,-soname,libignition-physics2-tpe.so"], + linkshared = True, + visibility = [], + deps = [ + ":tpelib", + "//ign_bazel:utilities", + "//ign_plugin/core:ign_plugin", + "//ign_plugin/register", + "//ign_physics", + "//ign_physics/sdf", + "//ign_physics/mesh", + "//ign_common", + "//ign_common/graphics", + "//ign_common/profiler", + "//ign_math", + "//ign_math/eigen3", + "//sdformat", + ], +) + +cc_library( + name = "tpe", + srcs = ["libignition-physics2-tpe.so"], + hdrs = plugin_headers, + visibility = ["//visibility:public"], + includes = ["plugin/src"], + deps = [ + ":tpelib", + "//ign_physics/mesh", + "//ign_physics/sdf", + "//sdformat", + ] +) + +[ + cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("plugin_src_", ""), + srcs = [src], + deps = [ + ":tpe", + "//ign_physics/test:test_utils", + "//ign_plugin/core:ign_plugin", + "@gtest//:gtest", + "@gtest//:gtest_main", + ], + data = ["plugin/worlds"], + local_defines = [ + "dartsim_plugin_LIB='\"\"'", + "bullet_plugin_LIB='\"\"'", + "TEST_WORLD_DIR='\"./ign_physics/tpe/plugin/worlds/\"'", + "IGNITION_PHYSICS_RESOURCE_DIR='\"./ign_physics/resources/\"'", + ], +) for src in plugin_test_sources] + diff --git a/tpe/plugin/src/EntityManagement_TEST.cc b/tpe/plugin/src/EntityManagement_TEST.cc index bdc312eef..d21afdd50 100644 --- a/tpe/plugin/src/EntityManagement_TEST.cc +++ b/tpe/plugin/src/EntityManagement_TEST.cc @@ -23,6 +23,8 @@ #include "EntityManagementFeatures.hh" +#include "test/Utils.hh" + struct TestFeatureList : ignition::physics::FeatureList< ignition::physics::tpeplugin::EntityManagementFeatureList > { }; @@ -30,7 +32,7 @@ struct TestFeatureList : ignition::physics::FeatureList< TEST(EntityManagement_TEST, ConstructEmptyWorld) { ignition::plugin::Loader loader; - loader.LoadLib(tpe_plugin_LIB); + loader.LoadLib(TpePluginLib()); ignition::plugin::PluginPtr tpe_plugin = loader.Instantiate("ignition::physics::tpeplugin::Plugin"); @@ -84,7 +86,9 @@ TEST(EntityManagement_TEST, ConstructEmptyWorld) TEST(EntityManagement_TEST, RemoveEntities) { ignition::plugin::Loader loader; - loader.LoadLib(tpe_plugin_LIB); + auto list = loader.LoadLib(TpePluginLib()); + + std::cout << TpePluginLib() << " " << list.size() << std::endl; ignition::plugin::PluginPtr tpe_plugin = loader.Instantiate("ignition::physics::tpeplugin::Plugin"); diff --git a/tpe/plugin/src/SDFFeatures_TEST.cc b/tpe/plugin/src/SDFFeatures_TEST.cc index 9695080e6..c0d5df84c 100644 --- a/tpe/plugin/src/SDFFeatures_TEST.cc +++ b/tpe/plugin/src/SDFFeatures_TEST.cc @@ -51,7 +51,7 @@ using WorldPtr = ignition::physics::World3dPtr; auto LoadEngine() { ignition::plugin::Loader loader; - loader.LoadLib(tpe_plugin_LIB); + loader.LoadLib(TpePluginLib()); ignition::plugin::PluginPtr tpe_plugin = loader.Instantiate("ignition::physics::tpeplugin::Plugin"); diff --git a/tpe/plugin/src/SimulationFeatures_TEST.cc b/tpe/plugin/src/SimulationFeatures_TEST.cc index 767de90aa..1540fa99a 100644 --- a/tpe/plugin/src/SimulationFeatures_TEST.cc +++ b/tpe/plugin/src/SimulationFeatures_TEST.cc @@ -59,7 +59,7 @@ std::unordered_set LoadWorlds( const std::string &_world) { ignition::plugin::Loader loader; - loader.LoadLib(_library); + loader.LoadLib(resolveLibrary(_library)); const std::set pluginNames = ignition::physics::FindFeatures3d::From(loader); @@ -350,8 +350,10 @@ TEST_P(SimulationFeatures_TEST, RetrieveContacts) } } -INSTANTIATE_TEST_CASE_P(PhysicsPlugins, SimulationFeatures_TEST, - ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries),); // NOLINT +INSTANTIATE_TEST_SUITE_P( + PhysicsPlugins, + SimulationFeatures_TEST, + ::testing::ValuesIn(ignition::physics::test::g_PhysicsPluginLibraries)); // NOLINT int main(int argc, char *argv[]) {