#How to use zig-fetch with git repos
1 messages · Page 1 of 1 (latest)
you need to use git+https://host/path for a git repository
ty!
does this also add it to my project, or do I have to mess around with build.zig as well?
and is this -> https://zig.news/edyu/zig-package-manager-wtf-is-zon-558e article still up-to-date?
looks to be mostly correct, I'd supplement it with https://ziglang.org/download/0.12.0/release-notes.html#Build-System though
and yes, you need to add the dependency as an import if you want to use it
cool, ty again!
I'm having trouble with the path, is there a standard location where the package manager installs things?
ie.
const chrono = b.addStaticLibrary(.{
.name = "chrono",
.root_source_file = .{.path = ""}
.target = target,
.optimize = optimize,
});
exe.linkLibrary(chrono);
Where would the path be?
nowhere, you didn't install it anywhere
even through the zig fetch command? If not how would I install it?
zig fetch gives you a hash that you use to reference it
and that is the path?
can you please say what you are actually trying to do
I am trying to add a library from git -> https://github.com/leroycep/chrono-zig
I have used zig fetch --save to get it into build.zig.zon
I am stuck actually being able to use and build with the package installed. Ie. configuring build.zig
what does your build.zig.zon look like
// ^ ommitted for brevity
// (just project name + version)
.dependencies = .{
.chrono = .{
.url = "git+https://github.com/leroycep/chrono-zig.git#bedd9339af9b05c240956b137cb1a5b67a9b74b7",
.hash = "12200e5959fd68f7b2101eae5b6f23a213712810814cef42f44e112cc7b4f14f0248",
},
},
.paths = .{
"",
},
}
my_exe.root_module.addImport("chrono", b.dependency("chrono", .{
.target = target,
.optimize = optimize,
}).module("chrono"));
then just const chrono = @import("chrono"); in your zig source code
sick, ty!