//! The "xkeyboard-config" library domain: keyboard layouts compiled from the
//! X11 xkeyboard-config database into native Zig (keycode + modifiers ->
//! keysym/character). The `layouts` tables are generated by
//! tools/make-xkeyboard-config.py; `xkeyboard-config` is the hand-written API
//! over them.

const std = @import("std");

pub fn build(b: *std.Build) void {
    const layouts = b.addModule("layouts", .{
        .root_source_file = b.path("generated/layouts.zig"),
    });
    _ = b.addModule("xkeyboard-config", .{
        .root_source_file = b.path("xkeyboard-config.zig"),
        .imports = &.{.{ .name = "layouts", .module = layouts }},
    });

    // Standalone `zig build test` for this domain alone; the root build keeps
    // its aggregate test step. The keycode->character assertions are the
    // end-to-end proof that the xkb-data -> generator -> Zig-lookup pipeline
    // is correct.
    const test_step = b.step("test", "Run the xkeyboard-config unit tests");
    const xkb_tests = b.addTest(.{
        .root_module = b.createModule(.{
            .root_source_file = b.path("xkeyboard-config.zig"),
            .target = b.resolveTargetQuery(.{}),
            .imports = &.{.{ .name = "layouts", .module = layouts }},
        }),
    });
    test_step.dependOn(&b.addRunArtifact(xkb_tests).step);
}
