Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/scripts/install-and-build-with-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ INSTALL_WASM=false
BUILD_EMBEDDED_WASM=false
SWIFT_VERSION_INPUT=""
SWIFT_BUILD_FLAGS=""
SWIFT_BUILD_COMMAND="swift build"

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -43,6 +44,10 @@ while [[ $# -gt 0 ]]; do
SWIFT_BUILD_FLAGS="${1#*=}"
shift
;;
--build-command=*)
SWIFT_BUILD_COMMAND="${1#*=}"
shift
;;
-*)
fatal "Unknown option: $1"
;;
Expand All @@ -59,7 +64,7 @@ done

# Validate arguments
if [[ -z "$SWIFT_VERSION_INPUT" ]]; then
fatal "Usage: $0 [--static] [--wasm] [--flags=\"<build-flags>\"] <swift-version>"
fatal "Usage: $0 [--static] [--wasm] [--flags=\"<build-flags>\"] [--build-command=\"<build-command>\"] <swift-version>"
fi

if [[ "$INSTALL_STATIC_LINUX" == false && "$INSTALL_WASM" == false ]]; then
Expand Down Expand Up @@ -525,11 +530,15 @@ install_sdks() {
}

build() {
# Enable alias expansion to use a 'swift' alias for the executable path
shopt -s expand_aliases

if [[ "$INSTALL_STATIC_LINUX" == true ]]; then
log "Running Swift build with Static Linux Swift SDK"

local sdk_name="${STATIC_LINUX_SDK_TAG}_static-linux-0.0.1"
local build_command="$SWIFT_EXECUTABLE_FOR_STATIC_LINUX_SDK build --swift-sdk $sdk_name"
alias swift='$SWIFT_EXECUTABLE_FOR_STATIC_LINUX_SDK'
local build_command="$SWIFT_BUILD_COMMAND --swift-sdk $sdk_name"
if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then
build_command="$build_command $SWIFT_BUILD_FLAGS"
fi
Expand All @@ -552,7 +561,8 @@ build() {
local sdk_name="${WASM_SDK_TAG}_wasm"
fi

local build_command="$SWIFT_EXECUTABLE_FOR_WASM_SDK build --swift-sdk $sdk_name"
alias swift='$SWIFT_EXECUTABLE_FOR_WASM_SDK'
local build_command="$SWIFT_BUILD_COMMAND --swift-sdk $sdk_name"
if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then
build_command="$build_command $SWIFT_BUILD_FLAGS"
fi
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ on:
type: string
description: "Linux command to build and test the package"
default: "swift test"
linux_static_sdk_build_command:
type: string
description: "Command to use when building the package with the Static Linux Swift SDK"
default: "swift build"
wasm_sdk_build_command:
type: string
description: "Command to use when building the package with the Swift SDK for Wasm"
default: "swift build"
windows_pre_build_command:
type: string
description: "Windows Command Prompt command to execute before building the Swift package"
Expand Down Expand Up @@ -235,7 +243,7 @@ jobs:
${{ inputs.linux_static_sdk_pre_build_command }}
which curl || (apt -q update && apt -yq install curl)
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
bash -s -- --static --flags="$BUILD_FLAGS" ${{ matrix.swift_version }}
bash -s -- --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }}

wasm-sdk-build:
name: Wasm SDK Build (${{ matrix.swift_version }} - ${{ matrix.os_version }})
Expand Down Expand Up @@ -273,7 +281,7 @@ jobs:
${{ inputs.wasm_sdk_pre_build_command }}
which curl || (apt -q update && apt -yq install curl)
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
bash -s -- --wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }}
bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }}

windows-build:
name: Windows (${{ matrix.swift_version }} - windows-2022)
Expand Down
Loading