2020-11-20 20:58:33 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, substituteAll
|
|
|
|
, binutils
|
2021-08-25 01:02:32 +00:00
|
|
|
, asciidoctor
|
2020-11-20 20:58:33 +00:00
|
|
|
, cmake
|
|
|
|
, perl
|
|
|
|
, zstd
|
2021-05-10 21:08:41 +00:00
|
|
|
, bashInteractive
|
2020-11-20 20:58:33 +00:00
|
|
|
, xcodebuild
|
|
|
|
, makeWrapper
|
2021-11-14 19:09:50 +00:00
|
|
|
, nix-update-script
|
2020-11-20 20:58:33 +00:00
|
|
|
}:
|
2008-02-12 13:32:37 +00:00
|
|
|
|
2023-03-13 13:50:19 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "ccache";
|
2024-02-06 15:48:40 +00:00
|
|
|
version = "4.9.1";
|
2015-05-11 12:56:41 +00:00
|
|
|
|
2020-05-28 13:54:44 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-03-13 13:50:19 +00:00
|
|
|
owner = "ccache";
|
|
|
|
repo = "ccache";
|
|
|
|
rev = "refs/tags/v${finalAttrs.version}";
|
2024-02-06 15:48:40 +00:00
|
|
|
sha256 = "sha256-n0MTq8x6KNkgwhJQG7F+e3iCOS644nLkMsiRztJe8QU=";
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
|
|
|
|
2021-05-10 21:08:41 +00:00
|
|
|
outputs = [ "out" "man" ];
|
2021-03-28 14:48:41 +00:00
|
|
|
|
2021-05-10 21:08:41 +00:00
|
|
|
patches = [
|
2021-03-28 14:48:41 +00:00
|
|
|
# When building for Darwin, test/run uses dwarfdump, whereas on
|
|
|
|
# Linux it uses objdump. We don't have dwarfdump packaged for
|
|
|
|
# Darwin, so this patch updates the test to also use objdump on
|
|
|
|
# Darwin.
|
2023-07-30 11:04:20 +00:00
|
|
|
# Additionally, when cross compiling, the correct target prefix
|
|
|
|
# needs to be set.
|
2021-03-28 14:48:41 +00:00
|
|
|
(substituteAll {
|
2023-07-30 11:04:20 +00:00
|
|
|
src = ./fix-objdump-path.patch;
|
|
|
|
objdump = "${binutils.bintools}/bin/${binutils.targetPrefix}objdump";
|
2021-03-28 14:48:41 +00:00
|
|
|
})
|
|
|
|
];
|
2018-02-28 07:07:54 +00:00
|
|
|
|
2021-08-25 01:02:32 +00:00
|
|
|
nativeBuildInputs = [ asciidoctor cmake perl ];
|
2020-11-20 20:58:33 +00:00
|
|
|
buildInputs = [ zstd ];
|
2015-07-01 15:43:04 +00:00
|
|
|
|
2021-08-25 01:02:32 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
# Build system does not autodetect redis library presence.
|
|
|
|
# Requires explicit flag.
|
|
|
|
"-DREDIS_STORAGE_BACKEND=OFF"
|
|
|
|
];
|
|
|
|
|
2020-11-20 20:58:33 +00:00
|
|
|
doCheck = true;
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [
|
2021-05-10 21:08:41 +00:00
|
|
|
# test/run requires the compgen function which is available in
|
|
|
|
# bashInteractive, but not bash.
|
|
|
|
bashInteractive
|
|
|
|
] ++ lib.optional stdenv.isDarwin xcodebuild;
|
|
|
|
|
2023-03-13 13:50:19 +00:00
|
|
|
checkPhase =
|
|
|
|
let
|
|
|
|
badTests = [
|
|
|
|
"test.trim_dir" # flaky on hydra (possibly filesystem-specific?)
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"test.basedir"
|
2023-06-11 03:23:41 +00:00
|
|
|
"test.fileclone" # flaky on hydra (possibly filesystem-specific?)
|
2023-03-13 13:50:19 +00:00
|
|
|
"test.multi_arch"
|
|
|
|
"test.nocpp2"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
''
|
|
|
|
runHook preCheck
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
ctest --output-on-failure -E '^(${lib.concatStringsSep "|" badTests})$'
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2012-01-21 01:29:06 +00:00
|
|
|
|
2019-07-15 12:14:19 +00:00
|
|
|
passthru = {
|
2012-01-21 00:25:30 +00:00
|
|
|
# A derivation that provides gcc and g++ commands, but that
|
|
|
|
# will end up calling ccache for the given cacheDir
|
2023-03-13 13:50:19 +00:00
|
|
|
links = { unwrappedCC, extraConfig }: stdenv.mkDerivation {
|
2023-02-24 05:13:12 +00:00
|
|
|
pname = "ccache-links";
|
|
|
|
inherit (finalAttrs) version;
|
2016-05-11 04:45:41 +00:00
|
|
|
passthru = {
|
2016-09-18 18:54:12 +00:00
|
|
|
isClang = unwrappedCC.isClang or false;
|
|
|
|
isGNU = unwrappedCC.isGNU or false;
|
2022-06-19 21:18:01 +00:00
|
|
|
isCcache = true;
|
2016-05-11 04:45:41 +00:00
|
|
|
};
|
2016-09-18 18:54:12 +00:00
|
|
|
inherit (unwrappedCC) lib;
|
2017-08-10 10:13:17 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2023-08-14 15:28:16 +00:00
|
|
|
# Unwrapped clang does not have a targetPrefix because it is multi-target
|
|
|
|
# target is decided with argv0.
|
|
|
|
buildCommand = let
|
|
|
|
targetPrefix = if unwrappedCC.isClang or false
|
|
|
|
then
|
|
|
|
""
|
|
|
|
else
|
|
|
|
(lib.optionalString (unwrappedCC ? targetConfig && unwrappedCC.targetConfig != null && unwrappedCC.targetConfig != "") "${unwrappedCC.targetConfig}-");
|
|
|
|
in ''
|
2012-01-21 00:25:30 +00:00
|
|
|
mkdir -p $out/bin
|
2016-09-18 18:54:12 +00:00
|
|
|
|
|
|
|
wrap() {
|
2023-08-14 15:28:16 +00:00
|
|
|
local cname="${targetPrefix}$1"
|
2016-09-18 18:54:12 +00:00
|
|
|
if [ -x "${unwrappedCC}/bin/$cname" ]; then
|
2023-03-13 13:50:19 +00:00
|
|
|
makeWrapper ${finalAttrs.finalPackage}/bin/ccache $out/bin/$cname \
|
2021-01-23 12:26:19 +00:00
|
|
|
--run ${lib.escapeShellArg extraConfig} \
|
2017-08-10 10:13:17 +00:00
|
|
|
--add-flags ${unwrappedCC}/bin/$cname
|
2016-09-18 18:54:12 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
wrap cc
|
|
|
|
wrap c++
|
|
|
|
wrap gcc
|
|
|
|
wrap g++
|
|
|
|
wrap clang
|
|
|
|
wrap clang++
|
|
|
|
|
|
|
|
for executable in $(ls ${unwrappedCC}/bin); do
|
2015-07-29 09:03:39 +00:00
|
|
|
if [ ! -x "$out/bin/$executable" ]; then
|
2016-09-18 18:54:12 +00:00
|
|
|
ln -s ${unwrappedCC}/bin/$executable $out/bin/$executable
|
2015-07-29 09:03:39 +00:00
|
|
|
fi
|
|
|
|
done
|
2016-09-18 18:54:12 +00:00
|
|
|
for file in $(ls ${unwrappedCC} | grep -vw bin); do
|
|
|
|
ln -s ${unwrappedCC}/$file $out/$file
|
2015-12-09 05:43:38 +00:00
|
|
|
done
|
2016-05-11 04:45:41 +00:00
|
|
|
'';
|
|
|
|
};
|
2008-02-12 13:32:37 +00:00
|
|
|
|
2023-03-13 13:50:19 +00:00
|
|
|
updateScript = nix-update-script { };
|
|
|
|
};
|
2021-11-14 19:09:50 +00:00
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2013-10-05 14:22:46 +00:00
|
|
|
description = "Compiler cache for fast recompilation of C/C++ code";
|
2020-11-20 20:58:33 +00:00
|
|
|
homepage = "https://ccache.dev";
|
2020-05-28 13:54:44 +00:00
|
|
|
downloadPage = "https://ccache.dev/download.html";
|
2023-03-13 13:50:19 +00:00
|
|
|
changelog = "https://ccache.dev/releasenotes.html#_ccache_${
|
|
|
|
builtins.replaceStrings [ "." ] [ "_" ] finalAttrs.version
|
|
|
|
}";
|
2015-05-28 17:20:29 +00:00
|
|
|
license = licenses.gpl3Plus;
|
2023-08-14 15:28:16 +00:00
|
|
|
mainProgram = "ccache";
|
2021-05-22 14:47:40 +00:00
|
|
|
maintainers = with maintainers; [ kira-bruneau r-burns ];
|
2016-08-31 00:13:27 +00:00
|
|
|
platforms = platforms.unix;
|
2008-02-12 13:32:37 +00:00
|
|
|
};
|
2023-03-13 13:50:19 +00:00
|
|
|
})
|