Skip to content

Commit e019cb6

Browse files
authored
Enable building with the Swift Linux SDK (#151)
1 parent e76d611 commit e019cb6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,24 @@ jobs:
4242

4343
- name: Run tests
4444
run: swift test -v
45+
46+
static-linux-sdk-build:
47+
name: Linux Static SDK Build (${{ matrix.swift-version }} - ${{ matrix.os }})
48+
strategy:
49+
matrix:
50+
os: [ubuntu-latest]
51+
swift-version:
52+
- 6.1.2
53+
runs-on: ${{ matrix.os }}
54+
container: swift:${{ matrix.swift-version }}-noble
55+
timeout-minutes: 30
56+
steps:
57+
- name: Check out code
58+
uses: actions/checkout@v4
59+
- name: Install static SDK and build
60+
env:
61+
BUILD_FLAGS: ""
62+
run: |
63+
which curl || (apt -q update && apt -yq install curl)
64+
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
65+
bash -s -- --static --flags="$BUILD_FLAGS" ${{ matrix.swift-version }}

Sources/MCP/Base/Transports/StdioTransport.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import struct Foundation.Data
1313
import Darwin.POSIX
1414
#elseif canImport(Glibc)
1515
import Glibc
16+
#elseif canImport(Musl)
17+
import Musl
1618
#endif
1719

18-
#if canImport(Darwin) || canImport(Glibc)
20+
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl)
1921
/// An implementation of the MCP stdio transport protocol.
2022
///
2123
/// This transport implements the [stdio transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio)
@@ -107,7 +109,7 @@ import struct Foundation.Data
107109
/// - Parameter fileDescriptor: The file descriptor to configure
108110
/// - Throws: Error if the operation fails
109111
private func setNonBlocking(fileDescriptor: FileDescriptor) throws {
110-
#if canImport(Darwin) || canImport(Glibc)
112+
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl)
111113
// Get current flags
112114
let flags = fcntl(fileDescriptor.rawValue, F_GETFL)
113115
guard flags >= 0 else {

0 commit comments

Comments
 (0)