Closed ghost closed 1 year ago
Since the new package manager is still completely undocumented, I've refrained myself from using it for now until it's at least stable and/or documented.
However, the const b = step.builder
causes an error because of the fact that build steps now run in parallel, but I already fixed that in commit 324b483, maybe it will work if you git pull capy?
build.zig.zon was at 1d50ad47a33510c1d42ad90d3fdd20c8d53ca64c, will try 232584fe5210f41cb4d259fd2dfe3237956ff661 with 0.11.0-dev.2287+1de64dba2
Hit a different error this time. Looks like this experiment requires more digging. I'll wait for the package manager to improve before trying again.
The only thing preventing capy from being used in the zig package manager is that the install
function isn't exposed in build.zig. If install
is changed to be pub
in build.zig then it works fine with the package manager.
It's kinda against the new module+dependency system, but this works until the package manager gets better documentation. Just do the following:
- const install = @import("build_capy.zig").install;
+ pub const install = @import("build_capy.zig").install;
.{
...
.dependencies = .{
.capy = .{
.url = "https://github.com/capy-ui/capy/archive/232584fe5210f41cb4d259fd2dfe3237956ff661.tar.gz",
.hash = "1220cc01af945ce8eda22be2f46a31a6b0795bd4f6041257bcecd3863267550b49d9",
},
},
}
const capy = @import("root").dependencies.imports.capy;
pub fn build(b: *std.Build) void {
...
capy.install(exe, .{}) catch @panic("capy install failed");
...
}
const capy = @import("capy");
My failed experiment based on bits and pieces from the package manager tickets looks a lot more verbose:
const capy_pkg = b.dependency("capy", .{
.target = target,
.optimize = optimize,
});
const capy_mod = capy_pkg.module("capy");
...
exe.addModule("capy", capy_mod);
@truemedian thanks for the vastly shorter and most likely only correct usage example. I was actually wondering if it's supposed to be this verbose at the consumer side and questioned my hacked together script.
b.dependency is the correct way to use the package manager, but it isn’t built to handle sdk-like packages that need to do their own configuration that depends on a CompileStep.
I see, in that case do you mind sharing a complete build.zig?
The build.zig
in https://github.com/capy-ui/capy/issues/39#issuecomment-1494786972 is what my PR enables, which is closer to how it works right now with zigmod.
Thanks. #40 with @truemedian's build.zig works
If I'm not mistaken and my use of the undocumented zig 0.11 package manager is error free, capy needs changes for downstream
build.zig.zon
to work. Either that, or zig 0.11's experimental package manager isn't capable of pulling in capy yet.What's a working recipe to use capy with
build.zig.zon
?No patch attached because I don't know what the fix is or if capy actually needs one.