-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathgz-physics8.rb
116 lines (109 loc) · 3.94 KB
/
gz-physics8.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class GzPhysics8 < Formula
desc "Physics library for robotics applications"
homepage "https://github.com/gazebosim/gz-physics"
url "https://osrf-distributions.s3.amazonaws.com/gz-physics/releases/gz-physics-8.1.0.tar.bz2"
sha256 "4dc187a27b5c2b34a22ff911ae770a551a49468ca53bdd24316f57e6e18e6490"
license "Apache-2.0"
revision 4
head "https://github.com/gazebosim/gz-physics.git", branch: "gz-physics8"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 sonoma: "1967f733587729852a3d96ff661c353d6054668109220ebc9bde6425ebd499eb"
sha256 ventura: "e8ff13b93fefab8664886f2a2d0cfaf9333de2ee817a3e504d32ab7724805953"
end
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 "pkgconf"
depends_on "sdformat15"
depends_on "tinyxml2"
depends_on "urdfdom"
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(";")}"
# Use a build folder
mkdir "build" do
system "cmake", "..", *cmake_args
system "make", "install"
end
end
test do
require "system_command"
extend SystemCommand::Mixin
# 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:)
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.22.1 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