windows support
Hey there,
I was looking at https://github.com/acheronfail/gash and found vain. gash doesn't work on windows currently. I found you recently updated deps and things looked more recent than gash. I was able to zvm i 0.13.0 and the build.
I tried installing choco install libgit2 and then I tried vcpkg install libgit2 & vcpkg integrate install
vcpkg builds the library fine. Just wondering if I should be setting env vars or change the build file or what you suggest.
zig build
install
└─ install git-vain
└─ zig build-exe git-vain Debug native failure
error: error: unable to find dynamic system library 'libgit2' using strategy 'paths_first'. searched paths: none
thanks for the code and video. the 2000clicks link no longer works, I thought the idea was cool and I created pens off your code. https://codepen.io/Dave-Horner/pen/mybBppJ
Yeah I recently rewrote it from C to Zig to have a project to learn zig with. I don't have access to a windows computer to help with this, but yeah there are probably some env vars to set to get the zig complier to find where libgit2 is installed. It might also take some changes to the build.zig file. I'm still pretty new to zig so dont really know myself.
If you just want to get something working, in the archive directory there is the C version still, and it doesn't link against any external libraries. Instead it just runs git commands under the hood. It does expect a /tmp dir though which might not work on windows either, though maybe in wsl2?
Sorry I'm not more help here, but if you figure things out more please let me know.
That visualization on codepen is cool!
I will play a bit more. Same boat with learning zig. It seems the build.zig changes a lot between zig versions and I've had trouble using other's zig code in the past from that complexity.
thanks for the heads up on the C implementation. I'm not sure which way to go on that; gash could also be fixed up to work on windows too. As you mention /tmp pathing would need to be fixed at a minimum. I would prefer a rust implementation TBH. Using this to learn zig is also fun.
I think that code for searching in a spiral is awesome.
Thanks!
exe.linkSystemLibrary2("git2",.{ .preferred_link_mode = .static });
exe.linkLibC();
zig build --search-prefix c:\working\vcpkg\installed\x64-windows
now I'm looking at:
var args = std.process.args(); // wont work on windows or wasi
@compileError("In Windows, use initWithAllocator instead.");
hmm. close, seems you knew about this issue. :)
17 ⋮ 17 │pub fn init(git: *Git) !Self {
18 ⋮ │ var args = std.process.args(); // wont work on windows or wasi
19 ⋮ │ const progname = args.next() orelse "git-vain";
⋮ 18 │ const progname = "git-vain";
⋮ 19 │ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
⋮ 20 │ const allocator = gpa.allocator();
⋮ 21 │ defer _ = gpa.deinit();
20 ⋮ 22 │
21 ⋮ │ if (args.next()) |arg| {
⋮ 23 │ const args = try std.process.argsAlloc(allocator);
⋮ 24 │ defer std.process.argsFree(allocator, args);
⋮ 25 │
⋮ 26 │ for(args) |arg| {
⋮ 27 │ std.debug.print(" {s}\n", .{arg});
22 ⋮ 28 │ const isTest = (progname.len >= 4 and std.mem.eql(u8, progname[progname.len - 4 ..], "test"));
23 ⋮ 29 │ if (!isTest) return _init(arg);
24 ⋮ 30 │ }
looks like I'm building; now I have to figure out to use it! :) any notes appreciated.
copy C:\working\vcpkg\installed\x64-windows\bin\{git2.dll,pcre.dll} zig-out\bin
gets me a running exe.
git-vain\zig-out\bin>git-vain.exe
error: NotFound
C:\working\zig\git-vain\src\zlg\internal\internal.zig:99:5: 0x861186 in unwrapError (git-vain.exe.obj)
return err;
^
C:\working\zig\git-vain\src\zlg\handle.zig:118:9: 0x861574 in repositoryOpen (git-vain.exe.obj)
try internal.wrapCall("git_repository_open", .{
^
C:\working\zig\git-vain\src\lib\git.zig:10:18: 0x8616c1 in init (git-vain.exe.obj)
const repo = try hand.repositoryOpen(".");
^
C:\working\zig\git-vain\src\main.zig:14:15: 0x8679b7 in main (git-vain.exe.obj)
var git = try Git.init();
trying it from the project toplevel.
zig-out\bin\git-vain.exe
zig-out\bin\git-vain.exe
error: NotHexChr
C:\working\zig\git-vain\src\lib\target.zig:67:12: 0x86f018 in hexChrToInt (git-vain.exe.obj)
} else return TargetError.NotHexChr;
^
C:\working\zig\git-vain\src\lib\target.zig:47:19: 0x863a05 in _init (git-vain.exe.obj)
var val = try hexChrToInt(ch[0]);
^
C:\working\zig\git-vain\src\lib\target.zig:29:22: 0x863262 in init (git-vain.exe.obj)
if (!isTest) return _init(arg);
^
C:\working\zig\git-vain\src\main.zig:15:20: 0x867a26 in main (git-vain.exe.obj)
const target = try Target.init(&git); ^