Skip to content

Commit

Permalink
bullet.rb initial attempt at pybullet support
Browse files Browse the repository at this point in the history
  • Loading branch information
ahundt committed May 9, 2017
1 parent 2818ad6 commit fd91540
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions Formula/bullet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,44 @@ class Bullet < Formula
deprecated_option "double-precision" => "with-double-precision"

depends_on "cmake" => :build
depends_on "enet" => :recommended
depends_on :python => :recommended
depends_on "numpy" => :recommended

def install
dylib = OS.mac? ? "dylib" : "so"
args = std_cmake_args + %w[
-DINSTALL_EXTRA_LIBS=ON -DBUILD_UNIT_TESTS=OFF
]
args << "-DUSE_DOUBLE_PRECISION=ON" if build.with? "double-precision"
args << "-DBUILD_BULLET2_DEMOS=ON" if build.with? "demo"
args << "-DBUILD_BULLET2_DEMOS=OFF" if build.without? "demo"

if build.with? "python"
py_prefix = `python-config --prefix`.chomp
py_lib = "#{py_prefix}/lib"
numpy_include=`python -c "from numpy.distutils.misc_util import get_numpy_include_dirs; print(get_numpy_include_dirs()[0])"`.chomp
args << "-DBUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK=ON" if OS.mac?
args += %W[
-DBUILD_PYBULLET=ON
-DBUILD_PYBULLET_NUMPY=ON
-DBUILD_PYBULLET_CLSOCKET=ON
-DBUILD_PYBULLET_ENET=ON
-DPYTHON_EXECUTABLE=#{which "python"}
-DPYTHON_LIBRARIES=#{py_lib}/libpython2.7.#{dylib}
-DPYTHON_INCLUDE_DIRS=#{py_prefix}/include/python2.7
-DPYTHON_NUMPY_INCLUDE_DIR=#{numpy_include}
]
end

if build.with? "enet"
args += %W[
-DBUILD_ENET=ON
-DBUILD_CLSOCKET=ON
]
end
args_shared = args.dup + %w[
-DBUILD_BULLET2_DEMOS=OFF -DBUILD_SHARED_LIBS=ON
-DBUILD_SHARED_LIBS=ON
]

args_framework = %W[
Expand All @@ -43,17 +72,24 @@ def install
args_shared += args_framework if build.with? "framework"

args_static = args.dup << "-DBUILD_SHARED_LIBS=OFF"
args_static << "-DBUILD_BULLET2_DEMOS=OFF" if build.without? "demo"

system "cmake", ".", *args_shared
system "make", "install"
args_static << "-DBUILD_BULLET2_DEMOS=OFF"

system "make", "clean"
mkdir "build_cmake_static" do
puts "cmake", "..", *args_static
system "cmake", "..", *args_static
system "make", "install", "VERBOSE=1"
end

system "cmake", ".", *args_static
system "make", "install"
mkdir "build_cmake_shared" do
puts "cmake", "..", *args_shared
system "cmake", "..", *args_shared
system "make", "install", "VERBOSE=1"
end

prefix.install "examples" if build.with? "demo"
if build.with? "demo"
prefix.install "build_cmake"
prefix.install "data"
end
end

test do
Expand Down

0 comments on commit fd91540

Please sign in to comment.