Skip to content

Commit

Permalink
sdformat15: new formula for ionic (#2465)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
  • Loading branch information
azeey and scpeters authored Oct 13, 2023
1 parent 7964c3c commit 76e0920
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
1 change: 0 additions & 1 deletion Aliases/sdformat15

This file was deleted.

83 changes: 83 additions & 0 deletions Formula/sdformat15.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class Sdformat15 < Formula
desc "Simulation Description Format"
homepage "http://sdformat.org"
url "https://github.com/gazebosim/sdformat.git", branch: "main"
version "14.999.999-0-20231011"
license "Apache-2.0"

head "https://github.com/gazebosim/sdformat.git", branch: "main"

depends_on "cmake" => [:build, :test]
depends_on "pkg-config" => [:build, :test]
depends_on "pybind11" => :build

depends_on "doxygen"
depends_on "gz-cmake3"
depends_on "gz-math7"
depends_on "gz-tools2"
depends_on "gz-utils2"
depends_on macos: :mojave # c++17
depends_on "[email protected]"
depends_on "tinyxml2"
depends_on "urdfdom"

def install
cmake_args = std_cmake_args
cmake_args << "-DBUILD_TESTING=Off"
cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpath}"

mkdir "build" do
system "cmake", "..", *cmake_args
system "make", "install"
end

(lib/"python3.11/site-packages").install Dir[lib/"python/*"]
rmdir prefix/"lib/python"
end

test do
(testpath/"test.cpp").write <<-EOS
#include <iostream>
#include "sdf/sdf.hh"
const std::string sdfString(
"<sdf version='1.5'>"
" <model name='example'>"
" <link name='link'>"
" <sensor type='gps' name='mysensor' />"
" </link>"
" </model>"
"</sdf>");
int main() {
sdf::SDF modelSDF;
modelSDF.SetFromString(sdfString);
std::cout << modelSDF.ToString() << std::endl;
}
EOS
(testpath/"CMakeLists.txt").write <<-EOS
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
find_package(sdformat15 QUIET REQUIRED)
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake ${SDFormat_LIBRARIES})
EOS
system "pkg-config", "sdformat15"
cflags = `pkg-config --cflags sdformat15`.split
system ENV.cc, "test.cpp",
*cflags,
"-L#{lib}",
"-lsdformat15",
"-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
# check python import
system Formula["[email protected]"].opt_bin/"python3.11", "-c", "import sdformat15"
end
end

0 comments on commit 76e0920

Please sign in to comment.