authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-04 23:40:51 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-04 23:40:51 -07:00
log4639401dddee0611f4bcd9e944e2f50fffeea10d
treeebc8d72d9675d962d6fe4cc6e91a7953e3c069a2
parent8dba61a43dd20c3eaf98e644dd703356c3fb2b97
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

cmd/fetch: add 'skip_libc' decl to deps.zig


2 files changed, 8 insertions(+), 1 deletions(-)

docs/deps.zig.md+4
......@@ -6,6 +6,10 @@ This file is generated by [`zigmod fetch`](commands/fetch.md) or [`zigmod ci`](c
66The relative path root to which all dependency sources are saved. Currently always `.zigmod/deps`.
77> Note: only available when made with `zigmod fetch`.
88
9### `skip_libc`
10- Type: `bool`
11Bool if you want `deps.zig` to skip calling `linkLibC()` for you. Defaults to `false`.
12
913### `fetch`
1014- Type: `pub fn (exe: *std.build.LibExeObjStep) void`
1115A helper function to automatically pull in dependencies, purely from the `zig build` system without the need to have `zigmod` installed.
src/cmd/fetch.zig+4-1
......@@ -54,6 +54,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
5454 try w.writeAll("const string = []const u8;\n");
5555 try w.writeAll("\n");
5656 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
57 try w.writeAll("pub var skip_libc = false;\n");
5758 try w.writeAll("\n");
5859 try w.writeAll(
5960 \\pub fn addAllTo(exe: *std.Build.Step.Compile) void {
......@@ -92,6 +93,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
9293 \\ const result = b.createModule(.{
9394 \\ .target = exe.root_module.resolved_target,
9495 \\ });
96 \\ const target = result.resolved_target.?.result;
9597 \\ if (self.import) |capture| {
9698 \\ result.root_source_file = capture[1];
9799 \\ }
......@@ -117,6 +119,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
117119 \\ link_lib_c = true;
118120 \\ }
119121 \\ for (self.system_libs) |item| {
122 \\ if (skip_libc and std.zig.target.isLibCLibName(target, item)) continue;
120123 \\ result.linkSystemLibrary(item, .{});
121124 \\ exe.linkSystemLibrary(item);
122125 \\ link_lib_c = true;
......@@ -126,7 +129,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
126129 \\ exe.linkFramework(item);
127130 \\ link_lib_c = true;
128131 \\ }
129 \\ if (link_lib_c) {
132 \\ if (link_lib_c and !skip_libc) {
130133 \\ result.link_libc = true;
131134 \\ exe.linkLibC();
132135 \\ }