authoravatarMeghan Denny<hello@nektro.net>2026-10-16 00:36:39-07:00
committeravatarMeghan Denny<hello@nektro.net>2026-10-16 00:37:26-07:00
logc6d2581c4663bc7d1ee2a172b526734a1cc56a5a
tree41569848a22da76707195575c7f0d4ce2e7cdc65
parent0319d62e9b650aaeae25d7e9d317a0b4fe83a9d7
signature Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

cmd/generate: remove Package store


2 files changed, 84 insertions(+), 155 deletions(-)

deps.zig+53-97
......@@ -4,78 +4,54 @@ const builtin = @import("builtin");
44const string = []const u8;
55
66pub const GitExactStep = struct {
7 step: std.Build.Step,
8 builder: *std.Build,
9 url: string,
10 commit: string,
7 step: *std.Build.Step,
8 path: std.Build.LazyPath,
119
12 pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep {
13 var result = b.allocator.create(GitExactStep) catch @panic("memory");
14 result.* = GitExactStep{
15 .step = std.Build.Step.init(.{
16 .id = .custom,
17 .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),
18 .owner = b,
19 .makeFn = make,
20 }),
21 .builder = b,
22 .url = url,
23 .commit = commit,
24 };
25
26
27
28 var urlpath = url;
29 urlpath = trimPrefix(u8, urlpath, "https://");
30 urlpath = trimPrefix(u8, urlpath, "git://");
31 const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });
32 flip(std.Io.Dir.cwd().access(std.Options.debug_io, repopath, .{})) catch return result;
33
34 var clonestep = std.Build.Step.Run.create(b, "clone");
35 clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
36
37 var checkoutstep = std.Build.Step.Run.create(b, "checkout");
38 checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
39 result.step.dependOn(&checkoutstep.step);
40 checkoutstep.step.dependOn(&clonestep.step);
41
42 return result;
43 }
44
45 fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
46 _ = step;
47 _ = options;
48 }
10 pub fn create(b: *std.Build, url: string, commit: string) GitExactStep {
11 const sc_clone = b.addSystemCommand(&.{ "git", "clone" });
12 sc_clone.addArg("--quiet");
13 sc_clone.addArg("--progress");
14 sc_clone.addArg("--depth");
15 sc_clone.addArg("1");
16 sc_clone.addArg("--revision");
17 sc_clone.addArg(commit);
18 sc_clone.addArg(url);
19 const path = sc_clone.addOutputDirectoryArg(std.fs.path.basenamePosix(url));
20 return .{
21 .step = &sc_clone.step,
22 .path = path,
23 };
24 }
4925};
5026
5127pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step {
5228 const b = exe.step.owner;
5329 const step = b.step("fetch", "");
54 step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "9f15c276b4e9d05afd34a10d8662a7dfc34647ea").step);
55 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "d2465c64833590a04bd9b7f50c87363fd03e65bf").step);
56 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "bebb39ae30d9848a1c212cee582d0b1c102d8b87").step);
57 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "6de79b4ff8f7462e26f224f4bed3c81710c8893b").step);
58 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "8f6c4761e5c22c6a5c83a032e764154b840275bc").step);
59 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-git", "88b94a1960be841bb93a0bca65d556cb6385d1fd").step);
60 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "e745b018f87ddc4c8958370332e6cf61625403cc").step);
61 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "800cbe5b241fc52370cb8f892f0d9c6f97133725").step);
62 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-json", "a731b57ee685ff1ddeea9456a924f45ce4da3031").step);
63 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "014971d4b1e327a5c61322c3a6b9369fd1863864").step);
64 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "bc1cd51625c13d6c7df819fd0d85968e617f5c57").step);
65 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "a9d067c3c4d6c226a1de5531b66785bc15d869ee").step);
66 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "1a27fe574706f0b91c9f66b22fe7d3fa8f5129d5").step);
67 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nio", "17c4f044b15917efc1d3f018765881d53fa27e48").step);
68 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "b349aa32b55aae4cf2ae56740003f8aff0394920").step);
69 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-freebsd", "f97e6c2de30af76818572490735c84ce1015958b").step);
70 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "6dabe7cce239d882c8fd132ab5cda1d1f9ff3634").step);
71 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-netbsd", "5ad432ca421c59099be3630b9d0dda49e8bef0a7").step);
72 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-openbsd", "164646a5e7c4129eb92ac524a60f1759605c99df").step);
73 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "1349fb2c8aaaa1503e8730facea6f87c5fe75dc0").step);
74 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "4ad0602d52a3f40ef74f59f648602c61409f7ba7").step);
75 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b").step);
76 step.dependOn(&GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498").step);
77 step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);
78 step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "207c34a16e4365edc20d92c7892f962b3bed46e8").step);
30 dependOnGit(GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "9f15c276b4e9d05afd34a10d8662a7dfc34647ea"), step, &@field(package_data, "_o6ogpor87xc2"));
31 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "d2465c64833590a04bd9b7f50c87363fd03e65bf"), step, &@field(package_data, "_u7sysdckdymi"));
32 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "bebb39ae30d9848a1c212cee582d0b1c102d8b87"), step, &@field(package_data, "_s84v9o48ucb0"));
33 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "6de79b4ff8f7462e26f224f4bed3c81710c8893b"), step, &@field(package_data, "_2ovav391ivak"));
34 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-extras", "8f6c4761e5c22c6a5c83a032e764154b840275bc"), step, &@field(package_data, "_f7dubzb7cyqe"));
35 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-git", "88b94a1960be841bb93a0bca65d556cb6385d1fd"), step, &@field(package_data, "_0k64oe2nuzvj"));
36 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "e745b018f87ddc4c8958370332e6cf61625403cc"), step, &@field(package_data, "_c1xirp1ota5p"));
37 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "800cbe5b241fc52370cb8f892f0d9c6f97133725"), step, &@field(package_data, "_7l3oxw6nqqws"));
38 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-json", "a731b57ee685ff1ddeea9456a924f45ce4da3031"), step, &@field(package_data, "_ocmr9rtohgcc"));
39 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-leven", "014971d4b1e327a5c61322c3a6b9369fd1863864"), step, &@field(package_data, "_96h80ezrvj7i"));
40 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "bc1cd51625c13d6c7df819fd0d85968e617f5c57"), step, &@field(package_data, "_0npcrzfdlrvk"));
41 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "a9d067c3c4d6c226a1de5531b66785bc15d869ee"), step, &@field(package_data, "_pt88y5d80m25"));
42 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "1a27fe574706f0b91c9f66b22fe7d3fa8f5129d5"), step, &@field(package_data, "_vph9l0hxpeze"));
43 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nio", "17c4f044b15917efc1d3f018765881d53fa27e48"), step, &@field(package_data, "_kscsl0145t7x"));
44 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "b349aa32b55aae4cf2ae56740003f8aff0394920"), step, &@field(package_data, "_73bukkeci2u6"));
45 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-freebsd", "f97e6c2de30af76818572490735c84ce1015958b"), step, &@field(package_data, "_qfev2g50alvp"));
46 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "6dabe7cce239d882c8fd132ab5cda1d1f9ff3634"), step, &@field(package_data, "_h7tv7ayhffak"));
47 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-netbsd", "5ad432ca421c59099be3630b9d0dda49e8bef0a7"), step, &@field(package_data, "_uvkgl6xf1azv"));
48 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-openbsd", "164646a5e7c4129eb92ac524a60f1759605c99df"), step, &@field(package_data, "_4rmxgmcykiba"));
49 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-time", "1349fb2c8aaaa1503e8730facea6f87c5fe75dc0"), step, &@field(package_data, "_iecwp4b3bsfm"));
50 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "4ad0602d52a3f40ef74f59f648602c61409f7ba7"), step, &@field(package_data, "_ede2wygpe1iy"));
51 dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b"), step, &@field(package_data, "_g982zq6e8wsv"));
52 dependOnGit(GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498"), step, &@field(package_data, "_0e2d06bb494b"));
53 dependOnGit(GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6"), step, &@field(package_data, "_8mdbh0zuneb0"));
54 dependOnGit(GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "207c34a16e4365edc20d92c7892f962b3bed46e8"), step, &@field(package_data, "_2ta738wrqbaq"));
7955 return step;
8056}
8157
......@@ -103,11 +79,16 @@ pub fn addAllTo(exe: *std.Build.Step.Compile) void {
10379 inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl.name).module_memo = null;
10480}
10581
82pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void {
83 s.dependOn(ge.step);
84 p.path = ge.path;
85}
86
10687var link_lib_c = false;
10788pub const Package = struct {
10889 name: string = "",
109 store: ?string = null,
11090 main: ?string = null,
91 path: ?std.Build.LazyPath = null,
11192 deps: []const *Package = &.{},
11293 c_include_dirs: []const string = &.{},
11394 c_source_files: []const string = &.{},
......@@ -137,8 +118,8 @@ pub const Package = struct {
137118 dummy_library.step.dependOn(fetch_step);
138119 var links: u32 = 0;
139120 if (self.main) |m| {
140 if (self.store) |s| {
141 result.root_source_file = (std.Build.LazyPath{ .cwd_relative = b.cache_root.path.? }).path(b, "zigmod/deps").path(b, s[1..]).path(b, m);
121 if (self.path) |p| {
122 result.root_source_file = p.path(b, m);
142123 } else {
143124 result.root_source_file = b.path(m);
144125 }
......@@ -157,13 +138,13 @@ pub const Package = struct {
157138 }
158139 }
159140 for (self.c_include_dirs) |item| {
160 result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
161 dummy_library.root_module.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
141 result.addIncludePath(self.path.?.path(b, item));
142 dummy_library.root_module.addIncludePath(self.path.?.path(b, item));
162143 link_lib_c = true;
163144 links += 1;
164145 }
165146 for (self.c_source_files) |item| {
166 dummy_library.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags });
147 dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags });
167148 links += 1;
168149 }
169150 for (self.system_libs) |item| {
......@@ -195,139 +176,114 @@ fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void
195176
196177pub const package_data = struct {
197178 pub var _o6ogpor87xc2 = Package{
198 .store = "/git/github.com/marlersoft/zigwin32/9f15c276b4e9d05afd34a10d8662a7dfc34647ea",
199179 .name = "win32",
200180 .main = "win32.zig",
201181 };
202182 pub var _u7sysdckdymi = Package{
203 .store = "/git/github.com/nektro/arqv-ini/d2465c64833590a04bd9b7f50c87363fd03e65bf",
204183 .name = "ini",
205184 .main = "src/ini.zig",
206185 };
207186 pub var _s84v9o48ucb0 = Package{
208 .store = "/git/github.com/nektro/zig-ansi/bebb39ae30d9848a1c212cee582d0b1c102d8b87",
209187 .name = "ansi",
210188 .main = "src/lib.zig",
211189 };
212190 pub var _f7dubzb7cyqe = Package{
213 .store = "/git/github.com/nektro/zig-extras/8f6c4761e5c22c6a5c83a032e764154b840275bc",
214191 .name = "extras",
215192 .main = "src/lib.zig",
216193 };
217194 pub var _c1xirp1ota5p = Package{
218 .store = "/git/github.com/nektro/zig-inquirer/e745b018f87ddc4c8958370332e6cf61625403cc",
219195 .name = "inquirer",
220196 .main = "src/lib.zig",
221197 .deps = &[_]*Package{ &_s84v9o48ucb0 },
222198 };
223199 pub var _96h80ezrvj7i = Package{
224 .store = "/git/github.com/nektro/zig-leven/014971d4b1e327a5c61322c3a6b9369fd1863864",
225200 .name = "leven",
226201 .main = "src/lib.zig",
227202 };
228203 pub var _0npcrzfdlrvk = Package{
229 .store = "/git/github.com/nektro/zig-licenses/bc1cd51625c13d6c7df819fd0d85968e617f5c57",
230204 .name = "licenses",
231205 .main = "src/lib.zig",
232206 };
233207 pub var _pt88y5d80m25 = Package{
234 .store = "/git/github.com/nektro/zig-licenses-text/a9d067c3c4d6c226a1de5531b66785bc15d869ee",
235208 .name = "licenses-text",
236209 .main = "src/lib.zig",
237210 };
238211 pub var _73bukkeci2u6 = Package{
239 .store = "/git/github.com/nektro/zig-sys-darwin/b349aa32b55aae4cf2ae56740003f8aff0394920",
240212 .name = "sys-darwin",
241213 .main = "sys_darwin.zig",
242214 };
243215 pub var _qfev2g50alvp = Package{
244 .store = "/git/github.com/nektro/zig-sys-freebsd/f97e6c2de30af76818572490735c84ce1015958b",
245216 .name = "sys-freebsd",
246217 .main = "freebsd.zig",
247218 };
248219 pub var _h7tv7ayhffak = Package{
249 .store = "/git/github.com/nektro/zig-sys-linux/6dabe7cce239d882c8fd132ab5cda1d1f9ff3634",
250220 .name = "sys-linux",
251221 .main = "mod.zig",
252222 };
253223 pub var _uvkgl6xf1azv = Package{
254 .store = "/git/github.com/nektro/zig-sys-netbsd/5ad432ca421c59099be3630b9d0dda49e8bef0a7",
255224 .name = "sys-netbsd",
256225 .main = "netbsd.zig",
257226 };
258227 pub var _4rmxgmcykiba = Package{
259 .store = "/git/github.com/nektro/zig-sys-openbsd/164646a5e7c4129eb92ac524a60f1759605c99df",
260228 .name = "sys-openbsd",
261229 .main = "openbsd.zig",
262230 };
263231 pub var _kscsl0145t7x = Package{
264 .store = "/git/github.com/nektro/zig-nio/17c4f044b15917efc1d3f018765881d53fa27e48",
265232 .name = "nio",
266233 .main = "nio.zig",
267234 .deps = &[_]*Package{ &_h7tv7ayhffak, &_f7dubzb7cyqe, &_73bukkeci2u6, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
268235 };
269236 pub var _7l3oxw6nqqws = Package{
270 .store = "/git/github.com/nektro/zig-intrusive-parser/800cbe5b241fc52370cb8f892f0d9c6f97133725",
271237 .name = "intrusive-parser",
272238 .main = "intrusive_parser.zig",
273239 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_kscsl0145t7x },
274240 };
275241 pub var _iecwp4b3bsfm = Package{
276 .store = "/git/github.com/nektro/zig-time/1349fb2c8aaaa1503e8730facea6f87c5fe75dc0",
277242 .name = "time",
278243 .main = "time.zig",
279244 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_h7tv7ayhffak, &_73bukkeci2u6, &_kscsl0145t7x, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
280245 };
281246 pub var _vph9l0hxpeze = Package{
282 .store = "/git/github.com/nektro/zig-nfs/1a27fe574706f0b91c9f66b22fe7d3fa8f5129d5",
283247 .name = "nfs",
284248 .main = "nfs.zig",
285249 .deps = &[_]*Package{ &_h7tv7ayhffak, &_kscsl0145t7x, &_iecwp4b3bsfm, &_73bukkeci2u6, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
286250 };
287251 pub var _2ovav391ivak = Package{
288 .store = "/git/github.com/nektro/zig-detect-license/6de79b4ff8f7462e26f224f4bed3c81710c8893b",
289252 .name = "detect-license",
290253 .main = "src/lib.zig",
291254 .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i, &_vph9l0hxpeze },
292255 };
293256 pub var _ede2wygpe1iy = Package{
294 .store = "/git/github.com/nektro/zig-tracer/4ad0602d52a3f40ef74f59f648602c61409f7ba7",
295257 .name = "tracer",
296258 .main = "src/mod.zig",
297259 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_h7tv7ayhffak, &_vph9l0hxpeze, &_kscsl0145t7x, &_iecwp4b3bsfm },
298260 };
299261 pub var _0k64oe2nuzvj = Package{
300 .store = "/git/github.com/nektro/zig-git/88b94a1960be841bb93a0bca65d556cb6385d1fd",
301262 .name = "git",
302263 .main = "git.zig",
303264 .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy, &_vph9l0hxpeze, &_kscsl0145t7x, &_0e2d06bb494b },
304265 };
305266 pub var _ocmr9rtohgcc = Package{
306 .store = "/git/github.com/nektro/zig-json/a731b57ee685ff1ddeea9456a924f45ce4da3031",
307267 .name = "json",
308268 .main = "json.zig",
309269 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_ede2wygpe1iy, &_7l3oxw6nqqws, &_kscsl0145t7x },
310270 };
311271 pub var _g982zq6e8wsv = Package{
312 .store = "/git/github.com/nektro/zig-yaml/dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b",
313272 .name = "yaml",
314273 .main = "yaml.zig",
315274 .deps = &[_]*Package{ &_8mdbh0zuneb0 },
316275 };
317276 pub var _0e2d06bb494b = Package{
318 .store = "/git/github.com/madler/zlib/da607da739fa6047df13e66a2af6b8bec7c2a498",
319277 .c_include_dirs = &.{ "" },
320278 .c_source_files = &.{ "inftrees.c", "inflate.c", "adler32.c", "zutil.c", "trees.c", "gzclose.c", "gzwrite.c", "gzread.c", "deflate.c", "compress.c", "crc32.c", "infback.c", "gzlib.c", "uncompr.c", "inffast.c" },
321279 .c_source_flags = &.{ "-DZ_HAVE_UNISTD_H=1" },
322280 };
323281 pub var _8mdbh0zuneb0 = Package{
324 .store = "/git/github.com/yaml/libyaml/2c891fc7a770e8ba2fec34fc6b545c672beb37e6",
325282 .c_include_dirs = &.{ "include" },
326283 .c_source_files = &.{ "src/api.c", "src/dumper.c", "src/emitter.c", "src/loader.c", "src/parser.c", "src/reader.c", "src/scanner.c", "src/writer.c" },
327284 .c_source_flags = &.{ "-DYAML_VERSION_MAJOR=0", "-DYAML_VERSION_MINOR=2", "-DYAML_VERSION_PATCH=5", "-DYAML_VERSION_STRING=\"0.2.5\"", "-DYAML_DECLARE_STATIC=1" },
328285 };
329286 pub var _2ta738wrqbaq = Package{
330 .store = "/git/github.com/ziglibs/known-folders/207c34a16e4365edc20d92c7892f962b3bed46e8",
331287 .name = "known-folders",
332288 .main = "known-folders.zig",
333289 };
src/cmd/generate.zig+31-58
......@@ -47,48 +47,24 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
4747 try w.writeAll("\n");
4848 try w.writeAll(
4949 \\pub const GitExactStep = struct {
50 \\ step: std.Build.Step,
51 \\ builder: *std.Build,
52 \\ url: string,
53 \\ commit: string,
50 \\ step: *std.Build.Step,
51 \\ path: std.Build.LazyPath,
5452 \\
55 \\ pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep {
56 \\ var result = b.allocator.create(GitExactStep) catch @panic("memory");
57 \\ result.* = GitExactStep{
58 \\ .step = std.Build.Step.init(.{
59 \\ .id = .custom,
60 \\ .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),
61 \\ .owner = b,
62 \\ .makeFn = make,
63 \\ }),
64 \\ .builder = b,
65 \\ .url = url,
66 \\ .commit = commit,
67 \\ };
68 \\
69 \\ var urlpath = url;
70 \\ urlpath = trimPrefix(u8, urlpath, "https://");
71 \\ urlpath = trimPrefix(u8, urlpath, "git://");
72 \\ const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });
73 \\ flip(std.Io.Dir.cwd().access(std.Options.debug_io, repopath, .{})) catch return result;
74 \\
75 \\ var clonestep = std.Build.Step.Run.create(b, "clone");
76 \\ clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
77 \\
78 \\ var checkoutstep = std.Build.Step.Run.create(b, "checkout");
79 \\ checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
80 \\ result.step.dependOn(&checkoutstep.step);
81 \\ checkoutstep.step.dependOn(&clonestep.step);
82 // TODO rm the .git folder
83 // TODO mark folder as read-only
84 \\
85 \\ return result;
86 \\ }
87 \\
88 \\ fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
89 \\ _ = step;
90 \\ _ = options;
91 \\ }
53 \\ pub fn create(b: *std.Build, url: string, commit: string) GitExactStep {
54 \\ const sc_clone = b.addSystemCommand(&.{ "git", "clone" });
55 \\ sc_clone.addArg("--quiet");
56 \\ sc_clone.addArg("--progress");
57 \\ sc_clone.addArg("--depth");
58 \\ sc_clone.addArg("1");
59 \\ sc_clone.addArg("--revision");
60 \\ sc_clone.addArg(commit);
61 \\ sc_clone.addArg(url);
62 \\ const path = sc_clone.addOutputDirectoryArg(std.fs.path.basenamePosix(url));
63 \\ return .{
64 \\ .step = &sc_clone.step,
65 \\ .path = path,
66 \\ };
67 \\ }
9268 \\};
9369 \\
9470 \\pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step {
......@@ -101,7 +77,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
10177 .local => {},
10278 .system_lib => {},
10379 .framework => {},
104 .git => try w.print(" step.dependOn(&GitExactStep.create(b, \"{s}\", \"{s}\").step);\n", .{ module.dep.?.path, try module.pin(alloc, cachepath, options) }),
80 .git => try w.print(" dependOnGit(GitExactStep.create(b, \"{s}\", \"{s}\"), step, &@field(package_data, \"_{s}\"));\n", .{ module.dep.?.path, try module.pin(alloc, cachepath, options), module.short_id() }),
10581 .hg => @panic("TODO"),
10682 .http => @panic("TODO"),
10783 }
......@@ -134,11 +110,16 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
134110 \\ inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl.name).module_memo = null;
135111 \\}
136112 \\
113 \\pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void {
114 \\ s.dependOn(ge.step);
115 \\ p.path = ge.path;
116 \\}
117 \\
137118 \\var link_lib_c = false;
138119 \\pub const Package = struct {
139120 \\ name: string = "",
140 \\ store: ?string = null,
141121 \\ main: ?string = null,
122 \\ path: ?std.Build.LazyPath = null,
142123 \\ deps: []const *Package = &.{},
143124 \\ c_include_dirs: []const string = &.{},
144125 \\ c_source_files: []const string = &.{},
......@@ -168,8 +149,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
168149 \\ dummy_library.step.dependOn(fetch_step);
169150 \\ var links: u32 = 0;
170151 \\ if (self.main) |m| {
171 \\ if (self.store) |s| {
172 \\ result.root_source_file = (std.Build.LazyPath{ .cwd_relative = b.cache_root.path.? }).path(b, "zigmod/deps").path(b, s[1..]).path(b, m);
152 \\ if (self.path) |p| {
153 \\ result.root_source_file = p.path(b, m);
173154 \\ } else {
174155 \\ result.root_source_file = b.path(m);
175156 \\ }
......@@ -188,13 +169,13 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
188169 \\ }
189170 \\ }
190171 \\ for (self.c_include_dirs) |item| {
191 \\ result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
192 \\ dummy_library.root_module.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
172 \\ result.addIncludePath(self.path.?.path(b, item));
173 \\ dummy_library.root_module.addIncludePath(self.path.?.path(b, item));
193174 \\ link_lib_c = true;
194175 \\ links += 1;
195176 \\ }
196177 \\ for (self.c_source_files) |item| {
197 \\ dummy_library.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags });
178 \\ dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags });
198179 \\ links += 1;
199180 \\ }
200181 \\ for (self.system_libs) |item| {
......@@ -240,7 +221,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf
240221 }
241222 try duped.append(mod);
242223 }
243 try print_pkg_data_to(w, alloc, cachepath, &duped, &done, options);
224 try print_pkg_data_to(w, &duped, &done);
244225 try w.writeAll("};\n\n");
245226
246227 try w.writeAll("pub const packages = ");
......@@ -281,7 +262,7 @@ fn print_deps(w: nfs.File, m: zigmod.Module) !void {
281262 try w.writeAll("}");
282263}
283264
284fn print_pkg_data_to(w: nfs.File, alloc: std.mem.Allocator, cachepath: [:0]const u8, notdone: *std.array_list.Managed(zigmod.Module), done: *std.array_list.Managed(zigmod.Module), options: *common.CollectOptions) !void {
265fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module), done: *std.array_list.Managed(zigmod.Module)) !void {
285266 var len: usize = notdone.items.len;
286267 while (notdone.items.len > 0) {
287268 for (notdone.items, 0..) |mod, i| {
......@@ -292,14 +273,6 @@ fn print_pkg_data_to(w: nfs.File, alloc: std.mem.Allocator, cachepath: [:0]const
292273 , .{
293274 mod.short_id(),
294275 });
295 const fixed_path = if (std.mem.startsWith(u8, mod.clean_path, "v/")) mod.clean_path[2..std.mem.lastIndexOfScalar(u8, mod.clean_path, '/').?] else mod.clean_path;
296 switch (mod.type) {
297 .system_lib, .framework => {},
298 .local => {},
299 .git => try w.print(" .store = \"/{}/{s}\",\n", .{ u.altStringEscape(fixed_path), try mod.pin(alloc, cachepath, options) }),
300 .hg => @panic("TODO"),
301 .http => @panic("TODO"),
302 }
303276 if (mod.main.len > 0 and !std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) {
304277 try w.print(" .name = \"{s}\",\n", .{mod.name});
305278 try w.print(" .main = \"{s}\",\n", .{mod.main});