2015-05-11 14:16:15 +01:00
|
|
|
{ stdenv, fetchurl, runCommand, gcc, perl, zlib }:
|
2008-02-12 13:32:37 +00:00
|
|
|
|
2012-01-21 00:25:30 +00:00
|
|
|
let
|
2015-05-11 14:16:15 +01:00
|
|
|
# TODO: find out if there's harm in just using 'rec' instead.
|
2015-05-11 13:56:41 +01:00
|
|
|
name = "ccache-${version}";
|
|
|
|
version = "3.2.2";
|
|
|
|
sha256 = "1jm0qb3h5sypllaiyj81zp6m009vm50hzjnx994ril94kxlrj3ag";
|
2015-05-11 14:16:15 +01:00
|
|
|
doCheck = true;
|
2015-05-11 13:56:41 +01:00
|
|
|
|
2012-01-21 00:25:30 +00:00
|
|
|
ccache =
|
2008-02-12 13:32:37 +00:00
|
|
|
stdenv.mkDerivation {
|
2015-05-11 14:16:15 +01:00
|
|
|
inherit name doCheck;
|
2008-02-12 13:32:37 +00:00
|
|
|
src = fetchurl {
|
2015-05-11 13:56:41 +01:00
|
|
|
inherit sha256;
|
|
|
|
url = "mirror://samba/ccache/${name}.tar.xz";
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
|
|
|
|
2015-05-11 14:16:15 +01:00
|
|
|
# The test dependency on perl should be gone in the next release:
|
|
|
|
buildInputs = [ zlib ]
|
|
|
|
++ stdenv.lib.optionals doCheck [ perl ];
|
2012-01-21 01:29:06 +00:00
|
|
|
|
2012-01-21 00:25:30 +00:00
|
|
|
passthru = {
|
|
|
|
# A derivation that provides gcc and g++ commands, but that
|
|
|
|
# will end up calling ccache for the given cacheDir
|
2015-03-24 12:59:34 +00:00
|
|
|
links = extraConfig : (runCommand "ccache-links" { passthru.gcc = gcc; }
|
2012-01-21 00:25:30 +00:00
|
|
|
''
|
|
|
|
mkdir -p $out/bin
|
2015-01-15 04:44:00 +00:00
|
|
|
if [ -x "${gcc.cc}/bin/gcc" ]; then
|
2012-01-21 00:25:30 +00:00
|
|
|
cat > $out/bin/gcc << EOF
|
|
|
|
#!/bin/sh
|
2012-01-21 01:29:06 +00:00
|
|
|
${extraConfig}
|
2015-01-15 04:44:00 +00:00
|
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/gcc "\$@"
|
2012-01-21 00:25:30 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/gcc
|
|
|
|
fi
|
2015-01-15 04:44:00 +00:00
|
|
|
if [ -x "${gcc.cc}/bin/g++" ]; then
|
2012-01-21 00:25:30 +00:00
|
|
|
cat > $out/bin/g++ << EOF
|
|
|
|
#!/bin/sh
|
2012-01-21 01:29:06 +00:00
|
|
|
${extraConfig}
|
2015-01-15 04:44:00 +00:00
|
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/g++ "\$@"
|
2012-01-21 00:25:30 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/g++
|
|
|
|
fi
|
|
|
|
'');
|
2008-02-12 13:32:37 +00:00
|
|
|
};
|
|
|
|
|
2015-01-26 03:41:30 +00:00
|
|
|
meta = with stdenv.lib; {
|
2015-05-11 13:56:41 +01:00
|
|
|
inherit version;
|
2013-10-05 15:22:46 +01:00
|
|
|
description = "Compiler cache for fast recompilation of C/C++ code";
|
2008-02-12 13:32:37 +00:00
|
|
|
homepage = http://ccache.samba.org/;
|
2015-05-11 13:56:41 +01:00
|
|
|
downloadPage = https://ccache.samba.org/download.html;
|
2015-01-26 03:41:30 +00:00
|
|
|
license = with licenses; gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ nckx ];
|
2008-02-12 13:32:37 +00:00
|
|
|
};
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
ccache
|