init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# Wayland Protocol Code Generator
|
||||
|
||||
Code generation for Wayland protocols, for use without libwayland.
|
||||
Generated code is NOT ABI compatible with libwayland.
|
||||
|
||||
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
|
||||
to add an option to emit the code as a single-header C library too.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### CLI
|
||||
|
||||
The binary can be produced by invoking `zig build` in the project root
|
||||
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
|
||||
$ ./zig-out/bin/wayland-protocol-generator -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`
|
||||
which will include the code for each protocol.
|
||||
|
||||
The core wayland protocol can be found at
|
||||
https://gitlab.freedesktop.org/wayland/wayland and additional protocol
|
||||
specifications can be found at
|
||||
https://gitlab.freedesktop.org/wayland/wayland-protocols
|
||||
|
||||
|
||||
### Generation Via Build.zig
|
||||
|
||||
You can use the zig build system to generate `protocols.zig` and expose it
|
||||
as a module as follows:
|
||||
|
||||
Add this repo as a dependency. You can do this manually or by invoking:
|
||||
|
||||
```shell
|
||||
$ zig fetch --save git+https://github.com/ptrToLiam/wayland-protocol-codegen
|
||||
```
|
||||
|
||||
Then add some lines such as the following to your `build.zig`:
|
||||
|
||||
```zig
|
||||
const wayland_protocol_specifications = [_]std.Build.LazyPath{
|
||||
b.path("path/to/wayland.xml"),
|
||||
b.path("path/to/protocol1.xml"),
|
||||
b.path("path/to/protocolN.xml"),
|
||||
...,
|
||||
};
|
||||
|
||||
const wayland_protocols = b.dependency("wayland_zig", .{
|
||||
.protocols = &wayland_protocol_specifications,
|
||||
}).module("wayland-protocols");
|
||||
exe.root_module.addImport("wayland-protocols", wayland_protocols);
|
||||
```
|
||||
|
||||
This will allow you to import the protocol code with
|
||||
`@import("wayland-protocols")` in your executable module's source code.
|
||||
|
||||
Reference in New Issue
Block a user