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

Bumps in ionic : ci_matching_branch/bump_ionic_gz-sim9 #2470

Merged
merged 6 commits into from
Oct 18, 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-sim9

This file was deleted.

137 changes: 137 additions & 0 deletions Formula/gz-sim9.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
class GzSim9 < Formula
desc "Gazebo Sim robot simulator"
homepage "https://github.com/gazebosim/gz-sim"
url "https://github.com/gazebosim/gz-sim.git", branch: "main"
version "8.999.999-0-20231016"
license "Apache-2.0"

head "https://github.com/gazebosim/gz-sim.git", branch: "main"

depends_on "cmake" => :build
depends_on "pybind11" => :build
depends_on "ffmpeg"
depends_on "gflags"
depends_on "google-benchmark"
depends_on "gz-cmake4"
depends_on "gz-common6"
depends_on "gz-fuel-tools10"
depends_on "gz-gui9"
depends_on "gz-math8"
depends_on "gz-msgs11"
depends_on "gz-physics8"
depends_on "gz-plugin3"
depends_on "gz-rendering9"
depends_on "gz-sensors9"
depends_on "gz-tools2"
depends_on "gz-transport14"
depends_on "gz-utils3"
depends_on macos: :mojave # c++17
depends_on "pkg-config"
depends_on "protobuf"
depends_on "ruby"
depends_on "sdformat15"

def install
rpaths = [
rpath,
rpath(source: lib/"gz-sim-8/plugins", target: lib),
rpath(source: lib/"gz-sim-8/plugins/gui", target: lib),
rpath(source: lib/"gz-sim-8/plugins/gui/GzSim", 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 some plugins in subfolders
plugin_info = lambda { |p|
# 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
}
%w[altimeter log physics sensors].each do |system|
plugin_info.call lib/"gz-sim-8/plugins/libgz-sim-#{system}-system.dylib"
end
["libAlignTool", "libEntityContextMenuPlugin", "libGzSceneManager", "GzSim/libEntityContextMenu"].each do |p|
plugin_info.call lib/"gz-sim-8/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-sim9 QUIET REQUIRED)
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake gz-sim9::core)
EOS
# ENV.append_path "PKG_CONFIG_PATH", Formula["qt@5"].opt_lib/"pkgconfig"
# system "pkg-config", "--cflags", "gz-sim9"
# cflags = `pkg-config --cflags gz-sim9`.split
# ldflags = `pkg-config --libs gz-sim9`.split
# system ENV.cc, "test.cpp",
# *cflags,
# *ldflags,
# "-lc++",
# "-o", "test"
# system "./test"
# test building with cmake
ENV.append_path "CMAKE_PREFIX_PATH", Formula["ffmpeg@4"].opt_prefix
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
end
end