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

gz-physics8: new formula for ionic #2473

Merged
merged 7 commits into from
Oct 17, 2023
Merged
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
1 change: 0 additions & 1 deletion Aliases/gz-physics8

This file was deleted.

104 changes: 104 additions & 0 deletions Formula/gz-physics8.rb
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