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...@@ -6,6 +6,10 @@ This file is generated by [`zigmod fetch`](commands/fetch.md) or [`zigmod ci`](c
6The relative path root to which all dependency sources are saved. Currently always `.zigmod/deps`.6The relative path root to which all dependency sources are saved. Currently always `.zigmod/deps`.
7> Note: only available when made with `zigmod fetch`.7> 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
9### `fetch`13### `fetch`
10- Type: `pub fn (exe: *std.build.LibExeObjStep) void`14- Type: `pub fn (exe: *std.build.LibExeObjStep) void`
11A helper function to automatically pull in dependencies, purely from the `zig build` system without the need to have `zigmod` installed.15A 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...@@ -54,6 +54,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
54 try w.writeAll("const string = []const u8;\n");54 try w.writeAll("const string = []const u8;\n");
55 try w.writeAll("\n");55 try w.writeAll("\n");
56 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});56 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
57 try w.writeAll("pub var skip_libc = false;\n");
57 try w.writeAll("\n");58 try w.writeAll("\n");
58 try w.writeAll(59 try w.writeAll(
59 \\pub fn addAllTo(exe: *std.Build.Step.Compile) void {60 \\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...@@ -92,6 +93,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
92 \\ const result = b.createModule(.{93 \\ const result = b.createModule(.{
93 \\ .target = exe.root_module.resolved_target,94 \\ .target = exe.root_module.resolved_target,
94 \\ });95 \\ });
96 \\ const target = result.resolved_target.?.result;
95 \\ if (self.import) |capture| {97 \\ if (self.import) |capture| {
96 \\ result.root_source_file = capture[1];98 \\ result.root_source_file = capture[1];
97 \\ }99 \\ }
...@@ -117,6 +119,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -117,6 +119,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
117 \\ link_lib_c = true;119 \\ link_lib_c = true;
118 \\ }120 \\ }
119 \\ for (self.system_libs) |item| {121 \\ for (self.system_libs) |item| {
122 \\ if (skip_libc and std.zig.target.isLibCLibName(target, item)) continue;
120 \\ result.linkSystemLibrary(item, .{});123 \\ result.linkSystemLibrary(item, .{});
121 \\ exe.linkSystemLibrary(item);124 \\ exe.linkSystemLibrary(item);
122 \\ link_lib_c = true;125 \\ link_lib_c = true;
...@@ -126,7 +129,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -126,7 +129,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
126 \\ exe.linkFramework(item);129 \\ exe.linkFramework(item);
127 \\ link_lib_c = true;130 \\ link_lib_c = true;
128 \\ }131 \\ }
129 \\ if (link_lib_c) {132 \\ if (link_lib_c and !skip_libc) {
130 \\ result.link_libc = true;133 \\ result.link_libc = true;
131 \\ exe.linkLibC();134 \\ exe.linkLibC();
132 \\ }135 \\ }