Unverified Commit 356953c3 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

sdl3-image: add option to disable stb and modernize (#400078)

parents a43704a2 c705d86b
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
{
  lib,
  sdl3,
  darwin,
  libavif,
  libtiff,
  libwebp,
@@ -9,8 +8,12 @@
  cmake,
  fetchFromGitHub,
  validatePkgConfig,
  libpng,
  libjpeg,
  nix-update-script,
  # Boolean flags
  enableTests ? true,
  enableSTB ? true,
  enableImageIO ? stdenv.hostPlatform.isDarwin,
}:

@@ -39,29 +42,43 @@ stdenv.mkDerivation (finalAttrs: {
    validatePkgConfig
  ];

  buildInputs = [
  buildInputs =
    [
      sdl3
      libtiff
      libwebp
      libavif
  ] ++ (lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.Foundation);
    ]
    ++ (lib.optionals (!enableSTB) [
      libpng
      libjpeg
    ]);

  cmakeFlags = [
    # fail when a dependency could not be found
    (lib.cmakeBool "SDLIMAGE_STRICT" true)
    # disable shared dependencies as they're opened at runtime using SDL_LoadObject otherwise.
    (lib.cmakeBool "SDLIMAGE_DEPS_SHARED" false)
    # disable stbi
    (lib.cmakeBool "SDLIMAGE_BACKEND_STB" enableSTB)
    # enable imageio backend
    (lib.cmakeBool "SDLIMAGE_BACKEND_IMAGEIO" enableImageIO)
    # enable tests
    (lib.cmakeBool "SDLIMAGE_TESTS" enableTests)
  ];

  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--version-regex"
      "release-(3\\..*)"
    ];
  };

  meta = {
    description = "SDL image library";
    homepage = "https://github.com/libsdl-org/SDL_image";
    license = lib.licenses.zlib;
    maintainers = with lib.maintainers; [ evythedemon ];
    maintainers = [ lib.maintainers.evythedemon ];
    inherit (sdl3.meta) platforms;
  };
})