update README and rename (wayland->wl in project name)

This commit is contained in:
2026-03-21 17:30:57 +00:00
parent d903e5c126
commit aec9ff7d23
4 changed files with 15 additions and 22 deletions
+7 -13
View File
@@ -1,20 +1,15 @@
# Wayland Protocol Code Generator # Wayland Protocol Code Generator
Code generation for Wayland protocols, for use without libwayland. Code generation for Wayland protocols, for use without libwayland.
Generated code is NOT ABI compatible with libwayland. Generated code is NOT ABI compatible with libwayland. Users of the generated
code are expected to implement Wayland wire communication handling themselves.
I wrote this to use in my own projects to avoid the callback-heavy
interface provided by libwayland and the standard wayland-scanner.
This generator currently only supports generating Zig code, but I plan This generator currently only supports generating Zig code, but I plan
to add an option to emit the code as a single-header C library too. to add an option to emit the code as a single-header C library in the future.
I'll probably also give this all a cleanup pass soon. This code was all
written rather quickly and probably can be tidied up.
> [!NOTE] > [!NOTE]
> This program currently only generates client-compatible code. > This program currently only generates client-compatible code.
> Support for server-compatible codegen may come later if I feel like it. > Support for server-compatible codegen may come later.
## Usage ## Usage
@@ -25,7 +20,7 @@ and `protocols.zig` can be generated by running the program as below:
``` ```
# The program can be run with as many input protocols as you'd like # The program can be run with as many input protocols as you'd like
$ ./zig-out/bin/wayland-protocol-generator -o protocols.zig path/to/wayland.xml path/to/protocol1.xml path/to/protocolN.xml $ ./zig-out/bin/wl-protocol-codegen -o protocols.zig path/to/wayland.xml path/to/protocol1.xml path/to/protocolN.xml
``` ```
This will read in all provided xml files and produce a single `protocols.zig` This will read in all provided xml files and produce a single `protocols.zig`
@@ -45,7 +40,7 @@ as a module as follows:
Add this repo as a dependency. You can do this manually or by invoking: Add this repo as a dependency. You can do this manually or by invoking:
```shell ```shell
$ zig fetch --save git+https://github.com/ptrToLiam/wayland-protocol-codegen $ zig fetch --save git+https://github.com/ptrToLiam/wl-protocol-codegen
``` ```
Then add some lines such as the following to your `build.zig`: Then add some lines such as the following to your `build.zig`:
@@ -58,7 +53,7 @@ const wayland_protocol_specifications = [_]std.Build.LazyPath{
..., ...,
}; };
const wayland_protocols = b.dependency("wayland_protocol_codegen", .{ const wayland_protocols = b.dependency("wl_protocol_codegen", .{
.protocols = &wayland_protocol_specifications, .protocols = &wayland_protocol_specifications,
}).module("wayland-protocols"); }).module("wayland-protocols");
exe.root_module.addImport("wayland-protocols", wayland_protocols); exe.root_module.addImport("wayland-protocols", wayland_protocols);
@@ -66,4 +61,3 @@ exe.root_module.addImport("wayland-protocols", wayland_protocols);
This will allow you to import the protocol code with This will allow you to import the protocol code with
`@import("wayland-protocols")` in your executable module's source code. `@import("wayland-protocols")` in your executable module's source code.
+2 -5
View File
@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {
}); });
const generator = b.addExecutable(.{ const generator = b.addExecutable(.{
.name = "wayland-protocol-codegen", .name = "wl-protocol-codegen",
.root_module = root, .root_module = root,
}); });
b.installArtifact(generator); b.installArtifact(generator);
@@ -33,16 +33,13 @@ pub fn build(b: *std.Build) !void {
wl_generate_cmd.addFileArg(protocol); wl_generate_cmd.addFileArg(protocol);
} }
wl_generate_cmd.addArg("-o");
if (debug_opt) wl_generate_cmd.addArg("--debug"); if (debug_opt) wl_generate_cmd.addArg("--debug");
wl_generate_cmd.addArg("-o");
const protocols_zig = wl_generate_cmd.addOutputFileArg("protocols.zig"); const protocols_zig = wl_generate_cmd.addOutputFileArg("protocols.zig");
const protocols_zig_module = b.addModule("wayland-protocols", .{ const protocols_zig_module = b.addModule("wayland-protocols", .{
.root_source_file = protocols_zig, .root_source_file = protocols_zig,
}); });
_ = protocols_zig_module; _ = protocols_zig_module;
} }
} }
+5 -3
View File
@@ -1,10 +1,12 @@
.{ .{
.name = .wayland_protocol_codegen, .name = .wl_protocol_codegen,
.version = "0.0.0", .version = "0.1.0",
.fingerprint = 0xe5b43b9ebc061f42, .fingerprint = 0x170494c9b73f40bc,
.minimum_zig_version = "0.16.0-dev.2261+d6b3dd25a", .minimum_zig_version = "0.16.0-dev.2261+d6b3dd25a",
.paths = .{ .paths = .{
"build.zig", "build.zig",
"README.md",
"LICENSE",
"src", "src",
}, },
} }
+1 -1
View File
@@ -1893,7 +1893,7 @@ const UsageMsgFmt =
const OutputBeginString = const OutputBeginString =
\\// This file is generated from provided Wayland XML specifications by \\// This file is generated from provided Wayland XML specifications by
\\// wayland-protocol-codegen and should NOT be edited manually. \\// wl-protocol-codegen and should NOT be edited manually.
\\ \\
; ;