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
|
|
|
|
}:
|
2008-02-12 13:32:37 +00:00
|
|
|
|
2016-01-25 19:08:34 +00:00
|
|
|
let ccache = stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "ccache";
|
2021-09-29 00:04:45 +00:00
|
|
|
version = "4.4.2";
|
2015-05-11 12:56:41 +00:00
|
|
|
|
2020-05-28 13:54:44 +00:00
|
|
|
src = fetchFromGitHub {
|
2020-11-20 20:58:33 +00:00
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2020-05-28 13:54:44 +00:00
|
|
|
rev = "v${version}";
|
2021-09-29 00:04:45 +00:00
|
|
|
hash = "sha256-VtwykRX5so6LqyC0En/Jx7anXD7qW47zqq3awCY0lJE=";
|
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.
|
|
|
|
(substituteAll {
|
|
|
|
src = ./force-objdump-on-darwin.patch;
|
|
|
|
objdump = "${binutils.bintools}/bin/objdump";
|
|
|
|
})
|
|
|
|
];
|
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;
|
2021-05-10 21:08:41 +00:00
|
|
|
checkInputs = [
|
|
|
|
# test/run requires the compgen function which is available in
|
|
|
|
# bashInteractive, but not bash.
|
|
|
|
bashInteractive
|
|
|
|
] ++ lib.optional stdenv.isDarwin xcodebuild;
|
|
|
|
|
2021-09-15 00:38:01 +00:00
|
|
|
checkPhase = let
|
|
|
|
badTests = [
|
|
|
|
"test.trim_dir" # flaky on hydra (possibly filesystem-specific?)
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"test.basedir"
|
|
|
|
"test.multi_arch"
|
|
|
|
"test.nocpp2"
|
|
|
|
];
|
|
|
|
in ''
|
2021-05-10 21:08:41 +00:00
|
|
|
runHook preCheck
|
2020-11-20 20:58:33 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2021-09-15 00:38:01 +00:00
|
|
|
ctest --output-on-failure -E '^(${lib.concatStringsSep "|" badTests})$'
|
2021-05-10 21:08:41 +00:00
|
|
|
runHook postCheck
|
2020-11-20 20:58:33 +00:00
|
|
|
'';
|
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
|
2019-08-13 21:52:01 +00:00
|
|
|
links = {unwrappedCC, extraConfig}: stdenv.mkDerivation {
|
2016-05-11 04:45:41 +00:00
|
|
|
name = "ccache-links";
|
|
|
|
passthru = {
|
2016-09-18 18:54:12 +00:00
|
|
|
isClang = unwrappedCC.isClang or false;
|
|
|
|
isGNU = unwrappedCC.isGNU or false;
|
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 ];
|
2016-05-11 04:45:41 +00:00
|
|
|
buildCommand = ''
|
2012-01-21 00:25:30 +00:00
|
|
|
mkdir -p $out/bin
|
2016-09-18 18:54:12 +00:00
|
|
|
|
|
|
|
wrap() {
|
|
|
|
local cname="$1"
|
|
|
|
if [ -x "${unwrappedCC}/bin/$cname" ]; then
|
2017-08-10 10:13:17 +00:00
|
|
|
makeWrapper ${ccache}/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
|
|
|
};
|
|
|
|
|
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";
|
2015-05-28 17:20:29 +00:00
|
|
|
license = licenses.gpl3Plus;
|
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
|
|
|
};
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
2016-01-25 19:08:34 +00:00
|
|
|
in ccache
|