homebrew-core/Formula/bullet.rb

77 lines
2.6 KiB
Ruby

class Bullet < Formula
desc "Physics SDK"
homepage "http://bulletphysics.org/wordpress/"
url "https://github.com/bulletphysics/bullet3/archive/2.85.1.tar.gz"
sha256 "6e157c0b50373bc0e860de27f06397827bb28a4205bc568ae79d76a0f919ed62"
head "https://github.com/bulletphysics/bullet3.git"
bottle do
cellar :any_skip_relocation
sha256 "db8f96ee50d670a4a35200d131cd991a8e35f0129f1ab4b64d7f16a2136629f1" => :sierra
sha256 "c5e8d5b15d71bafbc6b344e53a89a743aefe17af922ed71f4ee198ddd3f232d0" => :el_capitan
sha256 "2f3b941f70527d96caab211f1f05dd1448b9efa4072f0ed576deb1113497075b" => :yosemite
end
deprecated_option "framework" => "with-framework"
deprecated_option "shared" => "with-shared"
deprecated_option "build-demo" => "with-demo"
deprecated_option "double-precision" => "with-double-precision"
option :universal
option "with-framework", "Build frameworks"
option "with-shared", "Build shared libraries"
option "with-demo", "Build demo applications"
option "with-double-precision", "Use double precision"
depends_on "cmake" => :build
def install
args = ["-DINSTALL_EXTRA_LIBS=ON", "-DBUILD_UNIT_TESTS=OFF"]
if build.with? "framework"
args << "-DBUILD_SHARED_LIBS=ON" << "-DFRAMEWORK=ON"
args << "-DCMAKE_INSTALL_PREFIX=#{frameworks}"
args << "-DCMAKE_INSTALL_NAME_DIR=#{frameworks}"
else
args << "-DBUILD_SHARED_LIBS=ON" if build.with? "shared"
args << "-DCMAKE_INSTALL_PREFIX=#{prefix}"
end
if build.universal?
ENV.universal_binary
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
end
args << "-DUSE_DOUBLE_PRECISION=ON" if build.with? "double-precision"
# Related to the following warnings when building --with-shared --with-demo
# https://gist.github.com/scpeters/6afc44f0cf916b11a226
if build.with?("demo") && (build.with?("shared") || build.with?("framework"))
raise "Demos cannot be installed with shared libraries or framework."
end
args << "-DBUILD_BULLET2_DEMOS=OFF" if build.without? "demo"
system "cmake", *args
system "make"
system "make", "install"
prefix.install "examples" if build.with? "demo"
prefix.install "Extras" if build.with? "extra"
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include "bullet/LinearMath/btPolarDecomposition.h"
int main() {
btMatrix3x3 I = btMatrix3x3::getIdentity();
btMatrix3x3 u, h;
polarDecompose(I, u, h);
return 0;
}
EOS
system ENV.cc, "test.cpp", "-L#{lib}", "-lLinearMath", "-lc++", "-o", "test"
system "./test"
end
end