Skip to content

Commit ec10dae

Browse files
committed
replace libwayland with shimizu
1 parent 825a676 commit ec10dae

13 files changed

Lines changed: 6772 additions & 566 deletions

build.zig

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ pub fn build(b: *std.Build) !void {
101101
if (want_examples) try buildExamples(b, optimize, target, module);
102102
}
103103
if (want_core) {
104-
if (target.result.os.tag == .linux) {
105-
module.addCSourceFile(.{
106-
.file = b.path("src/core/linux/wayland.c"),
107-
});
108-
}
109104
linkCore(b, module);
110105
}
111106
if (want_sysaudio) {
@@ -278,11 +273,42 @@ fn linkCore(b: *std.Build, module: *std.Build.Module) void {
278273
const optimize = module.optimize orelse @panic("module must have .optimize specified");
279274

280275
if (target.result.os.tag == .linux) {
281-
if (b.lazyDependency("wayland_headers", .{
276+
if (b.lazyDependency("shimizu", .{
282277
.target = target,
283278
.optimize = optimize,
284279
})) |dep| {
285-
module.linkLibrary(dep.artifact("wayland-headers"));
280+
module.addImport("shimizu", dep.module("shimizu"));
281+
282+
const generate_wayland_protocols_zig_cmd = b.addRunArtifact(dep.artifact("shimizu-scanner"));
283+
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/xdg-shell.xml"));
284+
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/xdg-decoration-unstable-v1.xml"));
285+
286+
// lowest common denominators as of 2024-01-05 https://wayland.app/protocols/xdg-shell#compositor-support
287+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "xdg_wm_base", "2" });
288+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "wp_presentation", "1" });
289+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "wp_viewporter", "1" });
290+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zwp_linux_dmabuf_v1", "3" });
291+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zwp_tablet_manager_v2", "1" });
292+
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zxdg_decoration_manager_v1", "1" });
293+
294+
generate_wayland_protocols_zig_cmd.addArg("--import");
295+
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/wayland.xml"));
296+
generate_wayland_protocols_zig_cmd.addArg("@import(\"core\")");
297+
298+
generate_wayland_protocols_zig_cmd.addArg("--output");
299+
const wayland_protocols_dir = generate_wayland_protocols_zig_cmd.addOutputDirectoryArg("wayland-unstable");
300+
301+
const wayland_protocols_module = b.addModule("wayland-protocols", .{
302+
.root_source_file = wayland_protocols_dir.path(b, "root.zig"),
303+
.target = target,
304+
.optimize = optimize,
305+
.imports = &.{
306+
.{ .name = "wire", .module = dep.module("wire") },
307+
.{ .name = "core", .module = dep.module("core") },
308+
},
309+
});
310+
311+
module.addImport("wayland-protocols", wayland_protocols_module);
286312
}
287313
if (b.lazyDependency("x11_headers", .{
288314
.target = target,

build.zig.zon

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
.hash = "1220aa08da5d0682f5e6defcd8fcc3f7fbd7c3f471ec25cca6cc47e1e0f003dad28b",
5353
.lazy = true,
5454
},
55-
.wayland_headers = .{
56-
.url = "https://pkg.machengine.org/wayland-headers/464f5d7e9de3bd93dd6f4b4f880b7276ecdcaf13.tar.gz",
57-
.hash = "12205ac3159cfe9af679bf43545a71e45216ee110ee6d37ee4bedbb1cbc7f6caff7d",
58-
.lazy = true,
55+
.shimizu = .{
56+
.url = "https://git.sr.ht/~geemili/shimizu/archive/76ea423f2467978020765e8e3d0975a14aa641f8.tar.gz",
57+
.hash = "1220875e9cb9629bdf5cb5387b40b229d09ae5079c59519e4d49e22674df461eb40d",
5958
},
6059
.x11_headers = .{
6160
.url = "https://pkg.machengine.org/x11-headers/29aefb525d5c08b05b0351e34b1623854a138c21.tar.gz",

0 commit comments

Comments
 (0)