build: exact per-binary imports — the pre-wired default set is gone
Every binary's build.zig now names precisely the modules its source
imports (derived by scanning each artifact's sources, transitively
through same-directory files), and its zon carries only the domains
those come from — kernel stays implicit (the root shim + link script
live there). build-support's userBinary resolves each name through one
module-to-domain table (module_homes); Domains/domains()/defaultImports
and the raw recipe entry point are deleted. An undeclared @import is a
compile error (verified: injecting @import("xkeyboard-config") into
logger fails with 'no module named ... available within module
program'), and e.g. xkeyboard-config now appears in exactly two
manifests — the two keyboard drivers. Availability never bloated the
emitted binaries (Zig compiles only what a program imports); this makes
the declared interfaces honest. Production and -Dtest-case manifests
byte-identical; all build variants and standalone package builds
green.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
//! The acpi discovery service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2). The artifact is named "discovery": one swappable process per
|
||||
//! firmware fills the ramdisk's neutral `discovery` slot (docs/discovery.md),
|
||||
//! so the device manager never learns which firmware it is on. The root
|
||||
//! build's -Ddiscovery picks this package or `fdt`.
|
||||
//! The acpi service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
//!
|
||||
//! The artifact is named "discovery": one swappable process per firmware
|
||||
//! fills the ramdisk's neutral `discovery` slot (docs/discovery.md); the
|
||||
//! root's -Ddiscovery picks this package or `fdt`.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
@@ -11,14 +13,10 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "discovery",
|
||||
.root_source_file = b.path("acpi.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{
|
||||
"acpi-ids", "aml", "device-manager-protocol", "driver", "ipc", "logging", "memory",
|
||||
"power-protocol", "process", "service", "time",
|
||||
},
|
||||
});
|
||||
const protocol = b.dependency("protocol", .{});
|
||||
// The shared AML interpreter (the same parser the kernel runs), the
|
||||
// device-manager report channel, and the power protocol (the SCI/power
|
||||
// button path, docs/power.md).
|
||||
build_support.programModule(exe).addImport("aml", b.dependency("device", .{}).module("aml"));
|
||||
build_support.programModule(exe).addImport("device-manager-protocol", protocol.module("device-manager-protocol"));
|
||||
build_support.programModule(exe).addImport("power-protocol", protocol.module("power-protocol"));
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
.fingerprint = 0xf31e9a0903256b64, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
//! The device-manager service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The device-manager service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const protocol = b.dependency("protocol", .{});
|
||||
const device = b.dependency("device", .{});
|
||||
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "device-manager",
|
||||
.root_source_file = b.path("device-manager.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{
|
||||
"device-manager-protocol", "device-registry", "driver", "file-system", "ipc",
|
||||
"logging", "memory", "process", "service", "time",
|
||||
},
|
||||
});
|
||||
build_support.programModule(exe).addImport("device-manager-protocol", protocol.module("device-manager-protocol"));
|
||||
build_support.programModule(exe).addImport("device-registry", device.module("device-registry"));
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
.fingerprint = 0x7092fc24905cd147, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The display-demo service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The display-demo service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
@@ -10,7 +9,7 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "display-demo",
|
||||
.root_source_file = b.path("display-demo.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{ "display", "logging", "time" },
|
||||
});
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
.fingerprint = 0x5d2832e1e2880143, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
//! The display service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The display service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const protocol = b.dependency("protocol", .{});
|
||||
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "display",
|
||||
.root_source_file = b.path("display.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{
|
||||
"display", "display-protocol", "driver", "input", "ipc", "logging", "memory",
|
||||
"scanout-protocol", "service", "thread", "time",
|
||||
},
|
||||
.threaded = true, // real atomics/TLS (docs/threading.md)
|
||||
});
|
||||
build_support.programModule(exe).addImport("display-protocol", protocol.module("display-protocol"));
|
||||
build_support.programModule(exe).addImport("scanout-protocol", protocol.module("scanout-protocol"));
|
||||
b.installArtifact(exe);
|
||||
|
||||
// Standalone `zig build test`; the root aggregate depends on this step.
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
.fingerprint = 0xcd172a34b127a19, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
//! The fat service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The fat service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const protocol = b.dependency("protocol", .{});
|
||||
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "fat",
|
||||
.root_source_file = b.path("fat.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{
|
||||
"block", "file-system", "ipc", "logging", "memory", "process", "service", "time",
|
||||
"vfs-protocol",
|
||||
},
|
||||
});
|
||||
build_support.programModule(exe).addImport("vfs-protocol", protocol.module("vfs-protocol"));
|
||||
b.installArtifact(exe);
|
||||
|
||||
// Standalone `zig build test`; the root aggregate depends on this step.
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
.fingerprint = 0x98958143ecfe1636, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
//! The fdt discovery service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2). The artifact is named "discovery" like acpi's: the Raspberry Pis
|
||||
//! hand over a flattened device tree instead of ACPI, and the aarch64 target
|
||||
//! flips the root build's -Ddiscovery default when it lands (docs/arm.md).
|
||||
//! A placeholder until the ARM bring-up.
|
||||
//! The fdt service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
//!
|
||||
//! The artifact is named "discovery" like acpi's: the Raspberry Pis hand over
|
||||
//! a flattened device tree, and the aarch64 target flips the root's
|
||||
//! -Ddiscovery default when it lands (docs/arm.md). A placeholder until the
|
||||
//! ARM bring-up.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
@@ -11,7 +14,7 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "discovery",
|
||||
.root_source_file = b.path("fdt.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{ "process" },
|
||||
});
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
.fingerprint = 0xe5e27506c7fc2eea, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! init (PID 1) as a binary package (docs/build-packages-plan.md, phase 2):
|
||||
//! this file names only what is specific to init — the shared recipe and the
|
||||
//! default-import wiring live in build-support. The root build consumes the
|
||||
//! artifact for the boot image and forwards its -Dserial here.
|
||||
//! init (PID 1) as a binary package (docs/build-packages-plan.md): this file
|
||||
//! names the binary and EXACTLY the modules its source imports — the shared
|
||||
//! recipe and the module-to-domain map live in build-support. The root build
|
||||
//! consumes the artifact for the boot image and forwards its -Dserial here.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
@@ -10,14 +10,11 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "init",
|
||||
.root_source_file = b.path("init.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{
|
||||
"csv", "file-system", "ipc", "logging", "memory", "power-protocol",
|
||||
"process", "time",
|
||||
},
|
||||
});
|
||||
// init speaks the power protocol (orderly shutdown, docs/power.md) and
|
||||
// parses its boot service list from /etc/init.csv with the shared csv
|
||||
// helpers. Which services it starts is data, not a compile-time option:
|
||||
// the root build selects which init.csv variant is bundled (-Ddiagnose).
|
||||
build_support.programModule(exe).addImport("power-protocol", b.dependency("protocol", .{}).module("power-protocol"));
|
||||
build_support.programModule(exe).addImport("csv", b.dependency("csv", .{}).module("csv"));
|
||||
// init reads the same `serial` flag the kernel does: its liveness heartbeat
|
||||
// is a serial/test-build diagnostic (the QEMU harness's init tests assert
|
||||
// on it, and -Dserial images emit it), so a flashable image runs a purely
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
.fingerprint = 0xc674e474eeeced43, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
.csv = .{ .path = "../../../library/csv" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
//! The input service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The input service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const protocol = b.dependency("protocol", .{});
|
||||
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "input",
|
||||
.root_source_file = b.path("input.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{ "input", "input-protocol", "ipc", "logging", "process", "service" },
|
||||
});
|
||||
build_support.programModule(exe).addImport("input-protocol", protocol.module("input-protocol"));
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
.fingerprint = 0xd82832d7113ed94e, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
.protocol = .{ .path = "../../../library/protocol" },
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The logger service as a binary package (docs/build-packages-plan.md,
|
||||
//! phase 2): this file names only what is specific to this binary — the shared
|
||||
//! recipe and the default-import wiring live in build-support. The root build
|
||||
//! consumes the artifact(s) for the boot image.
|
||||
//! The logger service as a binary package (docs/build-packages-plan.md):
|
||||
//! this file names the binary and EXACTLY the modules its source imports —
|
||||
//! the shared recipe and the module-to-domain map live in build-support.
|
||||
|
||||
const std = @import("std");
|
||||
const build_support = @import("build-support");
|
||||
@@ -10,7 +9,7 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = build_support.userBinary(b, .{
|
||||
.name = "logger",
|
||||
.root_source_file = b.path("logger.zig"),
|
||||
.domains = build_support.domains(b),
|
||||
.imports = &.{ "file-system", "ipc", "logging", "service", "time" },
|
||||
});
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
.fingerprint = 0x987e13f37b0eaea2, // Changing this has security and trust implications.
|
||||
.minimum_zig_version = "0.16.0",
|
||||
.dependencies = .{
|
||||
// build-support supplies the shared recipe; kernel is implicit in
|
||||
// every binary (the root shim + link script live there). The rest
|
||||
// are exactly the homes of this binary's declared imports.
|
||||
.@"build-support" = .{ .path = "../../../build-support" },
|
||||
.kernel = .{ .path = "../../../library/kernel" },
|
||||
.device = .{ .path = "../../../library/device" },
|
||||
.client = .{ .path = "../../../library/client" },
|
||||
.@"xkeyboard-config" = .{ .path = "../../../library/xkeyboard-config" },
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user