wayprompt/build.zig
2024-01-05 03:34:38 +01:00

95 lines
3.8 KiB
Zig

const std = @import("std");
const fs = std.fs;
const mem = std.mem;
const Scanner = @import("deps/zig-wayland/build.zig").Scanner;
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const options = b.addOptions();
const scanner = Scanner.create(b, .{});
scanner.addCustomProtocol("protocol/wlr-layer-shell-unstable-v1.xml");
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); // Dependency of layer-shell.
scanner.addSystemProtocol("staging/cursor-shape/cursor-shape-v1.xml");
scanner.addSystemProtocol("unstable/tablet/tablet-unstable-v2.xml"); // Dependency of cursor-shape.
scanner.generate("wp_cursor_shape_manager_v1", 1);
scanner.generate("wl_compositor", 5);
scanner.generate("wl_shm", 1);
scanner.generate("zwlr_layer_shell_v1", 3);
scanner.generate("wl_seat", 8);
scanner.generate("wl_output", 4);
const wayland = b.createModule(.{ .source_file = scanner.result });
const xkbcommon = b.createModule(.{
.source_file = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" },
});
const pixman = b.createModule(.{
.source_file = .{ .path = "deps/zig-pixman/pixman.zig" },
});
const spoon = b.createModule(.{
.source_file = .{ .path = "deps/zig-spoon/import.zig" },
});
const fcft = b.createModule(.{
.source_file = .{ .path = "deps/zig-fcft/fcft.zig" },
.dependencies = &.{
.{ .name = "pixman", .module = pixman },
},
});
const wayprompt_cli = b.addExecutable(.{
.name = "wayprompt",
.root_source_file = .{ .path = "src/wayprompt-cli.zig" },
.target = target,
.optimize = optimize,
});
wayprompt_cli.linkLibC();
wayprompt_cli.addModule("wayland", wayland);
wayprompt_cli.linkSystemLibrary("wayland-client");
wayprompt_cli.linkSystemLibrary("wayland-cursor");
scanner.addCSource(wayprompt_cli);
wayprompt_cli.addModule("fcft", fcft);
wayprompt_cli.linkSystemLibrary("fcft");
wayprompt_cli.addModule("xkbcommon", xkbcommon);
wayprompt_cli.linkSystemLibrary("xkbcommon");
wayprompt_cli.addModule("pixman", pixman);
wayprompt_cli.linkSystemLibrary("pixman-1");
wayprompt_cli.addModule("spoon", spoon);
wayprompt_cli.addOptions("build_options", options);
b.installArtifact(wayprompt_cli);
const wayprompt_pinentry = b.addExecutable(.{
.name = "pinentry-wayprompt",
.root_source_file = .{ .path = "src/wayprompt-pinentry.zig" },
.target = target,
.optimize = optimize,
});
wayprompt_pinentry.linkLibC();
wayprompt_pinentry.addModule("wayland", wayland);
wayprompt_pinentry.linkSystemLibrary("wayland-client");
wayprompt_pinentry.linkSystemLibrary("wayland-cursor");
scanner.addCSource(wayprompt_pinentry);
wayprompt_pinentry.addModule("fcft", fcft);
wayprompt_pinentry.linkSystemLibrary("fcft");
wayprompt_pinentry.addModule("xkbcommon", xkbcommon);
wayprompt_pinentry.linkSystemLibrary("xkbcommon");
wayprompt_pinentry.addModule("pixman", pixman);
wayprompt_pinentry.linkSystemLibrary("pixman-1");
wayprompt_pinentry.addModule("spoon", spoon);
wayprompt_pinentry.addOptions("build_options", options);
b.installArtifact(wayprompt_pinentry);
const tests = b.addTest(.{
.root_source_file = .{ .path = "src/tests.zig" },
.target = target,
.optimize = optimize,
});
const run_test = b.addRunArtifact(tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_test.step);
b.installFile("doc/wayprompt.1", "share/man/man1/wayprompt.1");
b.installFile("doc/pinentry-wayprompt.1", "share/man/man1/pinentry-wayprompt.1");
b.installFile("doc/wayprompt.5", "share/man/man5/wayprompt.5");
}