Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384#!/bin/shset -euunset BASH_ENV ENVroot=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd -P)mode=buildcase "${1:-}" in --prepare|--clean-modules) mode=$1; shift ;;esacscratch="$root/.build"previous=for argument in "$@"; do if [ "$previous" = --scratch-path ]; then scratch=$argument; fi case "$argument" in --scratch-path=*) scratch=${argument#--scratch-path=} ;; --package-path|--package-path=*) printf 'Use the build wrapper from the package being built.\n' >&2; exit 2 ;; esac previous=$argumentdone[ "$previous" != --scratch-path ] || { printf 'Missing scratch path.\n' >&2; exit 2; }case "$scratch" in /*) ;; *) scratch="$root/$scratch" ;; esaccase "$scratch/" in *'/../'*|*'/./'*) printf 'Build scratch cannot contain dot components.\n' >&2; exit 2 ;; esaccase "$scratch" in "$root/.build"|"$root/.build/"*) ;; *) printf 'Build scratch must be inside .build.\n' >&2; exit 2 ;; esac# Never follow a cache symlink while deleting compiled state.path=$scratchwhile [ "$path" != / ]; do if [ -L "$path" ]; then printf 'Refusing a symlinked build cache: %s\n' "$path" >&2; exit 2; fi path=$(dirname -- "$path")donemkdir -p "$scratch"scratch=$(CDPATH='' cd -- "$scratch" && pwd -P)case "$scratch" in "$root/.build"|"$root/.build/"*) ;; *) printf 'Build scratch must be inside .build.\n' >&2; exit 2 ;; esacinputs="$scratch/toolchain.inputs.$$"locked=0cleanup() { rm -f "$inputs" if [ "$locked" = 1 ]; then rm -f "$scratch/parcel-build.lock"; fi}trap cleanup EXITtrap 'exit 130' INTtrap 'exit 143' TERM HUPattempts=0until /usr/bin/shlock -p "$$" -f "$scratch/parcel-build.lock"; do attempts=$((attempts + 1)) if [ "$attempts" -ge 6000 ]; then printf 'Build cache is still locked: %s\n' "$scratch" >&2; exit 2; fi sleep 0.1donelocked=1fingerprint() { { printf 'parcel-build-stamp-v1\n' command -v swift swift --version xcrun --find swift xcrun --show-sdk-path xcodebuild -version printf '%s\n' "${DEVELOPER_DIR:-}" "${TOOLCHAINS:-}" "${SWIFT_EXEC:-}" "${PARCEL_BUNDLE_BUILD:-}" "${PARCEL_REALITY:-}" shasum -a 256 "$root/Package.swift" if [ -f "$root/Package.resolved" ]; then shasum -a 256 "$root/Package.resolved"; else printf 'Package.resolved missing\n'; fi } > "$inputs"}clean_modules() { # Keep checkouts, repositories, artifacts, workspace state and independent scratch dirs. for path in "$scratch"/*; do case "${path##*/}" in *-apple-*|*-unknown-*) rm -rf "$path" ;; esac done rm -rf "$scratch/debug" "$scratch/release" "$scratch/Modules" "$scratch/ModuleCache" \ "$scratch/plugins/cache" "$scratch/plugins/outputs" "$scratch/apple" \ "$scratch/"*.yaml "$scratch/"*.db "$scratch/"*.db-shm "$scratch/"*.db-wal rm -f "$scratch/toolchain.inputs" "$scratch/inputs"}fingerprintif [ "$mode" = --clean-modules ] || ! cmp -s "$inputs" "$scratch/toolchain.inputs"; then printf 'Discarding compiled modules in %s (build stamp changed or clean requested).\n' "$scratch" >&2 clean_modulesfiif [ "$mode" = build ]; then (cd "$root" && swift build "$@") # Resolution may create or update Package.resolved during the build. fingerprintfimv "$inputs" "$scratch/toolchain.inputs"