diff options
author | Nano Twerpus <nanotwerp@gmail.com> | 2024-05-31 06:58:44 -0400 |
---|---|---|
committer | Kira Bruneau <kira.bruneau@pm.me> | 2024-05-31 08:55:19 -0400 |
commit | d148e5a6dad22903299e1264e848e0127d30ece2 (patch) | |
tree | 3e73dd9aeafe0013596ff841f345c4ce00b10119 /pkgs/by-name/cc | |
parent | 2944aeb2c64d9e8eb060e14ae1762e208c53b3bb (diff) |
ccache: format with `nixfmt-rfc-style`
Diffstat (limited to 'pkgs/by-name/cc')
-rw-r--r-- | pkgs/by-name/cc/ccache/package.nix | 177 |
1 files changed, 102 insertions, 75 deletions
diff --git a/pkgs/by-name/cc/ccache/package.nix b/pkgs/by-name/cc/ccache/package.nix index 5ac81019e1111..f39066fba2895 100644 --- a/pkgs/by-name/cc/ccache/package.nix +++ b/pkgs/by-name/cc/ccache/package.nix @@ -1,20 +1,21 @@ -{ lib -, stdenv -, fetchFromGitHub -, substituteAll -, binutils -, asciidoctor -, cmake -, doctest -, fmt -, hiredis -, perl -, zstd -, bashInteractive -, xcodebuild -, xxHash -, makeWrapper -, nix-update-script +{ + lib, + stdenv, + fetchFromGitHub, + substituteAll, + binutils, + asciidoctor, + cmake, + perl, + fmt, + hiredis, + xxHash, + zstd, + bashInteractive, + doctest, + xcodebuild, + makeWrapper, + nix-update-script, }: stdenv.mkDerivation (finalAttrs: { @@ -28,7 +29,10 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-0T9iJXnDX8LffhB/5hsfBNyZQ211f0lL/7dvTrjmiE0="; }; - outputs = [ "out" "man" ]; + outputs = [ + "out" + "man" + ]; patches = [ # When building for Darwin, test/run uses dwarfdump, whereas on @@ -44,12 +48,24 @@ stdenv.mkDerivation (finalAttrs: { ]; strictDeps = true; - nativeBuildInputs = [ asciidoctor cmake perl ]; - buildInputs = [ fmt hiredis xxHash zstd ]; + + nativeBuildInputs = [ + asciidoctor + cmake + perl + ]; + + buildInputs = [ + fmt + hiredis + xxHash + zstd + ]; cmakeFlags = lib.optional (!finalAttrs.finalPackage.doCheck) "-DENABLE_TESTING=OFF"; doCheck = true; + nativeCheckInputs = [ # test/run requires the compgen function which is available in # bashInteractive, but not bash. @@ -62,14 +78,16 @@ stdenv.mkDerivation (finalAttrs: { checkPhase = let - badTests = [ - "test.trim_dir" # flaky on hydra (possibly filesystem-specific?) - ] ++ lib.optionals stdenv.isDarwin [ - "test.basedir" - "test.fileclone" # flaky on hydra (possibly filesystem-specific?) - "test.multi_arch" - "test.nocpp2" - ]; + badTests = + [ + "test.trim_dir" # flaky on hydra (possibly filesystem-specific?) + ] + ++ lib.optionals stdenv.isDarwin [ + "test.basedir" + "test.fileclone" # flaky on hydra (possibly filesystem-specific?) + "test.multi_arch" + "test.nocpp2" + ]; in '' runHook preCheck @@ -81,53 +99,59 @@ stdenv.mkDerivation (finalAttrs: { passthru = { # A derivation that provides gcc and g++ commands, but that # will end up calling ccache for the given cacheDir - links = { unwrappedCC, extraConfig }: stdenv.mkDerivation { - pname = "ccache-links"; - inherit (finalAttrs) version; - passthru = { - isClang = unwrappedCC.isClang or false; - isGNU = unwrappedCC.isGNU or false; - isCcache = true; + links = + { unwrappedCC, extraConfig }: + stdenv.mkDerivation { + pname = "ccache-links"; + inherit (finalAttrs) version; + passthru = { + isClang = unwrappedCC.isClang or false; + isGNU = unwrappedCC.isGNU or false; + isCcache = true; + }; + inherit (unwrappedCC) lib; + nativeBuildInputs = [ makeWrapper ]; + # Unwrapped clang does not have a targetPrefix because it is multi-target + # target is decided with argv0. + buildCommand = + let + targetPrefix = + if unwrappedCC.isClang or false then + "" + else + (lib.optionalString ( + unwrappedCC ? targetConfig && unwrappedCC.targetConfig != null && unwrappedCC.targetConfig != "" + ) "${unwrappedCC.targetConfig}-"); + in + '' + mkdir -p $out/bin + + wrap() { + local cname="${targetPrefix}$1" + if [ -x "${unwrappedCC}/bin/$cname" ]; then + makeWrapper ${finalAttrs.finalPackage}/bin/ccache $out/bin/$cname \ + --run ${lib.escapeShellArg extraConfig} \ + --add-flags ${unwrappedCC}/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 ${unwrappedCC}/bin/$executable $out/bin/$executable + fi + done + for file in $(ls ${unwrappedCC} | grep -vw bin); do + ln -s ${unwrappedCC}/$file $out/$file + done + ''; }; - inherit (unwrappedCC) lib; - nativeBuildInputs = [ makeWrapper ]; - # Unwrapped clang does not have a targetPrefix because it is multi-target - # target is decided with argv0. - buildCommand = let - targetPrefix = if unwrappedCC.isClang or false - then - "" - else - (lib.optionalString (unwrappedCC ? targetConfig && unwrappedCC.targetConfig != null && unwrappedCC.targetConfig != "") "${unwrappedCC.targetConfig}-"); - in '' - mkdir -p $out/bin - - wrap() { - local cname="${targetPrefix}$1" - if [ -x "${unwrappedCC}/bin/$cname" ]; then - makeWrapper ${finalAttrs.finalPackage}/bin/ccache $out/bin/$cname \ - --run ${lib.escapeShellArg extraConfig} \ - --add-flags ${unwrappedCC}/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 ${unwrappedCC}/bin/$executable $out/bin/$executable - fi - done - for file in $(ls ${unwrappedCC} | grep -vw bin); do - ln -s ${unwrappedCC}/$file $out/$file - done - ''; - }; updateScript = nix-update-script { }; }; @@ -141,7 +165,10 @@ stdenv.mkDerivation (finalAttrs: { }"; license = licenses.gpl3Plus; mainProgram = "ccache"; - maintainers = with maintainers; [ kira-bruneau r-burns ]; + maintainers = with maintainers; [ + kira-bruneau + r-burns + ]; platforms = platforms.unix; }; }) |