diff --git a/.github/workflows/scripts/install-and-build-with-sdk.sh b/.github/workflows/scripts/install-and-build-with-sdk.sh index b15a4a42..6111a631 100644 --- a/.github/workflows/scripts/install-and-build-with-sdk.sh +++ b/.github/workflows/scripts/install-and-build-with-sdk.sh @@ -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 @@ -43,6 +44,10 @@ while [[ $# -gt 0 ]]; do SWIFT_BUILD_FLAGS="${1#*=}" shift ;; + --build-command=*) + SWIFT_BUILD_COMMAND="${1#*=}" + shift + ;; -*) fatal "Unknown option: $1" ;; @@ -59,7 +64,7 @@ done # Validate arguments if [[ -z "$SWIFT_VERSION_INPUT" ]]; then - fatal "Usage: $0 [--static] [--wasm] [--flags=\"\"] " + fatal "Usage: $0 [--static] [--wasm] [--flags=\"\"] [--build-command=\"\"] " fi if [[ "$INSTALL_STATIC_LINUX" == false && "$INSTALL_WASM" == false ]]; then @@ -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 @@ -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 diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 670a0957..8d996b84 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -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" @@ -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 }}) @@ -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)