Mezzaluna/build.zig
Harrison DiAmbrosio 7325a3ee47 batman
2025-10-16 10:39:24 -04:00

71 lines
2.4 KiB
Zig

const std = @import("std");
const Scanner = @import("wayland").Scanner;
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// If instead your goal is to create an executable, consider if users might
// be interested in also being able to embed the core functionality of your
// program in their own executable in order to avoid the overhead involved in
// subprocessing your CLI tool.
// The below is copied from tinywl
// TODO: Ensure versioning is correct
// TODO: Ensure paths for system protocols are correct
const scanner = Scanner.create(b, .{});
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
scanner.addSystemProtocol("stable/tablet/tablet-v2.xml");
scanner.generate("wl_compositor", 4);
scanner.generate("wl_subcompositor", 1);
scanner.generate("wl_shm", 1);
scanner.generate("wl_output", 4);
scanner.generate("wl_seat", 7);
scanner.generate("wl_data_device_manager", 3);
scanner.generate("xdg_wm_base", 2);
scanner.generate("zwp_tablet_manager_v2", 1);
const wayland = b.createModule(.{ .root_source_file = scanner.result });
const xkbcommon = b.dependency("xkbcommon", .{}).module("xkbcommon");
const pixman = b.dependency("pixman", .{}).module("pixman");
const wlroots = b.dependency("wlroots", .{}).module("wlroots");
wlroots.addImport("wayland", wayland);
wlroots.addImport("xkbcommon", xkbcommon);
wlroots.addImport("pixman", pixman);
wlroots.resolved_target = target;
wlroots.linkSystemLibrary("wlroots-0.19", .{});
const wwm = b.addExecutable(.{
.name = "wwm",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
wwm.linkLibC();
wwm.root_module.addImport("wayland", wayland);
wwm.root_module.addImport("xkbcommon", xkbcommon);
wwm.root_module.addImport("wlroots", wlroots);
wwm.linkSystemLibrary("wayland-server");
wwm.linkSystemLibrary("xkbcommon");
wwm.linkSystemLibrary("pixman-1");
b.installArtifact(wwm);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(wwm);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
}