depot/third_party/nixpkgs/pkgs/build-support/rust/hooks/maturin-build-hook.sh
Default email ae2dc6aea6 Project import generated by Copybara.
GitOrigin-RevId: 4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0
2024-10-11 07:15:48 +02:00

40 lines
904 B
Bash

# shellcheck shell=bash disable=SC2154,SC2164
maturinBuildHook() {
echo "Executing maturinBuildHook"
runHook preBuild
# Put the wheel to dist/ so that regular Python tooling can find it.
local dist="$PWD/dist"
if [ -n "${buildAndTestSubdir-}" ]; then
pushd "${buildAndTestSubdir}"
fi
local flagsArray=(
"--jobs=$NIX_BUILD_CORES"
"--offline"
"--target" "@rustTargetPlatformSpec@"
"--manylinux" "off"
"--strip"
"--release"
"--out" "$dist"
)
concatTo flagsArray maturinBuildFlags
echoCmd 'maturinBuildHook flags' "${flagsArray[@]}"
@setEnv@ maturin build "${flagsArray[@]}"
if [ -n "${buildAndTestSubdir-}" ]; then
popd
fi
# These are python build hooks and may depend on ./dist
runHook postBuild
echo "Finished maturinBuildHook"
}
buildPhase=maturinBuildHook