s-ol / openxr-zig

MIT License
18 stars 1 forks source link

Release is necessary for integrating with Zig's Package Manager (build.zig.zon) #2

Open James-Riordan opened 10 months ago

James-Riordan commented 10 months ago

In order to use Zig's package manager to install this library as a project dependency, it's necessary to create releases.

build.zig.zon required a tar.gz or tar.xz file.

s-ol commented 10 months ago

@James-Riordan I'd tackle this once the package manager is released (presumably with 0.12?), feel free to ping here again once that drops

James-Riordan commented 10 months ago

@s-ol package manager was released with 0.11. It uses build.zig.zon. I found a way to get the tar.gz and hash with instructions on the vulkan-zig repo, but it still would be nice if there were releases to make it all easier. Zig requires a manual step of acquiring the hash of the tar.gz. On mac, I had to do something like 'shasum -a 256 ./path/to/tar.gz'.

It'd be appreciated if in each release there was also a hash included in release notes.

Link to Zig's 0.11 release notes on package manager:

https://ziglang.org/download/0.11.0/release-notes.html#Package-Management

Snippet from Snektron/vulkan-zig README for installing via package manager:

Generation with the package manager from build.zig

There is also support for adding this project as a dependency through zig package manager in its current form. In order to do this, add this repo as a dependency in your build.zig.zon:

.{
    // -- snip --
    .dependencies = .{
        // -- snip --
        .vulkan_zig = .{
            .url = "https://github.com/Snektron/vulkan-zig/archive/<commit SHA>.tar.gz",
            .hash = "<dependency hash>",
        },
    },
}

And then in your build.zig file, you'll need to add a line like this to your build function:

const vkzig_dep = b.dependency("vulkan_zig", .{
    .registry = @as([]const u8, b.pathFromRoot("path/to/vk.xml")),
});
const vkzig_bindings = vkzig_dep.module("vulkan-zig");
exe.addModule("vulkan-zig", vkzig_bindings);

That will allow you to @import("vulkan-zig") in your executable's source.

s-ol commented 10 months ago

Oh, I must've misread something then.

Have you tested the current build.zig with a locally gzipped archive and the package manager feature already?