homebrew-core/Formula/bullet.rb
2018-08-20 17:51:36 +02:00

90 lines
2.8 KiB
Ruby

class Bullet < Formula
desc "Physics SDK"
homepage "http://bulletphysics.org/wordpress/"
url "https://github.com/bulletphysics/bullet3/archive/2.87.tar.gz"
sha256 "438c151c48840fe3f902ec260d9496f8beb26dba4b17769a4a53212903935f95"
head "https://github.com/bulletphysics/bullet3.git"
bottle do
cellar :any
sha256 "c8947838fbb0b995a0c374138ebd9c3e92e29f68b4e89c58f369da95d99f218e" => :mojave
sha256 "26f10d89d53f5c384d473bf21d06e8db1104ca8d300285a89b68b657a0ff4753" => :high_sierra
sha256 "3a3fd3a1ead5ef2aefc65f752533bb96596fdd552d72fab5de86bba492f63104" => :sierra
sha256 "460cea95c022dc7116e09277715f9da51d3e7afa7901c4561af68b4ba5372795" => :el_capitan
end
option "with-framework", "Build frameworks"
option "with-demo", "Build demo applications"
option "with-double-precision", "Use double precision"
deprecated_option "framework" => "with-framework"
deprecated_option "build-demo" => "with-demo"
deprecated_option "double-precision" => "with-double-precision"
depends_on "cmake" => :build
def install
args = std_cmake_args + %w[
-DINSTALL_EXTRA_LIBS=ON -DBUILD_UNIT_TESTS=OFF -DBUILD_PYBULLET=OFF
]
args << "-DUSE_DOUBLE_PRECISION=ON" if build.with? "double-precision"
args_shared = args.dup + %w[
-DBUILD_BULLET2_DEMOS=OFF -DBUILD_SHARED_LIBS=ON
]
args_framework = %W[
-DFRAMEWORK=ON
-DCMAKE_INSTALL_PREFIX=#{frameworks}
-DCMAKE_INSTALL_NAME_DIR=#{frameworks}
]
args_shared += args_framework if build.with? "framework"
args_static = args.dup << "-DBUILD_SHARED_LIBS=OFF"
if build.without? "demo"
args_static << "-DBUILD_BULLET2_DEMOS=OFF"
else
args_static << "-DBUILD_BULLET2_DEMOS=ON"
end
mkdir "build" do
system "cmake", "..", *args_shared
system "make", "install"
system "make", "clean"
system "cmake", "..", *args_static
system "make", "install"
if build.with? "demo"
rm_rf Dir["examples/**/Makefile", "examples/**/*.cmake", "examples/**/CMakeFiles"]
pkgshare.install "examples"
(pkgshare/"examples").install "../data"
end
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
if build.with? "framework"
system ENV.cc, "test.cpp", "-F#{frameworks}", "-framework", "LinearMath",
"-I#{frameworks}/LinearMath.framework/Headers", "-lc++",
"-o", "f_test"
system "./f_test"
end
system ENV.cc, "test.cpp", "-I#{include}/bullet", "-L#{lib}",
"-lLinearMath", "-lc++", "-o", "test"
system "./test"
end
end