depot/third_party/nixpkgs/pkgs/development/compilers/swift/swiftpm/setup-hook.sh
Default email a0cb138ada Project import generated by Copybara.
GitOrigin-RevId: a100acd7bbf105915b0004427802286c37738fef
2023-02-02 18:25:31 +00:00

60 lines
1.4 KiB
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}"
$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}"
$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}"
$swiftpmFlags "${swiftpmFlagsArray[@]}"
)
swift-build --show-bin-path "${flagsArray[@]}"
}