-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gz-physics8: new formula for ionic (#2473)
Signed-off-by: Ian Chen <ichen@openrobotics.org> Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Steve Peters <scpeters@openrobotics.org> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
- Loading branch information
1 parent
afc7fa4
commit 5e340d1
Showing
2 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
class GzPhysics8 < Formula | ||
desc "Physics library for robotics applications" | ||
homepage "https://github.com/gazebosim/gz-physics" | ||
url "https://github.com/gazebosim/gz-physics.git", branch: "main" | ||
version "7.999.999-0-20231016" | ||
license "Apache-2.0" | ||
|
||
head "https://github.com/gazebosim/gz-physics.git", branch: "main" | ||
|
||
depends_on "cmake" => [:build, :test] | ||
|
||
depends_on "bullet" | ||
depends_on "dartsim" | ||
depends_on "google-benchmark" | ||
depends_on "gz-cmake4" | ||
depends_on "gz-common6" | ||
depends_on "gz-math8" | ||
depends_on "gz-plugin3" | ||
depends_on "gz-utils3" | ||
depends_on macos: :mojave # c++17 | ||
depends_on "pkg-config" | ||
depends_on "sdformat15" | ||
|
||
def install | ||
rpaths = [ | ||
rpath, | ||
rpath(source: lib/"gz-physics-8/engine-plugins", target: lib), | ||
] | ||
cmake_args = std_cmake_args | ||
cmake_args << "-DBUILD_TESTING=OFF" | ||
cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpaths.join(";")}" | ||
|
||
mkdir "build" do | ||
system "cmake", "..", *cmake_args | ||
system "make", "install" | ||
end | ||
end | ||
|
||
test do | ||
# test plugins in subfolders | ||
%w[bullet-featherstone bullet dartsim tpe].each do |engine| | ||
p = lib/"gz-physics-8/engine-plugins/libgz-physics-#{engine}-plugin.dylib" | ||
# Use gz-plugin --info command to check plugin linking | ||
cmd = Formula["gz-plugin3"].opt_libexec/"gz/plugin3/gz-plugin" | ||
args = ["--info", "--plugin"] << p | ||
# print command and check return code | ||
system cmd, *args | ||
# check that library was loaded properly | ||
_, stderr = system_command(cmd, args: args) | ||
error_string = "Error while loading the library" | ||
assert stderr.exclude?(error_string), error_string | ||
end | ||
# build against API | ||
(testpath/"test.cpp").write <<-EOS | ||
#include "gz/plugin/Loader.hh" | ||
#include "gz/physics/ConstructEmpty.hh" | ||
#include "gz/physics/RequestEngine.hh" | ||
int main() | ||
{ | ||
gz::plugin::Loader loader; | ||
loader.LoadLib("#{opt_lib}/libgz-physics8-dartsim-plugin.dylib"); | ||
gz::plugin::PluginPtr dartsim = | ||
loader.Instantiate("gz::physics::dartsim::Plugin"); | ||
using featureList = gz::physics::FeatureList< | ||
gz::physics::ConstructEmptyWorldFeature>; | ||
auto engine = | ||
gz::physics::RequestEngine3d<featureList>::From(dartsim); | ||
return engine == nullptr; | ||
} | ||
EOS | ||
(testpath/"CMakeLists.txt").write <<-EOS | ||
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) | ||
find_package(gz-physics8 REQUIRED) | ||
find_package(gz-plugin3 REQUIRED COMPONENTS all) | ||
add_executable(test_cmake test.cpp) | ||
target_link_libraries(test_cmake | ||
gz-physics8::gz-physics8 | ||
gz-plugin3::loader) | ||
EOS | ||
system "pkg-config", "gz-physics8" | ||
cflags = `pkg-config --cflags gz-physics8`.split | ||
ldflags = `pkg-config --libs gz-physics8`.split | ||
system "pkg-config", "gz-plugin3-loader" | ||
loader_cflags = `pkg-config --cflags gz-plugin3-loader`.split | ||
loader_ldflags = `pkg-config --libs gz-plugin3-loader`.split | ||
system ENV.cc, "test.cpp", | ||
*cflags, | ||
*ldflags, | ||
*loader_cflags, | ||
*loader_ldflags, | ||
"-lc++", | ||
"-o", "test" | ||
system "./test" | ||
# test building with cmake | ||
mkdir "build" do | ||
system "cmake", ".." | ||
system "make" | ||
system "./test_cmake" | ||
end | ||
# check for Xcode frameworks in bottle | ||
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}" | ||
system cmd_not_grep_xcode | ||
end | ||
end |