2019-12-03 20:41:28 +01:00
|
|
|
{ stdenv, fetchFromGitHub, cmake, ninja
|
2019-12-07 01:16:56 +01:00
|
|
|
, secureBuild ? false
|
2019-07-04 04:36:26 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
soext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-12-03 20:41:28 +01:00
|
|
|
pname = "mimalloc";
|
2019-10-23 00:38:42 +02:00
|
|
|
version = "1.1.0";
|
2019-07-04 04:36:26 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "microsoft";
|
2019-12-03 20:41:28 +01:00
|
|
|
repo = pname;
|
2019-07-04 04:36:26 +02:00
|
|
|
rev = "refs/tags/v${version}";
|
2019-10-23 00:38:42 +02:00
|
|
|
sha256 = "1i8pwzpcmbf7dxncb984xrnczn1737xqhf1jaizlyw0k1hpiam4v";
|
2019-07-04 04:36:26 +02:00
|
|
|
};
|
|
|
|
|
2019-12-03 20:41:28 +01:00
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
2019-07-04 04:36:26 +02:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
cmakeFlags = stdenv.lib.optional secureBuild [ "-DMI_SECURE=ON" ];
|
|
|
|
|
|
|
|
postInstall = ''
|
2019-12-03 20:41:28 +01:00
|
|
|
# first, install headers, that's easy
|
2019-07-04 04:36:26 +02:00
|
|
|
mkdir -p $dev
|
|
|
|
mv $out/lib/*/include $dev/include
|
|
|
|
|
2019-12-07 01:16:56 +01:00
|
|
|
# move .a and .o files into place
|
2019-12-04 23:24:09 +01:00
|
|
|
mv $out/lib/mimalloc-1.0/libmimalloc*.a $out/lib/libmimalloc.a
|
|
|
|
mv $out/lib/mimalloc-1.0/mimalloc*.o $out/lib/mimalloc.o
|
2019-07-04 04:36:26 +02:00
|
|
|
|
2019-12-07 01:16:56 +01:00
|
|
|
'' + (if secureBuild then ''
|
|
|
|
mv $out/lib/mimalloc-1.0/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc-secure${soext}.1.0
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc-secure${soext}
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc${soext}
|
|
|
|
'' else ''
|
|
|
|
mv $out/lib/mimalloc-1.0/libmimalloc${soext}.1.0 $out/lib/libmimalloc${soext}.1.0
|
|
|
|
ln -sfv $out/lib/libmimalloc${soext}.1.0 $out/lib/libmimalloc${soext}
|
|
|
|
'') + ''
|
2019-12-03 20:41:28 +01:00
|
|
|
# remote duplicate dir. FIXME: try to fix the .cmake file distribution
|
|
|
|
# so we can re-use it for dependencies...
|
2019-12-04 23:24:09 +01:00
|
|
|
rm -rf $out/lib/mimalloc-1.0
|
2019-07-04 04:36:26 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Compact, fast, general-purpose memory allocator";
|
|
|
|
homepage = "https://github.com/microsoft/mimalloc";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|