#How to use zig-fetch with git repos

1 messages · Page 1 of 1 (latest)

hollow wagon
umbral dawn
#

you need to use git+https://host/path for a git repository

hollow wagon
#

ty!

#

does this also add it to my project, or do I have to mess around with build.zig as well?

umbral dawn
#

and yes, you need to add the dependency as an import if you want to use it

hollow wagon
#

cool, ty again!

hollow wagon
#

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?

pale oasis
#

nowhere, you didn't install it anywhere

hollow wagon
#

even through the zig fetch command? If not how would I install it?

pale oasis
#

zig fetch gives you a hash that you use to reference it

hollow wagon
#

and that is the path?

pale oasis
#

can you please say what you are actually trying to do

hollow wagon
#

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

GitHub

Contribute to leroycep/chrono-zig development by creating an account on GitHub.

pale oasis
#

what does your build.zig.zon look like

hollow wagon
#
// ^ ommitted for brevity
// (just project name + version)
.dependencies = .{
        .chrono = .{
            .url = "git+https://github.com/leroycep/chrono-zig.git#bedd9339af9b05c240956b137cb1a5b67a9b74b7",
            .hash = "12200e5959fd68f7b2101eae5b6f23a213712810814cef42f44e112cc7b4f14f0248",
        },
    },
    .paths = .{
        "",
        
    },
}
pale oasis
#
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

hollow wagon
#

sick, ty!