lol

box2d: 2.4.2 -> 3.1.0

Diff: https://github.com/erincatto/box2d/compare/v2.4.2...v3.1.0

Changelog: https://box2d.org/documentation/md_release__notes__v310.html

+122 -21
+16
pkgs/by-name/bo/box2d/cmake_dont_fetch_enkits.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 8c1390e..791d3b7 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -83,10 +83,7 @@ if(PROJECT_IS_TOP_LEVEL) 6 + # Used in tests and samples 7 + FetchContent_Declare( 8 + enkits 9 + - GIT_REPOSITORY https://github.com/dougbinks/enkiTS.git 10 + - GIT_TAG master 11 + - GIT_SHALLOW TRUE 12 + - GIT_PROGRESS TRUE 13 + + URL @enkits_src@ 14 + ) 15 + FetchContent_MakeAvailable(enkits) 16 + endif()
+54
pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch
··· 1 + diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt 2 + index 5020345..97af8c6 100644 3 + --- a/samples/CMakeLists.txt 4 + +++ b/samples/CMakeLists.txt 5 + @@ -17,47 +17,12 @@ set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "GLFW Examples") 6 + set(GLFW_BUILD_TESTS OFF CACHE BOOL "GLFW Tests") 7 + set(GLFW_INSTALL OFF CACHE BOOL "GLFW Install") 8 + 9 + -FetchContent_Declare( 10 + - glfw 11 + - GIT_REPOSITORY https://github.com/glfw/glfw.git 12 + - GIT_TAG 3.4 13 + - GIT_SHALLOW TRUE 14 + - GIT_PROGRESS TRUE 15 + -) 16 + -FetchContent_MakeAvailable(glfw) 17 + +find_package(glfw) 18 + 19 + # imgui and glfw backend for GUI 20 + # https://gist.github.com/jeffamstutz/992723dfabac4e3ffff265eb71a24cd9 21 + # Modified to pin to a specific imgui release 22 + -FetchContent_Populate(imgui 23 + - URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.3.zip 24 + - SOURCE_DIR ${CMAKE_SOURCE_DIR}/build/imgui 25 + -) 26 + - 27 + -set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/build/imgui) 28 + - 29 + -add_library(imgui STATIC 30 + - ${IMGUI_DIR}/imconfig.h 31 + - ${IMGUI_DIR}/imgui.h 32 + - 33 + - ${IMGUI_DIR}/imgui.cpp 34 + - ${IMGUI_DIR}/imgui_draw.cpp 35 + - ${IMGUI_DIR}/imgui_demo.cpp 36 + - ${IMGUI_DIR}/imgui_tables.cpp 37 + - ${IMGUI_DIR}/imgui_widgets.cpp 38 + - 39 + - ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp 40 + - ${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp 41 + -) 42 + - 43 + -target_link_libraries(imgui PUBLIC glfw glad) 44 + -target_include_directories(imgui PUBLIC ${IMGUI_DIR} ${IMGUI_DIR}/backends) 45 + -target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS) 46 + -set_target_properties(imgui PROPERTIES 47 + - CXX_STANDARD 20 48 + - CXX_STANDARD_REQUIRED YES 49 + - CXX_EXTENSIONS NO 50 + -) 51 + +find_package(imgui) 52 + 53 + # jsmn for json 54 + set(JSMN_DIR ${CMAKE_SOURCE_DIR}/extern/jsmn)
+52 -21
pkgs/by-name/bo/box2d/package.nix
··· 2 2 lib, 3 3 stdenv, 4 4 fetchFromGitHub, 5 + 6 + substituteAll, 7 + 8 + # nativeBuildInputs 5 9 cmake, 10 + pkg-config, 11 + 12 + # buildInputs 13 + glfw3, 14 + imgui, 6 15 libGLU, 7 - libGL, 8 - libglut, 9 16 libX11, 10 17 libXcursor, 18 + libXi, 11 19 libXinerama, 12 20 libXrandr, 21 + libglut, 13 22 xorgproto, 14 - libXi, 15 - pkg-config, 16 - settingsFile ? "include/box2d/b2_settings.h", 23 + 24 + nix-update-script, 17 25 }: 18 26 19 27 let 20 - inherit (lib) cmakeBool optionals; 28 + inherit (lib) cmakeBool; 21 29 22 30 in 23 31 stdenv.mkDerivation (finalAttrs: { 24 32 pname = "box2d"; 25 - version = "2.4.2"; 33 + version = "3.1.0"; 26 34 27 35 src = fetchFromGitHub { 28 36 owner = "erincatto"; 29 37 repo = "box2d"; 30 - rev = "v${finalAttrs.version}"; 31 - hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8="; 38 + tag = "v${finalAttrs.version}"; 39 + hash = "sha256-QTSU1+9x8GoUK3hlTDMh43fc4vbNfFR7syt6xVHIuPs="; 32 40 }; 33 41 42 + patches = [ 43 + # prevent CMake from trying to download some libraries from the internet 44 + (substituteAll { 45 + src = ./cmake_dont_fetch_enkits.patch; 46 + enkits_src = fetchFromGitHub { 47 + owner = "dougbinks"; 48 + repo = "enkiTS"; 49 + rev = "686d0ec31829e0d9e5edf9ceb68c40f9b9b20ea9"; 50 + hash = "sha256-CerLj/WY+J3mrMvv7dGmZltjAM9v5C/IY4X+Ph78HVs="; 51 + }; 52 + }) 53 + ./cmake_use_system_glfw_and_imgui.patch 54 + ]; 55 + 56 + env.NIX_CFLAGS_COMPILE = toString ( 57 + lib.optionals stdenv.cc.isGNU [ 58 + # error: '*(float *)((char *)&localPointA + offsetof(b2Vec2, y))' may be used uninitialized 59 + "-Wno-error=maybe-uninitialized" 60 + ] 61 + ); 62 + 34 63 nativeBuildInputs = [ 35 64 cmake 36 65 pkg-config 37 66 ]; 38 67 39 68 buildInputs = [ 40 - libGL 69 + glfw3 70 + (imgui.override { 71 + # GLFW backend is disabled by default on darwin but box2d imports it unconditionally 72 + # https://github.com/erincatto/box2d/blob/v3.1.0/samples/main.cpp#L28 73 + IMGUI_BUILD_GLFW_BINDING = true; 74 + }) 41 75 libGLU 42 76 libX11 43 77 libXcursor ··· 52 86 (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) 53 87 ]; 54 88 55 - prePatch = '' 56 - substituteInPlace ${settingsFile} \ 57 - --replace-fail 'b2_maxPolygonVertices 8' 'b2_maxPolygonVertices 15' 58 - ''; 59 - 60 - # tests are broken on 2.4.2 and 2.3.x doesn't have tests: https://github.com/erincatto/box2d/issues/677 61 - doCheck = lib.versionAtLeast finalAttrs.version "2.4.2"; 89 + passthru = { 90 + updateScript = nix-update-script { }; 91 + }; 62 92 63 - meta = with lib; { 93 + meta = { 64 94 description = "2D physics engine"; 65 95 homepage = "https://box2d.org/"; 66 - maintainers = with maintainers; [ raskin ]; 67 - platforms = platforms.unix; 68 - license = licenses.zlib; 96 + changelog = "https://github.com/erincatto/box2d/releases/tag/v${finalAttrs.version}"; 97 + maintainers = with lib.maintainers; [ raskin ]; 98 + platforms = lib.platforms.unix; 99 + license = lib.licenses.zlib; 69 100 }; 70 101 })