depot/third_party/nixpkgs/pkgs/development/compilers/swift/swiftpm/setup-hook.sh
Default email ae2dc6aea6 Project import generated by Copybara.
GitOrigin-RevId: 4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0
2024-10-11 07:15:48 +02:00

62 lines
1.4 KiB
Bash

# shellcheck shell=bash
# Build using 'swift-build'.
swiftpmBuildPhase() {
runHook preBuild
local buildCores=1
if [ "${enableParallelBuilding-1}" ]; then
buildCores="$NIX_BUILD_CORES"
fi
local flagsArray=(
-j "$buildCores"
-c "${swiftpmBuildConfig-release}"
)
concatTo flagsArray swiftpmFlags swiftpmFlagsArray
echoCmd 'build flags' "${flagsArray[@]}"
TERM=dumb swift-build "${flagsArray[@]}"
runHook postBuild
}
if [ -z "${dontUseSwiftpmBuild-}" ] && [ -z "${buildPhase-}" ]; then
buildPhase=swiftpmBuildPhase
fi
# Check using 'swift-test'.
swiftpmCheckPhase() {
runHook preCheck
local buildCores=1
if [ "${enableParallelBuilding-1}" ]; then
buildCores="$NIX_BUILD_CORES"
fi
local flagsArray=(
-j "$buildCores"
-c "${swiftpmBuildConfig-release}"
)
concatTo flagsArray swiftpmFlags swiftpmFlagsArray
echoCmd 'check flags' "${flagsArray[@]}"
TERM=dumb swift-test "${flagsArray[@]}"
runHook postCheck
}
if [ -z "${dontUseSwiftpmCheck-}" ] && [ -z "${checkPhase-}" ]; then
checkPhase=swiftpmCheckPhase
fi
# Helper used to find the binary output path.
# Useful for performing the installPhase of swiftpm packages.
swiftpmBinPath() {
local flagsArray=(
-c "${swiftpmBuildConfig-release}"
)
concatTo flagsArray swiftpmFlags swiftpmFlagsArray
swift-build --show-bin-path "${flagsArray[@]}"
}