Commit e2ad6a29 authored by kyehn's avatar kyehn
Browse files

dart.media_kit_libs_linux: use packageRoot

parent 8e7193f6
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  mimalloc,
}:

# Implementation notes

# The patch exploits the fact that the download part is enclosed with "# ---"
# To use this module you will need to pass the CMake variable MIMALLOC_LIB
# example: -DMIMALLOC_LIB=${pkgs.mimalloc}/lib/mimalloc.o

# Direct link for the original CMakeLists.txt: https://raw.githubusercontent.com/media-kit/media-kit/main/libs/linux/media_kit_libs_linux/linux/CMakeLists.txt

{ version, src, ... }:

stdenv.mkDerivation {
@@ -20,12 +13,19 @@ stdenv.mkDerivation {

  dontBuild = true;

  postPatch =
    lib.optionalString (lib.versionAtLeast version "1.2.1") ''
      sed -i '/if(MIMALLOC_USE_STATIC_LIBS)/,/unset(MIMALLOC_USE_STATIC_LIBS CACHE)/d' linux/CMakeLists.txt
  # Remove mimalloc download
  # Direct link for the original CMakeLists.txt: https://raw.githubusercontent.com/media-kit/media-kit/main/libs/linux/media_kit_libs_linux/linux/CMakeLists.txt
  postPatch = ''
    pushd ${src.passthru.packageRoot}
  ''
  + lib.optionalString (lib.versionAtLeast version "1.2.1") ''
    sed -i '/if(MIMALLOC_USE_STATIC_LIBS)/,/unset(MIMALLOC_USE_STATIC_LIBS CACHE)/c\set(MIMALLOC_LIB "${lib.getLib mimalloc}/lib/mimalloc.o" CACHE INTERNAL "")' linux/CMakeLists.txt
  ''
  + lib.optionalString (lib.versionOlder version "1.2.1") ''
      awk -i inplace 'BEGIN {opened = 0}; /# --*[^$]*/ { print (opened ? "]===]" : "#[===["); opened = !opened }; {print $0}' linux/CMakeLists.txt
    sed -i '/# --\+/,/# --\+/c\set(MIMALLOC_LIB "${lib.getLib mimalloc}/lib/mimalloc.o")' linux/CMakeLists.txt
  ''
  + ''
    popd
  '';

  installPhase = ''