diff options
author | Daiderd Jordan <daiderd@gmail.com> | 2016-09-22 20:40:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-22 20:40:41 +0200 |
commit | 8377bf39c38e3534938006e13197db3f177b6659 (patch) | |
tree | a9463101309cf25db25f692b715e0178439b3b5c /pkgs/development | |
parent | f081a1aaf4ec30f953c8c68ce1be9f687179d4e5 (diff) | |
parent | 96d2a6c4348950eb29e26927cb08a45b415d484c (diff) | |
download | nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar.gz nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar.bz2 nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar.lz nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar.xz nixlib-8377bf39c38e3534938006e13197db3f177b6659.tar.zst nixlib-8377bf39c38e3534938006e13197db3f177b6659.zip |
Merge pull request #18739 from veprbl/ccache_fix2
ccache: improve compiler wrapper
Diffstat (limited to 'pkgs/development')
-rw-r--r-- | pkgs/development/tools/misc/ccache/default.nix | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/pkgs/development/tools/misc/ccache/default.nix b/pkgs/development/tools/misc/ccache/default.nix index c90e356e044f..99348e907a94 100644 --- a/pkgs/development/tools/misc/ccache/default.nix +++ b/pkgs/development/tools/misc/ccache/default.nix @@ -18,44 +18,46 @@ let ccache = stdenv.mkDerivation rec { doCheck = !stdenv.isDarwin; passthru = let - cc = stdenv.cc.cc; - ccname = if stdenv.cc.isClang then "clang" else "gcc"; - cxxname = if stdenv.cc.isClang then "clang++" else "g++"; + unwrappedCC = stdenv.cc.cc; in { # A derivation that provides gcc and g++ commands, but that # will end up calling ccache for the given cacheDir links = extraConfig: stdenv.mkDerivation rec { name = "ccache-links"; passthru = { - inherit (stdenv.cc) isClang; - inherit (cc) isGNU; + isClang = unwrappedCC.isClang or false; + isGNU = unwrappedCC.isGNU or false; }; - inherit (cc) lib; + inherit (unwrappedCC) lib; buildCommand = '' mkdir -p $out/bin - if [ -x "${cc}/bin/${ccname}" ]; then - cat > $out/bin/${ccname} << EOF - #!/bin/sh - ${extraConfig} - exec ${ccache}/bin/ccache ${cc}/bin/${ccname} "\$@" - EOF - chmod +x $out/bin/${ccname} - fi - if [ -x "${cc}/bin/${cxxname}" ]; then - cat > $out/bin/${cxxname} << EOF - #!/bin/sh - ${extraConfig} - exec ${ccache}/bin/ccache ${cc}/bin/${cxxname} "\$@" + + wrap() { + local cname="$1" + if [ -x "${unwrappedCC}/bin/$cname" ]; then + cat > $out/bin/$cname << EOF + #!/bin/sh + ${extraConfig} + exec ${ccache}/bin/ccache ${unwrappedCC}/bin/$cname "\$@" EOF - chmod +x $out/bin/${cxxname} - fi - for executable in $(ls ${cc}/bin); do + chmod +x $out/bin/$cname + fi + } + + wrap cc + wrap c++ + wrap gcc + wrap g++ + wrap clang + wrap clang++ + + for executable in $(ls ${unwrappedCC}/bin); do if [ ! -x "$out/bin/$executable" ]; then - ln -s ${cc}/bin/$executable $out/bin/$executable + ln -s ${unwrappedCC}/bin/$executable $out/bin/$executable fi done - for file in $(ls ${cc} | grep -vw bin); do - ln -s ${cc}/$file $out/$file + for file in $(ls ${unwrappedCC} | grep -vw bin); do + ln -s ${unwrappedCC}/$file $out/$file done ''; }; |