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:
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
@@ -8,7 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
|
||||
@Suite("DiagnosticParser")
|
||||
struct DiagnosticParserTests {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdGraphDSLEmbedded
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -8,7 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
|
||||
@Suite("LiveCompiler")
|
||||
struct LiveCompilerTests {
|
||||
@@ -30,7 +30,11 @@ struct LiveCompilerTests {
|
||||
|
||||
let snippet: CompiledSnippet = try LiveCompiler.compile(source: source)
|
||||
#expect(snippet.moduleName.hasPrefix("LBSnippet_"))
|
||||
#if os(macOS)
|
||||
#expect(snippet.dylibPath.hasSuffix(".dylib"))
|
||||
#else
|
||||
#expect(snippet.dylibPath.hasSuffix(".so"))
|
||||
#endif
|
||||
|
||||
var marker: Int32 = 0
|
||||
withUnsafeMutablePointer(to: &marker) { ptr in
|
||||
@@ -103,6 +107,11 @@ struct LiveCompilerTests {
|
||||
for url: URL in LiveSession.discoverSPMModuleMaps(in: importPaths) {
|
||||
args += ["-Xcc", "-fmodule-map-file=\(url.path)"]
|
||||
}
|
||||
#if os(Linux)
|
||||
for url: URL in LiveSession.discoverSourceSystemModuleMaps(in: importPaths) {
|
||||
args += ["-Xcc", "-fmodule-map-file=\(url.path)"]
|
||||
}
|
||||
#endif
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
|
||||
@MainActor
|
||||
@Suite("LiveSession diagnostics")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
import LyrebirdGraphDSLEmbedded
|
||||
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
|
||||
@MainActor
|
||||
@Suite("LiveSession")
|
||||
@@ -34,7 +34,12 @@ struct LiveSessionTests {
|
||||
@Test
|
||||
func buildDirDiscoveryFindsLyrebirdDylib() throws {
|
||||
let buildDir: URL = try #require(LiveSession.currentBuildDir())
|
||||
let dylib: URL = buildDir.appendingPathComponent("libLyrebirdDynamic.dylib")
|
||||
#if os(macOS)
|
||||
let libName: String = "libLyrebirdDynamic.dylib"
|
||||
#else
|
||||
let libName: String = "libLyrebirdDynamic.so"
|
||||
#endif
|
||||
let dylib: URL = buildDir.appendingPathComponent(libName)
|
||||
#expect(FileManager.default.fileExists(atPath: dylib.path))
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
@@ -8,7 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
|
||||
@Suite("SnippetHarness")
|
||||
struct SnippetHarnessTests {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
#if os(macOS) || os(Linux)
|
||||
import Testing
|
||||
@testable import LyrebirdLiveCompile
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
// LinuxScratchModelTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Pure-logic tests for the Linux scratch model's document / file surface
|
||||
// (dirty-tracking, new/load/save, title). Deliberately avoids the paths that
|
||||
// open a native GtkFileDialog (`openDocument()`, `saveAs()`) — those need a
|
||||
// running GTK application and a display, so they are exercised by hand on the
|
||||
// VM, not here. The paths covered are headless-safe: `CodeEditorController`'s
|
||||
// `setText` is a no-op until a widget is attached, and `save()` with a
|
||||
// `currentPath` set writes the file directly without a dialog.
|
||||
#if os(Linux)
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdLiveCompile
|
||||
@testable import LyrebirdLiveCompileUI
|
||||
|
||||
@Suite("LinuxScratchModel document + file I/O")
|
||||
struct LinuxScratchModelTests {
|
||||
|
||||
private func makeModel(initialSource: String = lyrebirdLinuxScratchSeed) -> LinuxScratchModel {
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: 64,
|
||||
controlBlockSize: 16,
|
||||
sampleRate: 48_000,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: 16,
|
||||
numControlBuses: 16,
|
||||
eventQueueCapacity: lyrebirdDefaultEventQueueCapacity,
|
||||
driver: OfflineDriver()
|
||||
)
|
||||
return LinuxScratchModel(session: LiveSession(engine: engine), initialSource: initialSource)
|
||||
}
|
||||
|
||||
private func tempPath(_ ext: String = "swift") -> String {
|
||||
FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("lyrebird-scratch-\(UUID().uuidString).\(ext)")
|
||||
.path
|
||||
}
|
||||
|
||||
// MARK: - Dirty tracking
|
||||
|
||||
@Test func freshModelIsCleanWithSeed() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
#expect(model.source == lyrebirdLinuxScratchSeed)
|
||||
#expect(model.isDirty == false)
|
||||
#expect(model.currentPath == nil)
|
||||
}
|
||||
|
||||
@Test func setSourceMarksDirtyOnRealChange() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
model.setSource(model.source + "\n// edit")
|
||||
#expect(model.isDirty == true)
|
||||
}
|
||||
|
||||
@Test func setSourceIgnoresUnchangedEcho() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
// A widget echo of the identical value must not flip the dirty flag.
|
||||
model.setSource(model.source)
|
||||
#expect(model.isDirty == false)
|
||||
}
|
||||
|
||||
// MARK: - New
|
||||
|
||||
@Test func newDocumentResetsToSeedAndClean() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
model.setSource("context.play { OscSin.Audio(freq: 440) }")
|
||||
model.currentPath = "/tmp/whatever.swift"
|
||||
#expect(model.isDirty == true)
|
||||
|
||||
model.newDocument()
|
||||
#expect(model.source == lyrebirdLinuxScratchSeed)
|
||||
#expect(model.currentPath == nil)
|
||||
#expect(model.isDirty == false)
|
||||
}
|
||||
|
||||
// MARK: - Load
|
||||
|
||||
@Test func loadFileReplacesBufferAndAdoptsPathClean() throws {
|
||||
let path: String = tempPath()
|
||||
let body: String = "context.play { OscSin.Audio(freq: 220, mul: 0.2) }\n"
|
||||
try body.write(toFile: path, atomically: true, encoding: .utf8)
|
||||
defer { try? FileManager.default.removeItem(atPath: path) }
|
||||
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
model.loadFile(path)
|
||||
#expect(model.source == body)
|
||||
#expect(model.currentPath == path)
|
||||
#expect(model.isDirty == false)
|
||||
}
|
||||
|
||||
@Test func loadFileMissingPathKeepsBuffer() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
let before: String = model.source
|
||||
model.loadFile("/nonexistent/does-not-exist.swift")
|
||||
// Failure is reported to the console; the buffer is untouched.
|
||||
#expect(model.source == before)
|
||||
#expect(model.currentPath == nil)
|
||||
}
|
||||
|
||||
// MARK: - Save
|
||||
|
||||
@Test func saveWritesToCurrentPathAndClears() throws {
|
||||
let path: String = tempPath()
|
||||
defer { try? FileManager.default.removeItem(atPath: path) }
|
||||
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
let code: String = "context.play { WhiteNoise.Audio(mul: 0.1) }"
|
||||
model.setSource(code)
|
||||
model.currentPath = path
|
||||
#expect(model.isDirty == true)
|
||||
|
||||
model.save() // currentPath is set -> writes directly, no dialog
|
||||
#expect(model.isDirty == false)
|
||||
let onDisk: String = try String(contentsOfFile: path, encoding: .utf8)
|
||||
#expect(onDisk == code)
|
||||
}
|
||||
|
||||
@Test func saveThenLoadRoundTrip() throws {
|
||||
let path: String = tempPath()
|
||||
defer { try? FileManager.default.removeItem(atPath: path) }
|
||||
|
||||
let writer: LinuxScratchModel = makeModel()
|
||||
let code: String = "context.play { OscSaw.Audio(freq: 110, mul: 0.15) }"
|
||||
writer.setSource(code)
|
||||
writer.currentPath = path
|
||||
writer.save()
|
||||
|
||||
let reader: LinuxScratchModel = makeModel()
|
||||
reader.loadFile(path)
|
||||
#expect(reader.source == code)
|
||||
#expect(reader.currentPath == path)
|
||||
#expect(reader.isDirty == false)
|
||||
}
|
||||
|
||||
// MARK: - Title
|
||||
|
||||
@Test func displayTitleUntitledWhenNoPath() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
#expect(model.displayTitle == "untitled.swift")
|
||||
}
|
||||
|
||||
@Test func displayTitleShowsFilenameAndDirtyMarker() {
|
||||
let model: LinuxScratchModel = makeModel()
|
||||
model.currentPath = "/home/user/tune.swift"
|
||||
#expect(model.displayTitle == "tune.swift")
|
||||
model.setSource(model.source + " ")
|
||||
#expect(model.displayTitle == "● tune.swift")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user