Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccache: 4.9.1 -> 4.10 #315714

Merged
merged 2 commits into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 109 additions & 77 deletions pkgs/by-name/cc/ccache/package.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
{ lib
, stdenv
, fetchFromGitHub
, substituteAll
, binutils
, asciidoctor
, cmake
, perl
, zstd
, bashInteractive
, xcodebuild
, 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: {
pname = "ccache";
version = "4.9.1";
version = "4.10";

src = fetchFromGitHub {
owner = "ccache";
repo = "ccache";
rev = "refs/tags/v${finalAttrs.version}";
sha256 = "sha256-n0MTq8x6KNkgwhJQG7F+e3iCOS644nLkMsiRztJe8QU=";
sha256 = "sha256-0T9iJXnDX8LffhB/5hsfBNyZQ211f0lL/7dvTrjmiE0=";
};

outputs = [ "out" "man" ];
outputs = [
"out"
"man"
];

patches = [
# When building for Darwin, test/run uses dwarfdump, whereas on
Expand All @@ -39,32 +47,47 @@ stdenv.mkDerivation (finalAttrs: {
})
];

nativeBuildInputs = [ asciidoctor cmake perl ];
buildInputs = [ zstd ];
strictDeps = true;

nativeBuildInputs = [
asciidoctor
cmake
perl
];

cmakeFlags = [
# Build system does not autodetect redis library presence.
# Requires explicit flag.
"-DREDIS_STORAGE_BACKEND=OFF"
buildInputs = [
fmt
hiredis
xxHash
zstd
];

cmakeFlags = lib.optional (!finalAttrs.finalPackage.doCheck) "-DENABLE_TESTING=OFF";

Nanotwerp marked this conversation as resolved.
Show resolved Hide resolved
doCheck = true;

nativeCheckInputs = [
# test/run requires the compgen function which is available in
# bashInteractive, but not bash.
bashInteractive
] ++ lib.optional stdenv.isDarwin xcodebuild;

checkInputs = [
doctest
];

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
Expand All @@ -76,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 { };
};
Expand All @@ -136,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;
};
})