mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
67a4f828b4
Currently there is a state of severe confusion in pkgs/build-support/rust/hooks/ regarding host vs target; right now there is only "host" defined, but whether it means "host" or "target" seems to fluctuate. This commit corrects that, ensuring that all variables come in all three flavors (build, host, target) and are used consistently with the nixpkgs convention. This also fixes the cross-compilation of packages which use `maturinBuildHook` -- hooks go in `nativeBuildInputs` and are phase-shifted backwards by one platform, so they need to be careful about distinguishing between build and host. Closes #247441
50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
cargoInstallPostBuildHook() {
|
|
echo "Executing cargoInstallPostBuildHook"
|
|
|
|
releaseDir=target/@targetSubdirectory@/$cargoBuildType
|
|
tmpDir="${releaseDir}-tmp";
|
|
|
|
mkdir -p $tmpDir
|
|
cp -r ${releaseDir}/* $tmpDir/
|
|
bins=$(find $tmpDir \
|
|
-maxdepth 1 \
|
|
-type f \
|
|
-executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \))
|
|
|
|
echo "Finished cargoInstallPostBuildHook"
|
|
}
|
|
|
|
cargoInstallHook() {
|
|
echo "Executing cargoInstallHook"
|
|
|
|
runHook preInstall
|
|
|
|
# rename the output dir to a architecture independent one
|
|
|
|
releaseDir=target/@targetSubdirectory@/$cargoBuildType
|
|
tmpDir="${releaseDir}-tmp";
|
|
|
|
mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep "${tmpDir}$")
|
|
for target in "${targets[@]}"; do
|
|
rm -rf "$target/../../${cargoBuildType}"
|
|
ln -srf "$target" "$target/../../"
|
|
done
|
|
mkdir -p $out/bin $out/lib
|
|
|
|
xargs -r cp -t $out/bin <<< $bins
|
|
find $tmpDir \
|
|
-maxdepth 1 \
|
|
-regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
|
|
-print0 | xargs -r -0 cp -t $out/lib
|
|
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
|
|
runHook postInstall
|
|
|
|
echo "Finished cargoInstallHook"
|
|
}
|
|
|
|
|
|
if [ -z "${dontCargoInstall-}" ] && [ -z "${installPhase-}" ]; then
|
|
installPhase=cargoInstallHook
|
|
postBuildHooks+=(cargoInstallPostBuildHook)
|
|
fi
|