Lyrebird 2.0.0 — Linux support

Consolidated release: the cross-platform Linux port (engine, generators, CLI,
REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable
WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux
live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive.
See RELEASES.md and LINUX_README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-10 21:09:11 -07:00
parent 77580ee98e
commit b6fdee8bfc
293 changed files with 16800 additions and 775 deletions
@@ -7,14 +7,14 @@
// LyrebirdLiveCompile — snippet source formatting.
//
// Shells out to the toolchain's `swift-format` (the same way `LiveCompiler`
// shells to `swiftc`) to pretty-print a snippet. macOS only — iOS cannot exec
// subprocesses. Writes the source to a temp file and runs `swift-format format
// shells to `swiftc`) to pretty-print a snippet. macOS/Linux only — iOS cannot
// exec subprocesses. Writes the source to a temp file and runs `swift-format format
// <file>`, capturing stdout — avoids the write-stdin/read-stdout pipe deadlock
// a streaming approach risks on large output.
import Foundation
#if os(macOS)
#if os(macOS) || os(Linux)
/// Stateless `swift-format` wrapper.
public enum SwiftFormatter {
@@ -72,14 +72,20 @@ public enum SwiftFormatter {
label: "net.realizedsound.lyrebird.swift-format-drain",
attributes: .concurrent
)
var outData: Data = Data()
var errData: Data = Data()
// Box the drained bytes in reference cells: on Linux the `DispatchQueue`
// closures are `@Sendable` and cannot mutate a captured `var`. Each
// closure writes its own box (no shared mutation), and `group.wait()`
// fences before the reads below.
let outBox: SwiftFormatterDataBox = SwiftFormatterDataBox()
let errBox: SwiftFormatterDataBox = SwiftFormatterDataBox()
group.enter()
drainQueue.async { outData = outHandle.readDataToEndOfFile(); group.leave() }
drainQueue.async { outBox.data = outHandle.readDataToEndOfFile(); group.leave() }
group.enter()
drainQueue.async { errData = errHandle.readDataToEndOfFile(); group.leave() }
drainQueue.async { errBox.data = errHandle.readDataToEndOfFile(); group.leave() }
group.wait()
process.waitUntilExit()
let outData: Data = outBox.data
let errData: Data = errBox.data
guard process.terminationStatus == 0 else {
let stderr: String = String(data: errData, encoding: .utf8) ?? ""
@@ -137,4 +143,13 @@ public enum SwiftFormatter {
}
}
/// Reference cell for one drained pipe's bytes, so the concurrent drain closures
/// write through a reference instead of mutating a captured `var` (which the
/// Linux `@Sendable` `DispatchQueue` closures forbid). `@unchecked Sendable`:
/// each instance is written by exactly one closure and read only after
/// `DispatchGroup.wait()`.
private final class SwiftFormatterDataBox: @unchecked Sendable {
var data: Data = Data()
}
#endif