Making the ccacheWrapper a bit nicer. More flexible, specifically.

svn path=/nixpkgs/trunk/; revision=31753
This commit is contained in:
Lluís Batlle i Rossell 2012-01-21 01:29:06 +00:00
parent 4a1c721c01
commit 8ea631310b
2 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
{stdenv, fetchurl, runCommand, gcc}: {stdenv, fetchurl, runCommand, gcc, zlib}:
let let
ccache = ccache =
@ -9,17 +9,19 @@ stdenv.mkDerivation {
sha256 = "04ax6ks49b6rn57hx4v9wbvmsfmw6ipn0wyfqwhh4lzw70flv3r7"; sha256 = "04ax6ks49b6rn57hx4v9wbvmsfmw6ipn0wyfqwhh4lzw70flv3r7";
}; };
buildInputs = [ zlib ];
passthru = { passthru = {
# A derivation that provides gcc and g++ commands, but that # A derivation that provides gcc and g++ commands, but that
# will end up calling ccache for the given cacheDir # will end up calling ccache for the given cacheDir
links = cacheDir : (runCommand "ccache-links" links = extraConfig : (runCommand "ccache-links"
{ inherit (gcc) langC langCC; } { inherit (gcc) langC langCC; }
'' ''
mkdir -p $out/bin mkdir -p $out/bin
if [ $langC -eq 1 ]; then if [ $langC -eq 1 ]; then
cat > $out/bin/gcc << EOF cat > $out/bin/gcc << EOF
#!/bin/sh #!/bin/sh
export CCACHE_DIR=${cacheDir} ${extraConfig}
exec ${ccache}/bin/ccache ${gcc.gcc}/bin/gcc "\$@" exec ${ccache}/bin/ccache ${gcc.gcc}/bin/gcc "\$@"
EOF EOF
chmod +x $out/bin/gcc chmod +x $out/bin/gcc
@ -27,7 +29,7 @@ stdenv.mkDerivation {
if [ $langCC -eq 1 ]; then if [ $langCC -eq 1 ]; then
cat > $out/bin/g++ << EOF cat > $out/bin/g++ << EOF
#!/bin/sh #!/bin/sh
export CCACHE_DIR=${cacheDir} ${extraConfig}
exec ${ccache}/bin/ccache ${gcc.gcc}/bin/g++ "\$@" exec ${ccache}/bin/ccache ${gcc.gcc}/bin/g++ "\$@"
EOF EOF
chmod +x $out/bin/g++ chmod +x $out/bin/g++

View File

@ -2895,10 +2895,12 @@ let
# Wrapper that works as gcc or g++ # Wrapper that works as gcc or g++
# It can be used by setting in nixpkgs config like this, for example: # It can be used by setting in nixpkgs config like this, for example:
# replaceStdenv = { pkgs }: (pkgs.ccacheStdenv "/var/ccache"); # replaceStdenv = { pkgs }: pkgs.ccacheStdenv "exports CCACHE_DIR=/var/ccache";
# But if you build in chroot, you should have that path in chroot # But if you build in chroot, you should have that path in chroot
ccacheWrapper = cacheDir: wrapGCC (ccache.links cacheDir); # If instantiated directly, it will use the HOME/.ccache as cache directory.
ccacheStdenv = cacheDir: overrideGCC stdenv (ccacheWrapper cacheDir); ccacheWrapper = { extraConfig ? "" }: wrapGCC (ccache.links extraConfig);
ccacheStdenv = extraConfig: overrideGCC stdenv
(ccacheWrapper { inherit extraConfig; } );
complexity = callPackage ../development/tools/misc/complexity { }; complexity = callPackage ../development/tools/misc/complexity { };