mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 07:13:23 +01:00
zstd: build with CMake
CMake is used for static builds because the Makefile does not offer a way to disable the shared library.
This commit is contained in:
parent
3ad650a14b
commit
c06a0b2c8c
2 changed files with 25 additions and 30 deletions
|
@ -1,7 +1,8 @@
|
|||
{ stdenv, fetchFromGitHub, fetchpatch, gnugrep
|
||||
{ stdenv, fetchFromGitHub, fetchpatch, cmake, gnugrep
|
||||
, fixDarwinDylibNames
|
||||
, file
|
||||
, legacySupport ? false }:
|
||||
, legacySupport ? false
|
||||
, enableShared ? true }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "zstd";
|
||||
|
@ -14,56 +15,46 @@ stdenv.mkDerivation rec {
|
|||
owner = "facebook";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ]
|
||||
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
|
||||
|
||||
patches = [
|
||||
# All 3 from https://github.com/facebook/zstd/pull/1883
|
||||
# From https://github.com/facebook/zstd/pull/1883
|
||||
(fetchpatch {
|
||||
url = "https://github.com/facebook/zstd/commit/106278e7e5fafaea3b7deb4147bdc8071562d2f0.diff";
|
||||
sha256 = "13z7id1qbc05cv1rmak7c8xrchp7jh1i623bq5pwcihg57wzcyr8";
|
||||
})
|
||||
(fetchpatch {
|
||||
url = "https://github.com/facebook/zstd/commit/0ede342acc2c26f87ae962fa88e158904d4198c4.diff";
|
||||
sha256 = "12l5xbvnzkvr76mvl1ls767paqfwbd9q1pzq44ckacfpz4f6iaap";
|
||||
excludes = [
|
||||
# I think line endings are causing problems, or something like that
|
||||
"programs/windres/generate_res.bat"
|
||||
];
|
||||
})
|
||||
(fetchpatch {
|
||||
url = "https://github.com/facebook/zstd/commit/10552eaffef84c011f67af0e04f0780b50a5ab26.diff";
|
||||
sha256 = "1s27ravar3rn7q8abybp9733jhpsfcaci51k04da94ahahvxwiqw";
|
||||
})
|
||||
] # This I didn't upstream because if you use posix threads with MinGW it will
|
||||
# work find, and I'm not sure how to write the condition.
|
||||
++ stdenv.lib.optional stdenv.hostPlatform.isWindows ./mcfgthreads-no-pthread.patch;
|
||||
|
||||
nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
|
||||
|
||||
makeFlags = [
|
||||
"ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}"
|
||||
] ++ stdenv.lib.optional stdenv.hostPlatform.isWindows "OS=Windows";
|
||||
cmakeFlags = [
|
||||
"-DZSTD_BUILD_SHARED:BOOL=${if enableShared then "ON" else "OFF"}"
|
||||
"-DZSTD_LEGACY_SUPPORT:BOOL=${if legacySupport then "ON" else "OFF"}"
|
||||
"-DZSTD_BUILD_TESTS:BOOL=ON"
|
||||
];
|
||||
cmakeDir = "../build/cmake";
|
||||
dontUseCmakeBuildDir = true;
|
||||
preConfigure = ''
|
||||
mkdir -p build_ && cd $_
|
||||
'';
|
||||
|
||||
checkInputs = [ file ];
|
||||
doCheck = true;
|
||||
preCheck = ''
|
||||
substituteInPlace tests/playTests.sh \
|
||||
substituteInPlace ../tests/playTests.sh \
|
||||
--replace 'MD5SUM="md5 -r"' 'MD5SUM="md5sum"'
|
||||
'';
|
||||
|
||||
installFlags = [
|
||||
"PREFIX=$(out)"
|
||||
];
|
||||
|
||||
preInstall = ''
|
||||
substituteInPlace programs/zstdgrep \
|
||||
preInstall = stdenv.lib.optionalString enableShared ''
|
||||
substituteInPlace ../programs/zstdgrep \
|
||||
--replace ":-grep" ":-${gnugrep}/bin/grep" \
|
||||
--replace ":-zstdcat" ":-$out/bin/zstdcat"
|
||||
|
||||
substituteInPlace programs/zstdless \
|
||||
substituteInPlace ../programs/zstdless \
|
||||
--replace "zstdcat" "$out/bin/zstdcat"
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Zstandard real-time compression algorithm";
|
||||
longDescription = ''
|
||||
|
|
|
@ -223,6 +223,10 @@ in {
|
|||
staticOnly = true;
|
||||
};
|
||||
|
||||
zstd = super.zstd.override {
|
||||
enableShared = false;
|
||||
};
|
||||
|
||||
llvmPackages_8 = super.llvmPackages_8 // {
|
||||
libraries = super.llvmPackages_8.libraries // rec {
|
||||
libcxxabi = super.llvmPackages_8.libraries.libcxxabi.override {
|
||||
|
|
Loading…
Reference in a new issue