Zig package manager distribution of Godot Engine binaries.
This repository syncs Godot releases from godotengine/godot-builds and exposes them as lazy dependencies for use in Zig projects. Headers are generated on-demand by running the Godot executable.
Add this package to your build.zig.zon:
zig fetch --save=godot git+https://github.com/gdzig/godot-versionsThen in your build.zig:
const std = @import("std");
const godot = @import("godot");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
// Get the Godot executable
if (godot.executable(b, target, "4.5")) |exe_path| {
// exe_path is a LazyPath to the Godot binary
}
// Get the headers (extension_api.json, gdextension_interface.h)
if (godot.headers(b, target, .{ .version = "4.5" })) |headers_dir| {
// headers_dir is a LazyPath to the generated headers
}
}By default, constraints match stable releases only. Append a prerelease suffix to include prereleases at that level or above.
| Constraint | Meaning | Example Match |
|---|---|---|
"4.5.1" |
Exact stable version | 4.5.1 |
"4.5" |
Any 4.5.x stable | 4.5.0, 4.5.1, ... (highest) |
"4" |
Any 4.x.x stable | 4.0.0, 4.5.1, ... (highest) |
"latest" |
Latest stable | 4.5.1 (currently) |
"4.6.0-beta2" |
Exact prerelease | 4.6.0-beta2 only |
"4.6-rc" |
Any 4.6.x rc or stable | 4.6.0-rc1 ... 4.6.0 (highest) |
"4.6-beta" |
Any 4.6.x beta or above | 4.6.0-beta1 ... 4.6.0 (highest) |
"4.6-dev" |
Any 4.6.x including prereleases | 4.6.0-dev1 ... 4.6.0 (highest) |
"rc" |
Latest rc or stable | 4.5.1 (currently) |
"beta" |
Latest beta, rc or stable | 4.5.1 (currently) |
"dev" |
Latest including all prereleases | 4.6.0-beta2 (currently) |
| Platform | Architectures |
|---|---|
| Linux | x86_64, x86, aarch64, arm |
| macOS | universal |
| Windows | x86_64, x86, aarch64 |
Returns a LazyPath to the Godot executable matching the version constraint for the given target. Returns null if the lazy dependency is not yet fetched.
if (godot.executable(b, target, "4.5")) |exe| {
const run = b.addRunArtifact(exe);
// ...
}Returns a LazyPath to a directory containing the generated header files. Headers are generated by running the Godot executable with the appropriate flags for the version:
extension_api.json- GDExtension API (with docs for 4.2+)gdextension_interface.h- C interface headergdextension_interface.json- JSON interface (4.6.0-dev5+ only)
// From a version constraint
if (godot.headers(b, target, .{ .version = "4.5" })) |dir| {
const api = dir.path(b, "extension_api.json");
const header = dir.path(b, "gdextension_interface.h");
}
// From a custom executable
const custom_godot = b.path("path/to/godot");
if (godot.headers(b, target, .{ .exe = custom_godot })) |dir| {
// ...
}Returns the raw dependency if you need access to other files in the package.
When used as the root package, you can fetch and run Godot directly:
# Install Godot to zig-out/bin/ and headers to zig-out/include/
zig build
# Install a specific version
zig build -Dversion="4.5.1"
zig build -Dversion="4.6-beta"
# Run Godot
zig build run -- --helpThis repository automatically syncs new releases from godotengine/godot-builds daily via GitHub Actions. New stable releases, betas, release candidates, and dev builds are typically available within 24 hours of their official release.
Godot Engine is licensed under the MIT license. See https://github.com/godotengine/godot/blob/master/LICENSE.txt