From 3c7bd2e2cb5069373274ac108025e3fadf12eada Mon Sep 17 00:00:00 2001 From: Green Sky Date: Mon, 15 Apr 2024 15:43:45 +0200 Subject: [PATCH] add sdl_image dep --- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 2 +- external/CMakeLists.txt | 1 + external/sdl_image/CMakeLists.txt | 21 ++++++++++++++++++++ flake.lock | 32 ++++++++++++++++++++++++------- flake.nix | 14 +++++++++++++- 6 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 external/sdl_image/CMakeLists.txt diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index dec2c43..361a2c3 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -76,7 +76,7 @@ jobs: arch: amd64 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=OFF - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} @@ -127,7 +127,7 @@ jobs: arch: amd64 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=OFF - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba80d27..3f14e8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: arch: amd64 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=OFF - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index f4415fd..cba4805 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -21,4 +21,5 @@ add_subdirectory(./imgui) add_subdirectory(./stb) add_subdirectory(./libwebp) add_subdirectory(./qoi) +add_subdirectory(./sdl_image) diff --git a/external/sdl_image/CMakeLists.txt b/external/sdl_image/CMakeLists.txt new file mode 100644 index 0000000..60d3826 --- /dev/null +++ b/external/sdl_image/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.16...3.24 FATAL_ERROR) + +include(FetchContent) + +if (NOT TARGET SDL3_image::SDL3_image) + set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + # TODO: make pr to make this an option + set(SDL3IMAGE_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + set(SDL3IMAGE_BACKEND_STB OFF CACHE BOOL "" FORCE) # important for security + set(SDL3IMAGE_BACKEND_IMAGEIO OFF CACHE BOOL "" FORCE) # some funky apple cmake bug + set(SDL3IMAGE_JXL ON CACHE BOOL "" FORCE) + + FetchContent_Declare(SDL3_image + GIT_REPOSITORY https://github.com/libsdl-org/SDL_image + # waiting on the imgui pr to get merged so i can update sdl <.< + GIT_TAG a45d6e5b84ccc0f3faae6ba7d561709ed600eee7 # tip last check + FIND_PACKAGE_ARGS # for the future + ) + FetchContent_MakeAvailable(SDL3_image) +endif() + diff --git a/flake.lock b/flake.lock index 6002f3d..a0ae079 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1709953752, - "narHash": "sha256-LW84B4vM1cn7E6cDNQn2LndT9iJXI1dRE5fwbNFbQa8=", + "lastModified": 1713189761, + "narHash": "sha256-MPp1dBhlY066IeBo+EPGEUN+s+aSUA+LWkvnzKh+rts=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fcaa81ed3c273237217330cf342ef1873b77c80a", + "rev": "ff44be4d8ff33f797ff3e3f87153d4f3b6a85ffb", "type": "github" }, "original": { @@ -56,7 +56,8 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "nlohmann-json": "nlohmann-json", - "sdl3": "sdl3" + "sdl3": "sdl3", + "sdl3_image": "sdl3_image" } }, "sdl3": { @@ -76,6 +77,23 @@ "type": "github" } }, + "sdl3_image": { + "flake": false, + "locked": { + "lastModified": 1712700609, + "narHash": "sha256-PVPH1uJ6g65SzHUboeQE6ZkC+72doMz9t9SG2LBo+7I=", + "owner": "libsdl-org", + "repo": "SDL_image", + "rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7", + "type": "github" + }, + "original": { + "owner": "libsdl-org", + "repo": "SDL_image", + "rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index c449690..e161844 100644 --- a/flake.nix +++ b/flake.nix @@ -14,9 +14,13 @@ url = "github:libsdl-org/SDL/0429f5d6a36fc35b551bcc2acd4a40c2db6dab82"; # keep in sync this cmake flake = false; }; + sdl3_image = { + url = "github:libsdl-org/SDL_image/a45d6e5b84ccc0f3faae6ba7d561709ed600eee7"; + flake = false; + }; }; - outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3 }: + outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3, sdl3_image }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; @@ -57,6 +61,13 @@ libGL pipewire + + # sdl3_image: + libpng + libjpeg + libjxl + #libavif # currently used sdl_image commit fails + #libwebp # still using our own loader ]; buildInputs = with pkgs; [ @@ -74,6 +85,7 @@ "-DFETCHCONTENT_SOURCE_DIR_ZSTD=${pkgs.zstd.src}" # we dont care about the version (we use 1.4.x features) "-DFETCHCONTENT_SOURCE_DIR_LIBWEBP=${pkgs.libwebp.src}" "-DFETCHCONTENT_SOURCE_DIR_SDL3=${sdl3}" + "-DFETCHCONTENT_SOURCE_DIR_SDL3_IMAGE=${sdl3_image}" ]; # TODO: replace with install command