mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
Add copyCargoTargetToOutputHook
This commit is contained in:
parent
c2d7d083d5
commit
2d9788eb8b
@ -1,23 +1,38 @@
|
||||
{ cargo
|
||||
, configureCargoCommonVarsHook
|
||||
, configureCargoVendoredDepsHook
|
||||
, copyCargoTargetToOutputHook
|
||||
, lib
|
||||
, stdenv
|
||||
}:
|
||||
|
||||
args@{ nativeBuildInputs ? [ ], ... }:
|
||||
{ doCopyTarget ? true
|
||||
, doCopyTargetToSeparateOutput ? doCopyTarget
|
||||
, nativeBuildInputs ? [ ]
|
||||
, outputs ? [ "out" ]
|
||||
, ...
|
||||
}@args:
|
||||
stdenv.mkDerivation (args // {
|
||||
inherit
|
||||
doCopyTarget
|
||||
doCopyTargetToSeparateOutput;
|
||||
|
||||
nativeBuildInputs = nativeBuildInputs ++ [
|
||||
cargo
|
||||
configureCargoCommonVarsHook
|
||||
configureCargoVendoredDepsHook
|
||||
copyCargoTargetToOutputHook
|
||||
];
|
||||
|
||||
outputs = outputs ++ lib.optional (doCopyTarget && doCopyTargetToSeparateOutput) "target";
|
||||
|
||||
buildPhase = ''
|
||||
cargo check --release
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
runHook preInstall
|
||||
mkdir -p $out
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
|
21
pkgs/copyCargoTargetToOutputHook.sh
Normal file
21
pkgs/copyCargoTargetToOutputHook.sh
Normal file
@ -0,0 +1,21 @@
|
||||
copyCargoTargetToOutput() {
|
||||
echo "Executing copyCargoTargetToOutput"
|
||||
trap "echo Finished copyCargoTargetToOutput" RETURN
|
||||
|
||||
local target_dir=${CARGO_TARGET_DIR:-target}
|
||||
|
||||
if [ "1" != "${doCopyTarget}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "1" = "${doCopyTargetToSeparateOutput}" ]; then
|
||||
local dest="${target}"
|
||||
else
|
||||
mkdir -p "${out}"
|
||||
local dest="${out}/target"
|
||||
fi
|
||||
|
||||
mv "${target_dir}" "${dest}"
|
||||
}
|
||||
|
||||
postInstallHooks+=(copyCargoTargetToOutput)
|
@ -10,4 +10,9 @@
|
||||
{
|
||||
name = "configureCargoVendoredDepsHook";
|
||||
} ./configureCargoVendoredDepsHook.sh;
|
||||
|
||||
copyCargoTargetToOutputHook = makeSetupHook
|
||||
{
|
||||
name = "copyCargoTargetToOutputHook";
|
||||
} ./copyCargoTargetToOutputHook.sh;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user