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:
@@ -62,7 +62,17 @@ struct ProjectScaffolderBuildTests {
|
||||
/// Raw strings (not `ProjectTemplate` cases) are the parametrized arguments
|
||||
/// because `@Test(arguments:)` requires `Sendable` and the public
|
||||
/// `ProjectTemplate` enum does not declare the conformance.
|
||||
static let spmTemplateRawValues: [String] = ["quickstart", "basic", "demo", "nrt", "score", "ui-demo"]
|
||||
///
|
||||
/// `ui-demo` emits `import AppKit` / `NSApplication`, so it is Apple-only by
|
||||
/// construction and is dropped off Apple rather than being expected to
|
||||
/// build there.
|
||||
static let spmTemplateRawValues: [String] = {
|
||||
var templates: [String] = ["quickstart", "basic", "demo", "nrt", "score"]
|
||||
#if canImport(AppKit)
|
||||
templates.append("ui-demo")
|
||||
#endif
|
||||
return templates
|
||||
}()
|
||||
|
||||
@Test(arguments: spmTemplateRawValues)
|
||||
func templateBuildsAgainstLiveLyrebird(_ rawValue: String) throws {
|
||||
@@ -100,15 +110,54 @@ struct ProjectScaffolderBuildTests {
|
||||
`swift build` failed for template \(template.rawValue) (exit \(result.exitCode)):
|
||||
\(result.output)
|
||||
""")
|
||||
guard result.exitCode == 0 else { return }
|
||||
|
||||
// Compiling is not the same as working. The offline-render templates
|
||||
// pick an output container, and a container the platform cannot write
|
||||
// (CAF off Apple) fails only at run time — a build-only check calls
|
||||
// that healthy. So actually run them and require the file to appear.
|
||||
guard let expectedOutput: String = Self.renderedOutputFileName(for: template) else { return }
|
||||
let run: (exitCode: Int32, output: String) = try Self.runSwiftRun(in: projectRoot)
|
||||
#expect(run.exitCode == 0,
|
||||
"""
|
||||
`swift run` failed for template \(template.rawValue) (exit \(run.exitCode)):
|
||||
\(run.output)
|
||||
""")
|
||||
let renderedPath: String = (projectRoot as NSString).appendingPathComponent(expectedOutput)
|
||||
#expect(fm.fileExists(atPath: renderedPath),
|
||||
"template \(template.rawValue) ran but wrote no \(expectedOutput)")
|
||||
}
|
||||
|
||||
/// The file a template is expected to render, or `nil` for templates that
|
||||
/// open an audio device or a window instead of writing one.
|
||||
private static func renderedOutputFileName(for template: ProjectTemplate) -> String? {
|
||||
switch template.rawValue {
|
||||
case "nrt": return "output.wav"
|
||||
case "score": return "score.wav"
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Run `swift run` in `directory`, capturing merged stdout+stderr.
|
||||
private static func runSwiftRun(in directory: String) throws -> (exitCode: Int32, output: String) {
|
||||
try runProcess(["swift", "run"], in: directory)
|
||||
}
|
||||
|
||||
// MARK: - swift build runner
|
||||
|
||||
/// Run `swift build` in `directory`, capturing merged stdout+stderr.
|
||||
private static func runSwiftBuild(in directory: String) throws -> (exitCode: Int32, output: String) {
|
||||
try runProcess(["swift", "build"], in: directory)
|
||||
}
|
||||
|
||||
/// Run a command in `directory`, capturing merged stdout+stderr.
|
||||
private static func runProcess(
|
||||
_ arguments: [String],
|
||||
in directory: String
|
||||
) throws -> (exitCode: Int32, output: String) {
|
||||
let process: Process = Process()
|
||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
|
||||
process.arguments = ["swift", "build"]
|
||||
process.arguments = arguments
|
||||
process.currentDirectoryURL = URL(fileURLWithPath: directory)
|
||||
|
||||
let pipe: Pipe = Pipe()
|
||||
|
||||
@@ -91,9 +91,29 @@ struct ProjectScaffolderTests {
|
||||
#expect(source.contains("import LyrebirdSynth"))
|
||||
}
|
||||
|
||||
@Test func mainSwiftReferencesCoreAudioDriver() {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "Demo")
|
||||
#expect(source.contains("CoreAudioDriver"))
|
||||
@Test func mainSwiftDefersDriverChoiceToTheLibrary() {
|
||||
// A scaffolded CLI project has to build wherever it was created, and
|
||||
// which drivers exist is not something consumer code can test for: the
|
||||
// Linux driver is absent from a build without libasound, and from a
|
||||
// Linux binary cross-compiled on a Mac. Naming a concrete driver — or
|
||||
// writing the `#if` in the emitted source — produces a project that
|
||||
// fails to compile on those configurations.
|
||||
for template: ProjectTemplate in [.quickstart, .basic, .demo] {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "Demo", template: template)
|
||||
#expect(source.contains("makeDefaultAudioDriver()"), "\(template)")
|
||||
#expect(source.contains("driver: driver"), "\(template)")
|
||||
#expect(!source.contains("CoreAudioDriver()"), "\(template)")
|
||||
#expect(!source.contains("ALSAAudioDriver()"), "\(template)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func appKitTemplateStaysAppleOnly() {
|
||||
// The GUI template imports AppKit, so it is macOS-only by construction;
|
||||
// a platform switch there would imply a portability it does not have.
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "Demo", template: .uiDemo)
|
||||
#expect(source.contains("import AppKit"))
|
||||
#expect(source.contains("CoreAudioDriver()"))
|
||||
#expect(!source.contains("ALSAAudioDriver"))
|
||||
}
|
||||
|
||||
// MARK: - testsSwift template
|
||||
@@ -633,7 +653,9 @@ struct ProjectScaffolderTests {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "Demo", template: .demo)
|
||||
#expect(source.contains("@LiveParam"))
|
||||
#expect(source.contains("SineTone"))
|
||||
#expect(source.contains("CoreAudioDriver"))
|
||||
// Driver choice belongs to the library — see
|
||||
// `mainSwiftDefersDriverChoiceToTheLibrary`.
|
||||
#expect(source.contains("makeDefaultAudioDriver()"))
|
||||
}
|
||||
|
||||
@Test func demoMainSwiftContainsName() {
|
||||
@@ -712,7 +734,10 @@ struct ProjectScaffolderTests {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "MyRender", template: .nrt)
|
||||
#expect(source.contains("NRTDriver"))
|
||||
#expect(source.contains("renderDuration"))
|
||||
#expect(source.contains("output.caf"))
|
||||
// WAV, not CAF: CAF is Apple-only, so a CAF render fails at run time
|
||||
// on Linux even though the project compiles there.
|
||||
#expect(source.contains("output.wav"))
|
||||
#expect(source.contains(".wavFloat32"))
|
||||
}
|
||||
|
||||
@Test func nrtMainSwiftContainsName() {
|
||||
@@ -738,7 +763,8 @@ struct ProjectScaffolderTests {
|
||||
@Test func scoreMainSwiftRendersOfflineWithNRTDriver() {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "MyPiece", template: .score)
|
||||
#expect(source.contains("NRTDriver"))
|
||||
#expect(source.contains("score.caf"))
|
||||
#expect(source.contains("score.wav"))
|
||||
#expect(source.contains(".wavFloat32"))
|
||||
#expect(source.contains("engine.schedule"))
|
||||
// Must not embed the Lyrebird copyright in emitted user source.
|
||||
#expect(!source.contains("Joshua Parmenter"))
|
||||
|
||||
Reference in New Issue
Block a user