From 31b331a3a53884b41926bd6fee5dbc3505e8acde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Sat, 7 Sep 2024 21:10:38 +0300 Subject: init: zig wayland hello world client Adapted the example from chapters 7 and 8 of the Wayland book (https://wayland-book.com/) into Zig. --- build.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 build.zig (limited to 'build.zig') 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); +} -- cgit v1.2.3