Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace libwayland with shimizu #1295

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ pub fn build(b: *std.Build) !void {
if (want_examples) try buildExamples(b, optimize, target, module);
}
if (want_core) {
if (target.result.os.tag == .linux) {
module.addCSourceFile(.{
.file = b.path("src/core/linux/wayland.c"),
});
}
linkCore(b, module);
}
if (want_sysaudio) {
Expand Down Expand Up @@ -278,11 +273,42 @@ fn linkCore(b: *std.Build, module: *std.Build.Module) void {
const optimize = module.optimize orelse @panic("module must have .optimize specified");

if (target.result.os.tag == .linux) {
if (b.lazyDependency("wayland_headers", .{
if (b.lazyDependency("shimizu", .{
.target = target,
.optimize = optimize,
})) |dep| {
module.linkLibrary(dep.artifact("wayland-headers"));
module.addImport("shimizu", dep.module("shimizu"));

const generate_wayland_protocols_zig_cmd = b.addRunArtifact(dep.artifact("shimizu-scanner"));
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/xdg-shell.xml"));
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/xdg-decoration-unstable-v1.xml"));

// lowest common denominators as of 2024-01-05 https://wayland.app/protocols/xdg-shell#compositor-support
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "xdg_wm_base", "2" });
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "wp_presentation", "1" });
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "wp_viewporter", "1" });
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zwp_linux_dmabuf_v1", "3" });
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zwp_tablet_manager_v2", "1" });
generate_wayland_protocols_zig_cmd.addArgs(&.{ "--interface-version", "zxdg_decoration_manager_v1", "1" });

generate_wayland_protocols_zig_cmd.addArg("--import");
generate_wayland_protocols_zig_cmd.addFileArg(b.path("src/core/linux/Wayland/wayland.xml"));
generate_wayland_protocols_zig_cmd.addArg("@import(\"core\")");

generate_wayland_protocols_zig_cmd.addArg("--output");
const wayland_protocols_dir = generate_wayland_protocols_zig_cmd.addOutputDirectoryArg("wayland-unstable");

const wayland_protocols_module = b.addModule("wayland-protocols", .{
.root_source_file = wayland_protocols_dir.path(b, "root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "wire", .module = dep.module("wire") },
.{ .name = "core", .module = dep.module("core") },
},
});

module.addImport("wayland-protocols", wayland_protocols_module);
}
if (b.lazyDependency("x11_headers", .{
.target = target,
Expand Down
7 changes: 3 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
.hash = "1220aa08da5d0682f5e6defcd8fcc3f7fbd7c3f471ec25cca6cc47e1e0f003dad28b",
.lazy = true,
},
.wayland_headers = .{
.url = "https://pkg.machengine.org/wayland-headers/464f5d7e9de3bd93dd6f4b4f880b7276ecdcaf13.tar.gz",
.hash = "12205ac3159cfe9af679bf43545a71e45216ee110ee6d37ee4bedbb1cbc7f6caff7d",
.lazy = true,
.shimizu = .{
.url = "https://git.sr.ht/~geemili/shimizu/archive/76ea423f2467978020765e8e3d0975a14aa641f8.tar.gz",
.hash = "1220875e9cb9629bdf5cb5387b40b229d09ae5079c59519e4d49e22674df461eb40d",
},
.x11_headers = .{
.url = "https://pkg.machengine.org/x11-headers/29aefb525d5c08b05b0351e34b1623854a138c21.tar.gz",
Expand Down
Loading
Loading