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:
+219
-37
@@ -1,5 +1,7 @@
|
||||
// swift-tools-version: 6.0
|
||||
import PackageDescription
|
||||
// ProcessInfo — read the LYREBIRD_DISABLE_ALSA opt-out below.
|
||||
import Foundation
|
||||
|
||||
let package = Package(
|
||||
name: "Lyrebird",
|
||||
@@ -21,7 +23,10 @@ let package = Package(
|
||||
// double-registration crash fixed in Phase 167). External consumers
|
||||
// never reference this product — they use `Lyrebird` (static) above.
|
||||
.library(name: "LyrebirdDynamic", type: .dynamic, targets: ["LyrebirdSynth"]),
|
||||
.library(name: "LyrebirdUI", targets: ["LyrebirdUI"]),
|
||||
// LyrebirdUI (SwiftUI/AppKit) product + targets are appended after this
|
||||
// literal under `#if os(macOS)` — they are Apple-only and must be absent
|
||||
// from the manifest on a native Linux/Windows host. See the block below
|
||||
// the `Package(...)` initializer.
|
||||
.library(name: "LyrebirdGraphDSL", targets: ["LyrebirdGraphDSL"]),
|
||||
.executable(name: "LyrebirdCLI", targets: ["LyrebirdCLI"]),
|
||||
],
|
||||
@@ -58,19 +63,38 @@ let package = Package(
|
||||
name: "LyrebirdC",
|
||||
path: "Sources/LyrebirdC"
|
||||
),
|
||||
// Vector-math seam. On Apple this target re-exports Accelerate
|
||||
// (`@_exported import Accelerate`); on non-Apple platforms it supplies
|
||||
// API-compatible scalar replacements for the vDSP/vForce primitives the
|
||||
// synthesis core uses. Every core file writes `import LyrebirdDSP` in
|
||||
// place of `import Accelerate`. See Sources/LyrebirdDSP/AccelerateShim.swift.
|
||||
.target(
|
||||
name: "LyrebirdDSP",
|
||||
path: "Sources/LyrebirdDSP",
|
||||
linkerSettings: [
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
.target(
|
||||
// Module/target renamed `Lyrebird` → `LyrebirdSynth` (the `Lyrebird`
|
||||
// product above still vends it). Folder path kept as `Sources/Lyrebird`
|
||||
// so the source tree and `Lyrebird.docc` catalog don't move.
|
||||
name: "LyrebirdSynth",
|
||||
dependencies: ["LyrebirdC"],
|
||||
// `CALSA` (libasound, for the Linux `ALSAAudioDriver`) is appended
|
||||
// to these dependencies on a Linux host — see the block below the
|
||||
// `Package(...)` initializer.
|
||||
dependencies: ["LyrebirdC", "LyrebirdDSP"],
|
||||
path: "Sources/Lyrebird",
|
||||
linkerSettings: [
|
||||
.linkedFramework("CoreAudio"),
|
||||
.linkedFramework("AudioToolbox"),
|
||||
.linkedFramework("Accelerate"),
|
||||
.linkedFramework("CoreMIDI"),
|
||||
.linkedFramework("AVFoundation"),
|
||||
// Apple-only frameworks. Guarded with `.when(platforms:)` so a
|
||||
// non-Apple target (Linux/Windows feasibility) does not fail at
|
||||
// link-configuration time before source-level errors surface.
|
||||
// macOS/iOS builds are unaffected.
|
||||
.linkedFramework("CoreAudio", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("AudioToolbox", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("CoreMIDI", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("AVFoundation", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
.executableTarget(
|
||||
@@ -87,15 +111,9 @@ let package = Package(
|
||||
]
|
||||
// Swift 6 language mode (Phase 202): inherits the swift-tools 6.0 default.
|
||||
),
|
||||
.target(
|
||||
name: "LyrebirdUI",
|
||||
dependencies: [
|
||||
"LyrebirdSynth",
|
||||
],
|
||||
path: "Sources/LyrebirdUI"
|
||||
// SwiftUI + AppKit + Observation are system frameworks — no linkerSettings needed.
|
||||
// Swift 6 language mode (Phase 202): inherits the swift-tools 6.0 default.
|
||||
),
|
||||
// NOTE: LyrebirdUI, LyrebirdUITests, and LyrebirdTests are appended after
|
||||
// the `Package(...)` initializer under `#if os(macOS)` — they need Apple
|
||||
// frameworks and must be absent from a native Linux/Windows manifest.
|
||||
// Phase 167 — `LyrebirdLiveCompile` (and its SwiftUI host
|
||||
// `LyrebirdLiveCompileUI`) moved to the `LiveCompile/` nested SwiftPM
|
||||
// package. It depends on the internal `.product(name: "LyrebirdDynamic",
|
||||
@@ -105,12 +123,10 @@ let package = Package(
|
||||
// cause of an ObjC class double-registration crash during `swift test`
|
||||
// in the single-package layout. The consumer-facing `Lyrebird` product
|
||||
// stays static (see products list). See `LiveCompile/Package.swift`.
|
||||
.executableTarget(
|
||||
name: "LyrebirdBenchmark",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Sources/LyrebirdBenchmark",
|
||||
swiftSettings: [.unsafeFlags(["-O"])]
|
||||
),
|
||||
// LyrebirdBenchmark micro-benchmarks Accelerate/vDSP primitives directly
|
||||
// (`import Accelerate`), so it is Apple-only and appended under
|
||||
// `#if os(macOS)` below the initializer — otherwise `swift test` on Linux
|
||||
// would try to build it and fail on the missing Accelerate module.
|
||||
// Interpreted graph-DSL. Pure Swift over core `LyrebirdSynth` types —
|
||||
// no swiftc, no AppKit — so it is cross-platform (iOS included). The
|
||||
// `DSLBuiltin` registry it consumes is emitted by the separate
|
||||
@@ -122,22 +138,13 @@ let package = Package(
|
||||
path: "Sources/LyrebirdGraphDSL"
|
||||
),
|
||||
.testTarget(
|
||||
name: "LyrebirdTests",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Tests/LyrebirdTests",
|
||||
name: "LyrebirdDSPTests",
|
||||
dependencies: ["LyrebirdDSP"],
|
||||
path: "Tests/LyrebirdDSPTests",
|
||||
linkerSettings: [
|
||||
.linkedFramework("AudioToolbox"),
|
||||
.linkedFramework("Accelerate"),
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "LyrebirdUITests",
|
||||
dependencies: [
|
||||
"LyrebirdUI",
|
||||
"LyrebirdSynth",
|
||||
],
|
||||
path: "Tests/LyrebirdUITests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "LyrebirdGraphDSLTests",
|
||||
dependencies: [
|
||||
@@ -146,8 +153,8 @@ let package = Package(
|
||||
],
|
||||
path: "Tests/LyrebirdGraphDSLTests",
|
||||
linkerSettings: [
|
||||
.linkedFramework("AudioToolbox"),
|
||||
.linkedFramework("Accelerate"),
|
||||
.linkedFramework("AudioToolbox", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
@@ -155,5 +162,180 @@ let package = Package(
|
||||
dependencies: ["LyrebirdCLI"],
|
||||
path: "Tests/LyrebirdCLITests"
|
||||
),
|
||||
// Platform-neutral core tests. Unlike `LyrebirdTests` (Apple-only —
|
||||
// some files import AudioToolbox/Accelerate directly), this target
|
||||
// compiles and runs on every supported platform, so the golden-value
|
||||
// DSP tests it holds actually execute on Linux in CI. That is the only
|
||||
// place the portable FFT/biquad/vector fallbacks in `LyrebirdDSP` are
|
||||
// verified through the real generators; `LyrebirdDSPTests` compares to
|
||||
// real vDSP and is therefore Apple-only by construction.
|
||||
.testTarget(
|
||||
name: "LyrebirdPortableTests",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Tests/LyrebirdPortableTests",
|
||||
linkerSettings: [
|
||||
.linkedFramework("AudioToolbox", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
// LyrebirdUI — the cross-platform UI module. Public control/view names are the
|
||||
// same on every platform; each file switches its body by backend
|
||||
// (`#if canImport(SwiftUI)` → real SwiftUI on Apple / `#else` → SwiftOpenUI on
|
||||
// Linux). Base dependency is `LyrebirdSynth` (the shared `@UIParam` model);
|
||||
// the Linux block below adds the SwiftOpenUI + BackendGTK4 backend deps. On
|
||||
// Apple, SwiftUI/AppKit are system frameworks so no package dep is needed.
|
||||
package.products.append(
|
||||
.library(name: "LyrebirdUI", targets: ["LyrebirdUI"])
|
||||
)
|
||||
package.targets.append(
|
||||
.target(
|
||||
name: "LyrebirdUI",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Sources/LyrebirdUI"
|
||||
)
|
||||
)
|
||||
|
||||
// Apple-only pieces, added only when the manifest host is macOS.
|
||||
//
|
||||
// `#if` cannot appear as an element inside an array literal in a package
|
||||
// manifest, so these are appended to the already-built `package` instead of
|
||||
// being conditionalized in place. On a native Linux/Windows host (in-container
|
||||
// `swift build`/`swift test`, CI) they are simply absent, so nothing tries to
|
||||
// compile SwiftUI/AppKit or the AudioToolbox-importing test files.
|
||||
//
|
||||
// • LyrebirdUITests — exercises LyrebirdUI (the module itself is now
|
||||
// cross-platform and appended above the initializer).
|
||||
// • LyrebirdBenchmark — micro-benchmarks Accelerate/vDSP primitives directly.
|
||||
// • LyrebirdTests — the main suite; still imports Apple frameworks
|
||||
// directly in some files (e.g. AUv3 driver tests).
|
||||
// Porting its platform-neutral majority to run on
|
||||
// Linux, plus Linux-runnable golden DSP tests, is a
|
||||
// separate work item.
|
||||
//
|
||||
// Cross-compiling from a Mac keeps the host as macOS, so Apple-SDK builds are
|
||||
// unaffected — they still see every target.
|
||||
#if os(macOS)
|
||||
package.targets.append(contentsOf: [
|
||||
.executableTarget(
|
||||
name: "LyrebirdBenchmark",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Sources/LyrebirdBenchmark",
|
||||
swiftSettings: [.unsafeFlags(["-O"])]
|
||||
),
|
||||
.testTarget(
|
||||
name: "LyrebirdTests",
|
||||
dependencies: ["LyrebirdSynth"],
|
||||
path: "Tests/LyrebirdTests",
|
||||
linkerSettings: [
|
||||
.linkedFramework("AudioToolbox", .when(platforms: [.macOS, .iOS])),
|
||||
.linkedFramework("Accelerate", .when(platforms: [.macOS, .iOS])),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "LyrebirdUITests",
|
||||
dependencies: [
|
||||
"LyrebirdUI",
|
||||
"LyrebirdSynth",
|
||||
],
|
||||
path: "Tests/LyrebirdUITests"
|
||||
),
|
||||
])
|
||||
#endif
|
||||
|
||||
// Linux live audio. `ALSAAudioDriver` needs libasound's headers, which are not
|
||||
// installed by default on a build box (`apt-get install libasound2-dev`), so
|
||||
// the target is added only when the manifest is being evaluated ON Linux —
|
||||
// where those headers can actually exist. A macOS host never sees it, whether
|
||||
// building for Apple platforms or cross-compiling to Linux; a cross-compiled
|
||||
// Linux binary therefore has no live-audio driver, only offline NRT rendering.
|
||||
// Build natively on Linux to get audio out.
|
||||
//
|
||||
// Escape hatch: set `LYREBIRD_DISABLE_ALSA=1` to build the rest of Lyrebird on
|
||||
// a Linux box that has no ALSA development package. Everything except the
|
||||
// driver still works — `ALSAAudioDriver` is `#if canImport(CALSA)`-guarded and
|
||||
// simply will not exist, and `makeDefaultAudioDriver()` returns an
|
||||
// `OfflineDriver` instead. Note that SwiftPM caches evaluated manifests, so
|
||||
// flipping this variable on an existing checkout may need the cache cleared
|
||||
// (`rm -rf .build`, or a fresh `--scratch-path`) before it takes effect.
|
||||
#if os(Linux)
|
||||
if ProcessInfo.processInfo.environment["LYREBIRD_DISABLE_ALSA"] == nil {
|
||||
package.targets.append(
|
||||
.systemLibrary(
|
||||
name: "CALSA",
|
||||
path: "Sources/CALSA",
|
||||
pkgConfig: "alsa",
|
||||
providers: [
|
||||
.apt(["libasound2-dev"]),
|
||||
]
|
||||
)
|
||||
)
|
||||
if let synthIndex: Int = package.targets.firstIndex(where: { $0.name == "LyrebirdSynth" }) {
|
||||
package.targets[synthIndex].dependencies.append(.target(name: "CALSA"))
|
||||
}
|
||||
// The portable test target needs it too: its ALSA tests are guarded on
|
||||
// `canImport(CALSA)`, which is only true where the module is a dependency.
|
||||
// Without this the guard is always false and the driver's tests silently
|
||||
// never run.
|
||||
if let testIndex: Int = package.targets.firstIndex(where: { $0.name == "LyrebirdPortableTests" }) {
|
||||
package.targets[testIndex].dependencies.append(.target(name: "CALSA"))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Linux backend for the cross-platform `LyrebirdUI`: SwiftOpenUI (GTK4). This is
|
||||
// now a DEFAULT Linux dependency — building `LyrebirdUI` on Linux pulls
|
||||
// SwiftOpenUI and needs `libgtk-4-dev`. (The default *core* Linux CI lane builds
|
||||
// only LyrebirdSynth / LyrebirdGraphDSL / LyrebirdCLI, so it does not build the
|
||||
// UI or need GTK; a plain `swift build` on Linux does.)
|
||||
//
|
||||
// Pinned to a personal fork commit carrying the GTK4 drag fix ("GTK4: continuous
|
||||
// drag for Canvas value controls": @Observable narrow path + live subtree redraw
|
||||
// + global interaction deferral with linked-control redraw). Move the pin to
|
||||
// `codelynx/SwiftOpenUI` + a version once the fix lands upstream and a release is
|
||||
// tagged. See spikes/SwiftOpenUIKnob/FORK_PATCH_PLAN.md.
|
||||
//
|
||||
// `LyrebirdUI`'s controls bind core `@UIParam` / `UIParamNode` (in
|
||||
// `LyrebirdSynth`), the same model the SwiftUI controls use, so one synthesizer's
|
||||
// parameters drive both platforms.
|
||||
#if os(Linux)
|
||||
// Set LYREBIRD_SWIFTOPENUI_LOCAL=/path/to/SwiftOpenUI to build against a local
|
||||
// fork checkout instead of the pinned release — used to iterate the GTK4 fork
|
||||
// without a push/pin round-trip (this Mac can't build the GTK4 backend; a Linux
|
||||
// container or the VM does). Unset (the default), it resolves the pinned tag.
|
||||
package.dependencies.append(
|
||||
ProcessInfo.processInfo.environment["LYREBIRD_SWIFTOPENUI_LOCAL"].map {
|
||||
.package(name: "SwiftOpenUI", path: $0)
|
||||
} ??
|
||||
// Pinned to the fork's tagged release 0.5.0 (== commit a392026): 0.1.0
|
||||
// (Patches A–F narrow-path + GTK4Backend.openStandaloneWindow → LyrebirdWindow
|
||||
// / presentInWindow + GTK4PointerTracking → Linux MouseTracker), plus the
|
||||
// GtkSourceView-backed `CodeEditor` view (Swift highlighting + gutter) used by
|
||||
// the Linux live-compile scratch editor — which adds a system dependency on
|
||||
// libgtksourceview-5-dev. A tag rather than a bare commit gives a stable,
|
||||
// human-readable release reference; bump it when the fork cuts a new release.
|
||||
// (Upstreaming to codelynx/SwiftOpenUI remains the open follow-on — see
|
||||
// docs/ui/linux-parity-plan.md.)
|
||||
.package(
|
||||
url: "https://github.com/joshpar/SwiftOpenUI",
|
||||
exact: "0.7.0"
|
||||
)
|
||||
)
|
||||
// Give the cross-platform LyrebirdUI target its Linux (GTK4) backend deps.
|
||||
if let uiIndex: Int = package.targets.firstIndex(where: { $0.name == "LyrebirdUI" }) {
|
||||
package.targets[uiIndex].dependencies.append(contentsOf: [
|
||||
.product(name: "SwiftOpenUI", package: "SwiftOpenUI"),
|
||||
.product(name: "BackendGTK4", package: "SwiftOpenUI"),
|
||||
])
|
||||
}
|
||||
// Runnable GTK4 GUI demo: `swift run LyrebirdUILinuxDemo`.
|
||||
package.targets.append(
|
||||
.executableTarget(
|
||||
name: "LyrebirdUILinuxDemo",
|
||||
dependencies: ["LyrebirdSynth", "LyrebirdUI"],
|
||||
path: "Sources/LyrebirdUILinuxDemo"
|
||||
)
|
||||
)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user