2024-04-21 15:54:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, libGLU
|
|
|
|
, libGL
|
2024-07-27 06:49:29 +00:00
|
|
|
, libglut
|
2024-04-21 15:54:59 +00:00
|
|
|
, libX11
|
|
|
|
, libXcursor
|
|
|
|
, libXinerama
|
|
|
|
, libXrandr
|
|
|
|
, xorgproto
|
|
|
|
, libXi
|
|
|
|
, pkg-config
|
|
|
|
, Carbon
|
|
|
|
, Cocoa
|
|
|
|
, Kernel
|
|
|
|
, OpenGL
|
|
|
|
, settingsFile ? "include/box2d/b2_settings.h"
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
let
|
|
|
|
inherit (lib) cmakeBool optionals;
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "box2d";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "2.4.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "erincatto";
|
|
|
|
repo = "box2d";
|
2024-04-21 15:54:59 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config ];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libGLU
|
|
|
|
libGL
|
2024-07-27 06:49:29 +00:00
|
|
|
libglut
|
2024-04-21 15:54:59 +00:00
|
|
|
libX11
|
|
|
|
libXcursor
|
|
|
|
libXinerama
|
|
|
|
libXrandr
|
|
|
|
xorgproto
|
|
|
|
libXi
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ optionals stdenv.hostPlatform.isDarwin [
|
2024-04-21 15:54:59 +00:00
|
|
|
Carbon Cocoa Kernel OpenGL
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2024-09-19 14:19:46 +00:00
|
|
|
(cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
2024-04-21 15:54:59 +00:00
|
|
|
substituteInPlace ${settingsFile} \
|
|
|
|
--replace-fail 'b2_maxPolygonVertices 8' 'b2_maxPolygonVertices 15'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# tests are broken on 2.4.2 and 2.3.x doesn't have tests: https://github.com/erincatto/box2d/issues/677
|
2024-04-21 15:54:59 +00:00
|
|
|
doCheck = lib.versionAtLeast finalAttrs.version "2.4.2";
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "2D physics engine";
|
|
|
|
homepage = "https://box2d.org/";
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ raskin ];
|
2021-06-28 23:13:55 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.zlib;
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|