#Current consensus for dependencies
1 messages · Page 1 of 1 (latest)
you could try zigmod but i just use the built in one cause its "easier" since zigs already installed
relying on third party libraries in a reproducable way is kinda a crapshoot if the most liable thing to break is the build system shipped by zig itself
i wanted to pull in the zig impl of clap for CLI parsing stuff
also reading the Bun codebase trying to see how they solve this but it's v possible they just write everything themselves
if you look at the github issues for clap they show you what to do
yeah but i'm worried how downstream users of my code will handle it if i end up doing two different things side by side?
who cares about downstream users if you are shipping arg parsing?
unless you doing some kinda unholy thing where you argparse as an API
i don't understand the first part sorry
i'm writing a binary
that i'd also like to expose as a library (i know how to do this with rust, for instance)
only the binary will need argparsing
you'd need to test to see what happens i suppose for if you only add clap as a module to an exe and not to a module you export for others to make use of
assuming you have your code setup such that you have a module and exe in a single repo or somethin like that
yeah this is another thing i need to solve, but i'm trying to get a minimum prototype atm
is the built-in package manager documented anywhere? there's this section but i'm unsure if this is the same thing? https://ziglang.org/documentation/master/#Zig-Build-System
thanks for responding btw, much appreciated
nah the package manager is kinda undocumented as far as i know
the build system has better docs recently created for it here:
https://ziglang.org/learn/build-system/
anyway dispite being undocumented the package manager isnt very sophisticated
The build.zig.zon basically is vaguely described here:
https://github.com/ziglang/zig/blob/master/doc/build.zig.zon.md
but basically all that you do is that you add something with a
.dependencies = .{
.some_dep_name = .{
.url = "https://something",
},
},
Then it does some magic with the zig fetch command which can basically only fetch a .tar.gz from a web url at the moment
then it spits out a complaint that the hash is missing and you put that field in
so .url should point to a tarball directly?
yeah
Also supports git urls
when did that get added
during one of the recent build system rewrites I believe
also wouldnt it be kinda inefficient to download the git tree in addition to the source files? Or maybe thats not how git urls work
it downloads a commit, not a tree
right, that's cool and could be v useful for me
oh you specify the commit, thats interesting
so something like https://github.com/Hejsil/zig-clap/commit/cf3a4e763831dd7e0845fef4f209f5c780eda375?
or literally just the sha digest?
git+https://github.com/Hejsil/zig-clap.git#cf3a4e763831dd7e0845fef4f209f5c780eda375
only on zig master
basically the same thing as https://github.com/Hejsil/zig-clap/archive/cf3a4e763831dd7e0845fef4f209f5c780eda375.tar.gz
only supports sha2-256
i should just update zig to master
nvm got it
okay now i just have an import error
$ cat build.zig.zon
.{
.name = "zig-thing",
.version = "0.1.0",
.dependencies = .{
.clap = .{
.url = "git+https://github.com/Hejsil/zig-clap.git#cf3a4e763831dd7e0845fef4f209f5c780eda375",
.hash = "1220b641ac5ed4187f293906201ee07f98423c942bf82e28c7c75a22d700b494c177",
},
},
.paths = .{"", "src/main.zig"},
}
$ zig build
src/main.zig:1:22: error: no module named 'clap' available within module root
const clap = @import("clap");
that's expected, you need to update build.zig too
also paths should look more like .{ "build.zig", "build.zig.zon", "src" }
so i'll need to add a module for clap?
It's now a dependency, so you can load the dependency, get the module that dependency exports, and add the module to your compile step.
oh right, is this what the ticket refers to here? https://github.com/Hejsil/zig-clap/issues/61#issuecomment-1580121478