homebrew-core/Formula/bullet.rb

94 lines
3.1 KiB
Ruby

class Bullet < Formula
desc "Physics SDK"
homepage "https://bulletphysics.org/"
url "https://github.com/bulletphysics/bullet3/archive/3.17.tar.gz"
sha256 "baa642c906576d4d98d041d0acb80d85dd6eff6e3c16a009b1abf1ccd2bc0a61"
license "Zlib"
head "https://github.com/bulletphysics/bullet3.git", branch: "master"
bottle do
rebuild 1
sha256 cellar: :any, arm64_monterey: "9ebae8edbbf4df12b7190daa7ef11f32651a478dd5ac3e07c81c2d4378bdf554"
sha256 cellar: :any, arm64_big_sur: "1f2000191b311d231c5e1a949aba892992e533df61cb3cf05cd1ec7ded01cb3f"
sha256 cellar: :any, monterey: "2ccc0eff9a5116600282123ebaa2d3adaed572103a4c372467577b4aa5e02671"
sha256 cellar: :any, big_sur: "85bf74ad7500b0bc9b15f212cc45d1d3ad6e2a2e427a1878ac571e7fd7007d97"
sha256 cellar: :any, catalina: "76e1c4ed888700e335545275f080f954071d76164784881488b0b31f295bdbb3"
sha256 cellar: :any, mojave: "3b39c389a9b532dfdbc0f3652bf9530fc68e1d453d1df5e017028b41f448e6c6"
sha256 cellar: :any_skip_relocation, x86_64_linux: "c2887fa28d8a3e81b07eff60948ee01179438333e826e1692799d6253e3fcc27"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
def install
common_args = %w[
-DBT_USE_EGL=ON
-DBUILD_UNIT_TESTS=OFF
-DINSTALL_EXTRA_LIBS=ON
]
double_args = std_cmake_args + %W[
-DCMAKE_INSTALL_RPATH=#{opt_lib}/bullet/double
-DUSE_DOUBLE_PRECISION=ON
-DBUILD_SHARED_LIBS=ON
]
mkdir "builddbl" do
system "cmake", "..", *double_args, *common_args
system "make", "install"
end
dbllibs = lib.children
(lib/"bullet/double").install dbllibs
args = std_cmake_args + %W[
-DBUILD_PYBULLET_NUMPY=ON
-DCMAKE_INSTALL_RPATH=#{opt_lib}
]
mkdir "build" do
system "cmake", "..", *args, *common_args, "-DBUILD_SHARED_LIBS=OFF", "-DBUILD_PYBULLET=OFF"
system "make", "install"
system "make", "clean"
system "cmake", "..", *args, *common_args, "-DBUILD_SHARED_LIBS=ON", "-DBUILD_PYBULLET=ON"
system "make", "install"
end
# Install single-precision library symlinks into `lib/"bullet/single"` for consistency
lib.each_child do |f|
next if f == lib/"bullet"
(lib/"bullet/single").install_symlink f
end
end
test do
(testpath/"test.cpp").write <<~EOS
#include "LinearMath/btPolarDecomposition.h"
int main() {
btMatrix3x3 I = btMatrix3x3::getIdentity();
btMatrix3x3 u, h;
polarDecompose(I, u, h);
return 0;
}
EOS
cxx_lib = "-lc++"
on_linux do
cxx_lib = "-lstdc++"
end
# Test single-precision library
system ENV.cc, "test.cpp", "-I#{include}/bullet", "-L#{lib}",
"-lLinearMath", cxx_lib, "-o", "test"
system "./test"
# Test double-precision library
system ENV.cc, "test.cpp", "-I#{include}/bullet", "-L#{lib}/bullet/double",
"-lLinearMath", cxx_lib, "-o", "test"
system "./test"
end
end