diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2024-09-07 21:10:38 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2024-09-07 21:10:38 +0300 |
commit | 31b331a3a53884b41926bd6fee5dbc3505e8acde (patch) | |
tree | 1c7b3987073b92e70a017895ca2ba2f34f8e1fc6 /build.zig | |
download | zigway-31b331a3a53884b41926bd6fee5dbc3505e8acde.tar.gz zigway-31b331a3a53884b41926bd6fee5dbc3505e8acde.zip |
init: zig wayland hello world client
Adapted the example from chapters 7 and 8 of the Wayland book
(https://wayland-book.com/) into Zig.
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..5e885fc --- /dev/null +++ b/build.zig @@ -0,0 +1,44 @@ +const std = @import("std"); + +const Scanner = @import("zig-wayland").Scanner; + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + + const optimize = b.standardOptimizeOption(.{}); + + const scanner = Scanner.create(b, .{}); + scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); + scanner.addSystemProtocol("staging/fractional-scale/fractional-scale-v1.xml"); + scanner.generate("wl_compositor", 6); + scanner.generate("wl_shm", 1); + scanner.generate("wl_output", 4); + scanner.generate("xdg_wm_base", 2); + scanner.generate("wp_fractional_scale_manager_v1", 1); + + const wayland = b.createModule(.{ .root_source_file = scanner.result }); + + const exe = b.addExecutable(.{ + .name = "zigway", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + exe.root_module.addImport("wayland", wayland); + exe.linkLibC(); + exe.linkSystemLibrary("wayland-client"); + + scanner.addCSource(exe); + + b.installArtifact(exe); + + const run_cmd = b.addRunArtifact(exe); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} |