Enable building with the Swift Linux SDK (#151)

This commit is contained in:
Tobias 2025-08-14 13:30:58 +02:00 • committed by GitHub
commit e019cb6909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View file

@ -42,3 +42,24 @@ jobs:
- name: Run tests
run: swift test -v
static-linux-sdk-build:
name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest]
swift-version:
- 6.1.2
runs-on: ${{ matrix.os }}
container: swift:${{ matrix.swift-version }}-noble
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install static SDK and build
env:
BUILD_FLAGS: ""
run: |
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 }}

View file

@ -13,9 +13,11 @@ import struct Foundation.Data
import Darwin.POSIX
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#endif
#if canImport(Darwin) || canImport(Glibc)
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl)
/// An implementation of the MCP stdio transport protocol.
///
/// This transport implements the [stdio transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio)
@ -107,7 +109,7 @@ import struct Foundation.Data
/// - Parameter fileDescriptor: The file descriptor to configure
/// - Throws: Error if the operation fails
private func setNonBlocking(fileDescriptor: FileDescriptor) throws {
#if canImport(Darwin) || canImport(Glibc)
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl)
// Get current flags
let flags = fcntl(fileDescriptor.rawValue, F_GETFL)
guard flags >= 0 else {