-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathgz-rendering7.rb
101 lines (93 loc) · 3.42 KB
/
gz-rendering7.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
class GzRendering7 < Formula
desc "Rendering library for robotics applications"
homepage "https://gazebosim.org"
url "https://osrf-distributions.s3.amazonaws.com/gz-rendering/releases/gz-rendering-7.5.0.tar.bz2"
sha256 "fcf0faff1ec286550f7bd9fd1e2c0cd6728bbabc5b831e0a018adf3798df9658"
license "Apache-2.0"
head "https://github.com/gazebosim/gz-rendering.git", branch: "gz-rendering7"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 sonoma: "a132de22cbd39f2b2829f504056eb500e6d42c3d5838ad14d16980e39896b98f"
sha256 ventura: "c96af0f852846c9e04e3f1f03eefb61b8c22c0d3a44f725ce26e06800c9bcf3c"
end
deprecate! date: "2024-09-30", because: "is past end-of-life date"
depends_on "cmake" => [:build, :test]
depends_on "pkgconf" => [:build, :test]
depends_on "freeimage"
depends_on "gz-cmake3"
depends_on "gz-common5"
depends_on "gz-math7"
depends_on "gz-plugin2"
depends_on "gz-utils2"
depends_on macos: :mojave # c++17
depends_on "ogre1.9"
depends_on "ogre2.3"
def install
rpaths = [
rpath,
rpath(source: lib/"gz-rendering-7/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
["ogre", "ogre2"].each do |engine|
p = lib/"gz-rendering-7/engine-plugins/libgz-rendering-#{engine}.dylib"
# 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
end
# build against API
github_actions = ENV["HOMEBREW_GITHUB_ACTIONS"].present?
(testpath/"test.cpp").write <<-EOS
#include <gz/rendering/RenderEngine.hh>
#include <gz/rendering/RenderingIface.hh>
int main(int _argc, char** _argv)
{
gz::rendering::RenderEngine *engine =
gz::rendering::engine("ogre");
return engine == nullptr;
}
EOS
(testpath/"CMakeLists.txt").write <<-EOS
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
find_package(gz-rendering7 REQUIRED COMPONENTS ogre ogre2)
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake gz-rendering7::gz-rendering7)
EOS
# test building with pkg-config
system "pkg-config", "gz-rendering7"
cflags = `pkg-config --cflags gz-rendering7`.split
ldflags = `pkg-config --libs gz-rendering7`.split
system ENV.cc, "test.cpp",
*cflags,
*ldflags,
"-lc++",
"-o", "test"
system "./test" unless github_actions
# test building with cmake
mkdir "build" do
system "cmake", ".."
system "make"
system "./test_cmake" unless github_actions
end
# check for Xcode frameworks in bottle
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}"
system cmd_not_grep_xcode
end
end