|
| 1 | +#!/bin/bash |
| 2 | +##===----------------------------------------------------------------------===## |
| 3 | +## |
| 4 | +## This source file is part of the SwiftNIO open source project |
| 5 | +## |
| 6 | +## Copyright (c) 2024 Apple Inc. and the SwiftNIO project authors |
| 7 | +## Licensed under Apache License v2.0 |
| 8 | +## |
| 9 | +## See LICENSE.txt for license information |
| 10 | +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors |
| 11 | +## |
| 12 | +## SPDX-License-Identifier: Apache-2.0 |
| 13 | +## |
| 14 | +##===----------------------------------------------------------------------===## |
| 15 | +set -euo pipefail |
| 16 | + |
| 17 | +log() { printf -- "** %s\n" "$*" >&2; } |
| 18 | +error() { printf -- "** ERROR: %s\n" "$*" >&2; } |
| 19 | +fatal() { error "$@"; exit 1; } |
| 20 | + |
| 21 | +test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset" |
| 22 | +test -n "${COMMAND:-}" || fatal "COMMAND unset" |
| 23 | +swift_version="$SWIFT_VERSION" |
| 24 | +command="$COMMAND" |
| 25 | +command_5_8="$COMMAND_OVERRIDE_5_8" |
| 26 | +command_5_9="$COMMAND_OVERRIDE_5_9" |
| 27 | +command_5_10="$COMMAND_OVERRIDE_5_10" |
| 28 | +command_nightly_6_0="$COMMAND_OVERRIDE_NIGHTLY_6_0" |
| 29 | +command_nightly_main="$COMMAND_OVERRIDE_NIGHTLY_MAIN" |
| 30 | + |
| 31 | +if [[ "$swift_version" == "5.8" ]] && [[ -n "$command_5_8" ]]; then |
| 32 | + log "Running 5.8 command override" |
| 33 | + eval "$command_5_8" |
| 34 | +elif [[ "$swift_version" == "5.9" ]] && [[ -n "$command_5_9" ]]; then |
| 35 | + log "Running 5.9 command override" |
| 36 | + eval "$command_5_9" |
| 37 | +elif [[ "$swift_version" == "5.10" ]] && [[ -n "$command_5_10" ]]; then |
| 38 | + log "Running 5.10 command override" |
| 39 | + eval "$command_5_10" |
| 40 | +elif [[ "$swift_version" == "nightly-6.0" ]] && [[ -n "$command_nightly_6_0" ]]; then |
| 41 | + log "Running nightly 6.0 command override" |
| 42 | + eval "$command_nightly_6_0" |
| 43 | +elif [[ "$swift_version" == "nightly-main" ]] && [[ -n "$command_nightly_main" ]]; then |
| 44 | + log "Running nightly main command override" |
| 45 | + eval "$command_nightly_main" |
| 46 | +else |
| 47 | + log "Running default command" |
| 48 | + eval "$command" |
| 49 | +fi |
0 commit comments