-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathgz-sim7.rb
161 lines (147 loc) · 5.29 KB
/
gz-sim7.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
class GzSim7 < Formula
desc "Gazebo Sim robot simulator"
homepage "https://github.com/gazebosim/gz-sim"
url "https://osrf-distributions.s3.amazonaws.com/gz-sim/releases/gz-sim-7.9.0.tar.bz2"
sha256 "b8a506112d1287efce144b5a1264ab5754cacc436370fe2f1035b35cdd0d29a4"
license "Apache-2.0"
revision 7
head "https://github.com/gazebosim/gz-sim.git", branch: "gz-sim7"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 sonoma: "99a76a7478f66f68dc328047af379dd545957d7426d588c7cdd788317478a408"
sha256 ventura: "154f23ac5d7f0c18dc7ca1f80add3bc683756421e41cfd79ac6116b80290bb25"
end
deprecate! date: "2024-09-30", because: "is past end-of-life date"
depends_on "cmake" => :build
depends_on "pybind11" => :build
depends_on "abseil"
depends_on "ffmpeg"
depends_on "gflags"
depends_on "google-benchmark"
depends_on "gz-cmake3"
depends_on "gz-common5"
depends_on "gz-fuel-tools8"
depends_on "gz-gui7"
depends_on "gz-math7"
depends_on "gz-msgs9"
depends_on "gz-physics6"
depends_on "gz-plugin2"
depends_on "gz-rendering7"
depends_on "gz-sensors7"
depends_on "gz-tools2"
depends_on "gz-transport12"
depends_on "gz-utils2"
depends_on macos: :mojave # c++17
depends_on "pkgconf"
depends_on "protobuf"
depends_on "[email protected]"
depends_on "qt@5"
depends_on "ruby"
depends_on "sdformat13"
depends_on "tinyxml2"
def python_cmake_arg
"-DPython3_EXECUTABLE=#{Formula["[email protected]"].opt_libexec}/bin/python}"
end
def install
rpaths = [
rpath,
rpath(source: lib/"gz-sim-7/plugins", target: lib),
rpath(source: lib/"gz-sim-7/plugins/gui", target: lib),
rpath(source: lib/"gz-sim-7/plugins/gui/GzSim", target: lib),
]
cmake_args = std_cmake_args
cmake_args << "-DBUILD_TESTING=OFF"
cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpaths.join(";")}"
cmake_args << python_cmake_arg
mkdir "build" do
system "cmake", "..", *cmake_args
system "make", "install"
end
(lib/"python3.13/site-packages").install Dir[lib/"python/*"]
rmdir prefix/"lib/python"
end
test do
require "system_command"
extend SystemCommand::Mixin
# test some plugins in subfolders
plugin_info = lambda { |p|
# Use gz-plugin --info command to check plugin linking
cmd = Formula["gz-plugin2"].opt_libexec/"gz/plugin2/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
}
%w[altimeter log physics sensors].each do |system|
plugin_info.call lib/"gz-sim-7/plugins/libgz-sim-#{system}-system.dylib"
end
["libAlignTool", "libEntityContextMenuPlugin", "libGzSceneManager", "GzSim/libEntityContextMenu"].each do |p|
plugin_info.call lib/"gz-sim-7/plugins/gui/#{p}.dylib"
end
# test gz sim CLI tool
ENV["GZ_CONFIG_PATH"] = "#{opt_share}/gz"
system Formula["gz-tools2"].opt_bin/"gz",
"sim", "-s", "--iterations", "5", "-r", "-v", "4"
# build against API
(testpath/"test.cpp").write <<-EOS
#include <cstdint>
#include <gz/sim/Entity.hh>
#include <gz/sim/EntityComponentManager.hh>
#include <gz/sim/components/World.hh>
#include <gz/sim/components/Name.hh>
using namespace gz;
using namespace sim;
//////////////////////////////////////////////////
int main(int argc, char **argv)
{
// Warm start. Initial allocation of resources can throw off calculations.
{
// Create the entity component manager
EntityComponentManager mgr;
// Create the matching entities
for (int i = 0; i < 100; ++i)
{
Entity entity = mgr.CreateEntity();
mgr.CreateComponent(entity, components::World());
mgr.CreateComponent(entity, components::Name("world_name"));
}
mgr.Each<components::World, components::Name>(
[&](const Entity &, const components::World *,
const components::Name *)->bool {return true;});
}
return 0;
}
EOS
(testpath/"CMakeLists.txt").write <<-EOS
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
find_package(gz-sim7 QUIET REQUIRED)
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake gz-sim7::core)
EOS
# ENV.append_path "PKG_CONFIG_PATH", Formula["qt@5"].opt_lib/"pkgconfig"
# system "pkg-config", "--cflags", "gz-sim7"
# cflags = `pkg-config --cflags gz-sim7`.split
# ldflags = `pkg-config --libs gz-sim7`.split
# system ENV.cc, "test.cpp",
# *cflags,
# *ldflags,
# "-lc++",
# "-o", "test"
# system "./test"
# test building with cmake
ENV.append_path "CMAKE_PREFIX_PATH", Formula["qt@5"].opt_prefix
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
# check python import
system Formula["[email protected]"].opt_libexec/"bin/python", "-c", "import gz.sim7"
end
end