//! The "client" library domain (library/client): userspace-service clients —
//! they talk to services over IPC, not to the kernel. Client modules end in
//! `-client` the way wire protocols end in `-protocol`, so a service, its
//! protocol, and its client never share a name (`display` the service,
//! `display-protocol` the wire contract, `display-client` a program's view).

const std = @import("std");

pub fn build(b: *std.Build) void {
    const kernel = b.dependency("kernel", .{});
    const protocol = b.dependency("protocol", .{});

    const ipc = kernel.module("ipc");
    const time = kernel.module("time");
    // Every client reaches its service by name now: resolve `/protocol/<name>`,
    // open it, and take the provider's endpoint out of the reply
    // (docs/os-development/protocol-namespace.md).
    const channel = kernel.module("channel");

    // A client frames its own packets, so it needs the envelope alongside the
    // protocol whose verbs it speaks.
    const envelope = protocol.module("envelope");

    _ = b.addModule("display-client", .{
        .root_source_file = b.path("display/display-client.zig"),
        .imports = &.{
            .{ .name = "channel", .module = channel },
            .{ .name = "envelope", .module = envelope },
            .{ .name = "ipc", .module = ipc },
            .{ .name = "time", .module = time },
            .{ .name = "display-protocol", .module = protocol.module("display-protocol") },
        },
    });
    _ = b.addModule("input-client", .{
        .root_source_file = b.path("input/input-client.zig"),
        .imports = &.{
            .{ .name = "channel", .module = channel },
            .{ .name = "envelope", .module = envelope },
            .{ .name = "ipc", .module = ipc },
            .{ .name = "time", .module = time },
            .{ .name = "input-protocol", .module = protocol.module("input-protocol") },
        },
    });

    // Standalone `zig build test`, kept for uniformity across the domains (the
    // root aggregate depends on every domain's test step). The clients have no
    // host-runnable unit tests yet — they are thin IPC conversation wrappers —
    // so the step is empty until one grows some.
    _ = b.step("test", "Run the client unit tests (none yet)");
}
