summary refs log tree commit diff
path: root/pkgs/development/libraries/bullet/roboschool-fork.nix
blob: 34a9ee3b6ee878a9ab4e799668de2b8e774352c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ stdenv, fetchFromGitHub, cmake, libGLU, libGL, freeglut
, Cocoa,  OpenGL
}:

stdenv.mkDerivation {
  pname = "bullet";
  version = "2019-03-27";

  src = fetchFromGitHub {
    owner = "olegklimov";
    repo = "bullet3";
    # roboschool needs the HEAD of a specific branch of this fork, see
    # https://github.com/openai/roboschool/issues/126#issuecomment-421643980
    # https://github.com/openai/roboschool/pull/62
    # https://github.com/openai/roboschool/issues/124
    rev = "3687507ddc04a15de2c5db1e349ada3f2b34b3d6";
    sha256 = "1wd7vj9136dl7lfb8ll0rc2fdl723y3ls9ipp7657yfl2xrqhvkb";
  };

  nativeBuildInputs = [ cmake ];
  buildInputs = stdenv.lib.optionals stdenv.isLinux [ libGLU libGL freeglut ]
    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa OpenGL ];

  patches = [ ./gwen-narrowing.patch ];

  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
    sed -i 's/FIND_PACKAGE(OpenGL)//' CMakeLists.txt
    sed -i 's/FIND_LIBRARY(COCOA_LIBRARY Cocoa)//' CMakeLists.txt
  '';

  cmakeFlags = [
    "-DBUILD_SHARED_LIBS=ON"
    "-DBUILD_CPU_DEMOS=OFF"
    "-DINSTALL_EXTRA_LIBS=ON"
  ] ++ stdenv.lib.optionals stdenv.isDarwin [
    "-DOPENGL_FOUND=true"
    "-DOPENGL_LIBRARIES=${OpenGL}/Library/Frameworks/OpenGL.framework"
    "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks/OpenGL.framework"
    "-DOPENGL_gl_LIBRARY=${OpenGL}/Library/Frameworks/OpenGL.framework"
    "-DCOCOA_LIBRARY=${Cocoa}/Library/Frameworks/Cocoa.framework"
    "-DBUILD_BULLET2_DEMOS=OFF"
    "-DBUILD_UNIT_TESTS=OFF"
  ];

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "A professional free 3D Game Multiphysics Library";
    longDescription = ''
      Bullet 3D Game Multiphysics Library provides state of the art collision
      detection, soft body and rigid body dynamics.
    '';
    homepage = http://bulletphysics.org;
    license = licenses.zlib;
    platforms = platforms.unix;
  };
}