anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / build-support / rust / hooks / cargo-install-hook.sh
blob4cf7840220a5a26cfb1e7e3338a9418d41922ea5
1 cargoInstallPostBuildHook() {
2 echo "Executing cargoInstallPostBuildHook"
4 releaseDir=target/@targetSubdirectory@/$cargoBuildType
5 tmpDir="${releaseDir}-tmp";
7 mkdir -p $tmpDir
8 cp -r ${releaseDir}/* $tmpDir/
9 bins=$(find $tmpDir \
10 -maxdepth 1 \
11 -type f \
12 -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \))
14 echo "Finished cargoInstallPostBuildHook"
17 cargoInstallHook() {
18 echo "Executing cargoInstallHook"
20 runHook preInstall
22 # rename the output dir to a architecture independent one
24 releaseDir=target/@targetSubdirectory@/$cargoBuildType
25 tmpDir="${releaseDir}-tmp";
27 mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep "${tmpDir}$")
28 for target in "${targets[@]}"; do
29 rm -rf "$target/../../${cargoBuildType}"
30 ln -srf "$target" "$target/../../"
31 done
32 mkdir -p $out/bin $out/lib
34 xargs -r cp -t $out/bin <<< $bins
35 find $tmpDir \
36 -maxdepth 1 \
37 -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
38 -print0 | xargs -r -0 cp -t $out/lib
40 # If present, copy any .dSYM directories for debugging on darwin
41 # https://github.com/NixOS/nixpkgs/issues/330036
42 find "${releaseDir}" -maxdepth 1 -name '*.dSYM' -exec cp -RLt $out/bin/ {} +
44 rmdir --ignore-fail-on-non-empty $out/lib $out/bin
45 runHook postInstall
47 echo "Finished cargoInstallHook"
51 if [ -z "${dontCargoInstall-}" ] && [ -z "${installPhase-}" ]; then
52 installPhase=cargoInstallHook
53 postBuildHooks+=(cargoInstallPostBuildHook)