diff --git a/Aliases/gz-plugin3 b/Aliases/gz-plugin3 deleted file mode 120000 index c7e255013..000000000 --- a/Aliases/gz-plugin3 +++ /dev/null @@ -1 +0,0 @@ -../Formula/gz-plugin2.rb \ No newline at end of file diff --git a/Formula/gz-plugin3.rb b/Formula/gz-plugin3.rb new file mode 100644 index 000000000..fc51f4bdb --- /dev/null +++ b/Formula/gz-plugin3.rb @@ -0,0 +1,69 @@ +class GzPlugin3 < Formula + desc "Plugin libraries for robotics applications" + homepage "https://github.com/gazebosim/gz-plugin" + url "https://github.com/gazebosim/gz-plugin.git", branch: "main" + version "2.999.999-0-20231006" + license "Apache-2.0" + + head "https://github.com/gazebosim/gz-plugin.git", branch: "main" + + depends_on "cmake" + depends_on "gz-cmake4" + depends_on "gz-tools2" + depends_on "gz-utils3" + depends_on macos: :high_sierra # c++17 + depends_on "pkg-config" + + def install + rpaths = [ + rpath, + rpath(source: libexec/"gz/plugin3", target: lib), + ] + cmake_args = std_cmake_args + cmake_args << "-DBUILD_TESTING=OFF" + cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpaths.join(";")}" + + # Use build folder + mkdir "build" do + system "cmake", "..", *cmake_args + system "make", "install" + end + end + + test do + # test CLI executable + system libexec/"gz/plugin3/gz-plugin" + # build against API + (testpath/"test.cpp").write <<-EOS + #include + int main() { + gz::plugin::Loader loader; + return loader.InterfacesImplemented().size(); + } + EOS + (testpath/"CMakeLists.txt").write <<-EOS + cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + find_package(gz-plugin3 QUIET REQUIRED COMPONENTS loader) + add_executable(test_cmake test.cpp) + target_link_libraries(test_cmake gz-plugin3::loader) + EOS + system "pkg-config", "gz-plugin3-loader" + cflags = `pkg-config --cflags gz-plugin3-loader`.split + system ENV.cc, "test.cpp", + *cflags, + "-L#{lib}", + "-lgz-plugin3-loader", + "-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