Merge pull request #18135 from veprbl/ccache_fix

ccache: enable build on darwin

authored by Daiderd Jordan and committed by GitHub afa64a60 d997f458

+22 -19
+22 -19
pkgs/development/tools/misc/ccache/default.nix
··· 1 - { stdenv, fetchurl, fetchpatch, runCommand, gcc, zlib }: 1 + { stdenv, fetchurl, fetchpatch, runCommand, zlib }: 2 2 3 3 let ccache = stdenv.mkDerivation rec { 4 4 name = "ccache-${version}"; ··· 15 15 substituteInPlace Makefile.in --replace 'objs) $(extra_libs)' 'objs)' 16 16 ''; 17 17 18 - doCheck = true; 18 + doCheck = !stdenv.isDarwin; 19 19 20 - passthru = { 20 + passthru = let 21 + cc = stdenv.cc.cc; 22 + ccname = if stdenv.cc.cc.isClang or false then "clang" else "gcc"; 23 + cxxname = if stdenv.cc.cc.isClang or false then "clang++" else "g++"; 24 + in { 21 25 # A derivation that provides gcc and g++ commands, but that 22 26 # will end up calling ccache for the given cacheDir 23 27 links = extraConfig: stdenv.mkDerivation rec { 24 28 name = "ccache-links"; 25 29 passthru = { 26 - inherit gcc; 27 - isGNU = true; 30 + inherit (cc) isGNU isClang; 28 31 }; 29 - inherit (gcc.cc) lib; 32 + inherit (cc) lib; 30 33 buildCommand = '' 31 34 mkdir -p $out/bin 32 - if [ -x "${gcc.cc}/bin/gcc" ]; then 33 - cat > $out/bin/gcc << EOF 35 + if [ -x "${cc}/bin/${ccname}" ]; then 36 + cat > $out/bin/${ccname} << EOF 34 37 #!/bin/sh 35 38 ${extraConfig} 36 - exec ${ccache}/bin/ccache ${gcc.cc}/bin/gcc "\$@" 39 + exec ${ccache}/bin/ccache ${cc}/bin/${ccname} "\$@" 37 40 EOF 38 - chmod +x $out/bin/gcc 41 + chmod +x $out/bin/${ccname} 39 42 fi 40 - if [ -x "${gcc.cc}/bin/g++" ]; then 41 - cat > $out/bin/g++ << EOF 43 + if [ -x "${cc}/bin/${cxxname}" ]; then 44 + cat > $out/bin/${cxxname} << EOF 42 45 #!/bin/sh 43 46 ${extraConfig} 44 - exec ${ccache}/bin/ccache ${gcc.cc}/bin/g++ "\$@" 47 + exec ${ccache}/bin/ccache ${cc}/bin/${cxxname} "\$@" 45 48 EOF 46 - chmod +x $out/bin/g++ 49 + chmod +x $out/bin/${cxxname} 47 50 fi 48 - for executable in $(ls ${gcc.cc}/bin); do 51 + for executable in $(ls ${cc}/bin); do 49 52 if [ ! -x "$out/bin/$executable" ]; then 50 - ln -s ${gcc.cc}/bin/$executable $out/bin/$executable 53 + ln -s ${cc}/bin/$executable $out/bin/$executable 51 54 fi 52 55 done 53 - for file in $(ls ${gcc.cc} | grep -vw bin); do 54 - ln -s ${gcc.cc}/$file $out/$file 56 + for file in $(ls ${cc} | grep -vw bin); do 57 + ln -s ${cc}/$file $out/$file 55 58 done 56 59 ''; 57 60 }; ··· 63 66 downloadPage = https://ccache.samba.org/download.html; 64 67 license = licenses.gpl3Plus; 65 68 maintainers = with maintainers; [ nckx ]; 66 - platforms = with platforms; linux; 69 + platforms = platforms.unix; 67 70 }; 68 71 }; 69 72 in ccache