77 lines
3.8 KiB
Swift
77 lines
3.8 KiB
Swift
// swift-tools-version: 6.0
|
|
import PackageDescription
|
|
|
|
// Build channel, selected at manifest-evaluation time via the NUCLEIC_CHANNEL
|
|
// environment variable (dev | beta | stable); defaults to `dev`. It drives two
|
|
// things in lockstep:
|
|
// • the app executable's PRODUCT name — which becomes the on-disk binary and
|
|
// therefore the OS process name (Activity Monitor / `ps`):
|
|
// dev -> nucleic-local beta -> nucleic-beta rc -> nucleic-rc stable -> nucleic
|
|
// • a compile-time define the app reads (`BuildChannel`) to pick its build identity
|
|
// and the warning banner (red local / blue beta / gold release-candidate / none stable).
|
|
// Branch mapping (see BUILD.md): dev builds from `dev`, beta from `staging`,
|
|
// rc from `rc`, stable from `main`.
|
|
let nucleicChannel = (Context.environment["NUCLEIC_CHANNEL"] ?? "dev").lowercased()
|
|
let (appProductName, channelDefine): (String, String) = {
|
|
switch nucleicChannel {
|
|
case "stable", "prod", "release": return ("nucleic", "NUCLEIC_STABLE")
|
|
case "rc", "candidate": return ("nucleic-rc", "NUCLEIC_RC")
|
|
case "beta": return ("nucleic-beta", "NUCLEIC_BETA")
|
|
default: return ("nucleic-local", "NUCLEIC_DEV")
|
|
}
|
|
}()
|
|
|
|
let package = Package(
|
|
name: "Nucleic",
|
|
// NucleicProtocol (the shared sync wire layer) must build for iOS too — that's what the
|
|
// NucleicRemote iPhone client links. The host-only targets (NucleicCore/App/spike) use
|
|
// macOS-only APIs and are simply never built for iOS.
|
|
platforms: [.macOS(.v14), .iOS(.v17)],
|
|
products: [
|
|
.library(name: "NucleicProtocol", targets: ["NucleicProtocol"]),
|
|
.library(name: "NucleicCore", targets: ["NucleicCore"]),
|
|
// Product (binary / process) name varies by channel — see `appProductName`.
|
|
.executable(name: appProductName, targets: ["NucleicApp"]),
|
|
.executable(name: "nucleic-spike", targets: ["nucleic-spike"]),
|
|
.executable(name: "fake-claude", targets: ["fake-claude"]),
|
|
.executable(name: "fake-grok", targets: ["fake-grok"]),
|
|
],
|
|
dependencies: [
|
|
.package(url: "https://github.com/groue/GRDB.swift.git", from: "7.0.0"),
|
|
.package(url: "https://github.com/migueldeicaza/SwiftTerm.git", from: "1.2.0"),
|
|
],
|
|
targets: [
|
|
// Pure, platform-agnostic: identifiers, the AgentEvent model, the sync wire
|
|
// protocol (ClientMsg/HostMsg), CBOR framing, and the Noise SecureChannel.
|
|
// No GRDB / Process / Network — compiles for macOS and iOS alike.
|
|
.target(name: "NucleicProtocol"),
|
|
.target(
|
|
name: "NucleicCore",
|
|
dependencies: [
|
|
"NucleicProtocol",
|
|
.product(name: "GRDB", package: "GRDB.swift"),
|
|
]),
|
|
.executableTarget(
|
|
name: "NucleicApp",
|
|
dependencies: ["NucleicCore", .product(name: "SwiftTerm", package: "SwiftTerm")],
|
|
swiftSettings: [.define(channelDefine)],
|
|
plugins: ["EmbedGitCommit"]),
|
|
// Prebuild plugin: stamps the built-from commit into a generated `GitCommit.swift`
|
|
// at build time, so the hash is baked into the binary (correct even on a
|
|
// packaged beta / rc / stable archive, where git isn't present at runtime).
|
|
.plugin(name: "EmbedGitCommit", capability: .buildTool()),
|
|
.executableTarget(name: "nucleic-spike", dependencies: ["NucleicCore"]),
|
|
.executableTarget(name: "fake-claude", dependencies: ["NucleicCore"]),
|
|
.executableTarget(name: "fake-grok", dependencies: ["NucleicCore"]),
|
|
.testTarget(
|
|
name: "NucleicProtocolTests",
|
|
dependencies: ["NucleicProtocol"]
|
|
),
|
|
.testTarget(
|
|
name: "NucleicCoreTests",
|
|
dependencies: ["NucleicCore"],
|
|
resources: [.copy("Fixtures")]
|
|
),
|
|
]
|
|
)
|