#!/usr/bin/env bash# Shared dependency repositories and downloaded binary artifacts, never build# output. Checkouts from an explicit warm resolve also live here. Xcode's two# destinations have separate source workspaces: a prod cut builds both at once.cotton_swiftpm_cache() { printf '%s\n'"${COTTON_SWIFTPM_CACHE:-$HOME/.cache/cottondb/swiftpm}"}cotton_swiftpm_key() { shasum -a 256"$1/Package.resolved" | cut -c1-24}cotton_swiftpm_sources() { printf '%s/xcode/%s/%s\n'"$(cotton_swiftpm_cache)""$2""$(cotton_swiftpm_key "$1")"}cotton_retain_swiftpm_cache() {local cache here cache="$(cotton_swiftpm_cache)" here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"# owner_only is deliberate: the ledger's budget and session rules must not# turn an offline-capable build into one that needs github.com again. mkdir -p "$cache" bash "$here/lane-claim.sh""$cache" --kind scratch --rule owner_only --lane swiftpm-cache >/dev/null}# A cut's build output lives outside its worktree (the cut build exports# COTTON_SWIFT_SCRATCH), so the next cut of the lane starts warm; any# other build keeps the package's own `.build`.cotton_swiftpm_build() { swift build --cache-path "$(cotton_swiftpm_cache)" ${COTTON_SWIFT_SCRATCH:+--scratch-path "$COTTON_SWIFT_SCRATCH"} --skip-update --force-resolved-versions "$@"}# cotton_swiftpm_build_dir <package dir>: where that build's output is.cotton_swiftpm_build_dir() { printf '%s\n'"${COTTON_SWIFT_SCRATCH:-$1/.build}"}