mirror of
https://github.com/apple/swift-nio
synced 2026-11-22 04:30:41 +00:00
### Motivation: We started seeing issues in Swift Log with building for Android when using types from the Concurrency module. Folks from the Android workgroup suggested we don't build with static stdlib, and I confirmed that removing it fixes the issue: https://github.com/apple/swift-log/actions/runs/34365246956/job/102512196662?pr=509 ### Modifications: Links the stdlib dynamically (default) for Android. ### Result: Unblock Swift Log's CI. This topic can be further discussed in the ongoing GitHub Actions unification.
44 lines
1.7 KiB
Bash
Executable File
44 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
##===----------------------------------------------------------------------===##
|
|
##
|
|
## This source file is part of the SwiftNIO open source project
|
|
##
|
|
## Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
|
|
## Licensed under Apache License v2.0
|
|
##
|
|
## See LICENSE.txt for license information
|
|
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
##
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
##
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
set -uo pipefail
|
|
|
|
log() { printf -- "** %s\n" "$*" >&2; }
|
|
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
|
|
fatal() { error "$@"; exit 1; }
|
|
|
|
# Parameter environment variables
|
|
swift_sdk_directory="${SWIFT_SDK_DIRECTORY:-"/tmp/swiftsdks"}"
|
|
arch="${INSTALL_SWIFT_ARCH:-"aarch64"}"
|
|
|
|
# The Android Swift SDK bundle ships one target triple per (architecture, API version)
|
|
# pair, so SwiftPM needs to be told which one to build for.
|
|
android_sdk_triple="${ANDROID_SDK_TRIPLE:-"${arch}-unknown-linux-android28"}"
|
|
|
|
log "Using Swift SDK directory: $swift_sdk_directory"
|
|
|
|
# Select the Swift SDK for Android
|
|
SWIFT_SDK="$(swift sdk list --swift-sdks-path "$swift_sdk_directory" | grep android | head -n1)"
|
|
if [[ -z "$SWIFT_SDK" ]]; then
|
|
fatal "No Android Swift SDK found. Please ensure you have the Android Swift SDK installed."
|
|
fi
|
|
|
|
log "Building using Swift SDK: $SWIFT_SDK (triple: $android_sdk_triple)"
|
|
|
|
# Pin the native build system for now: SwiftPM now defaults to swiftbuild, whose Android
|
|
# support expects a locally installed NDK found via ANDROID_NDK_ROOT/ANDROID_NDK_HOME
|
|
# rather than the one the Swift SDK links into its sysroot.
|
|
swift build --build-system native --swift-sdk "$SWIFT_SDK" --triple "$android_sdk_triple" --swift-sdks-path "$swift_sdk_directory" "${@}"
|