1// zig fmt: off
2const std = @import("std");
3const builtin = @import("builtin");
4const string = []const u8;
5
6pub const GitExactStep = struct {
7 step: std.Build.Step,
8 builder: *std.Build,
9 url: string,
10 commit: string,
11
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 var urlpath = url;
27 urlpath = trimPrefix(u8, urlpath, "https://");
28 urlpath = trimPrefix(u8, urlpath, "git://");
29 const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });
30 flip(std.Io.Dir.cwd().access(std.Options.debug_io, repopath, .{})) catch return result;
31
32 var clonestep = std.Build.Step.Run.create(b, "clone");
33 clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
34
35 var checkoutstep = std.Build.Step.Run.create(b, "checkout");
36 checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
37 result.step.dependOn(&checkoutstep.step);
38 checkoutstep.step.dependOn(&clonestep.step);
39
40 return result;
41 }
42
43 fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void {
44 _ = step;
45 _ = options;
46 }
47};
48
49pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step {
50 const b = exe.step.owner;
51 const step = b.step("fetch", "");
52 inline for (comptime std.meta.declarations(package_data)) |decl| {
53 const path = &@field(package_data, decl.name).entry;
54 const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";
55 if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });
56 }
57 step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "9f15c276b4e9d05afd34a10d8662a7dfc34647ea").step);
58 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "d2465c64833590a04bd9b7f50c87363fd03e65bf").step);
59 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "bebb39ae30d9848a1c212cee582d0b1c102d8b87").step);
60 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "6de79b4ff8f7462e26f224f4bed3c81710c8893b").step);
61 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "feae209ba5cbc9b92a240f2e8e531c1b913bef3f").step);
62 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-git", "88b94a1960be841bb93a0bca65d556cb6385d1fd").step);
63 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "e745b018f87ddc4c8958370332e6cf61625403cc").step);
64 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "800cbe5b241fc52370cb8f892f0d9c6f97133725").step);
65 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-json", "60425cbb04ce4b00edfad895771e5bd4029cf1c5").step);
66 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "014971d4b1e327a5c61322c3a6b9369fd1863864").step);
67 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "bc1cd51625c13d6c7df819fd0d85968e617f5c57").step);
68 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "a9d067c3c4d6c226a1de5531b66785bc15d869ee").step);
69 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "1163f0e7be1400c7e2f80b5719114a7d1dc2cd36").step);
70 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nio", "61cf2b1af033a83ec2137e21824a8afa01318388").step);
71 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "b349aa32b55aae4cf2ae56740003f8aff0394920").step);
72 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-freebsd", "a80eaba4499e56256ed2d42959fed5174b1fbf60").step);
73 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "24cc89eb39fbb1f8b4caa53beeca1c785ce78546").step);
74 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-netbsd", "5ad432ca421c59099be3630b9d0dda49e8bef0a7").step);
75 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-openbsd", "1a77f0cfe55b5fdfa6ac2bedf587bb3b8015c357").step);
76 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "cacde79ed6c866a370dd58f97ed1baa31b0b2c35").step);
77 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "4ad0602d52a3f40ef74f59f648602c61409f7ba7").step);
78 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b").step);
79 step.dependOn(&GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498").step);
80 step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);
81 step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "207c34a16e4365edc20d92c7892f962b3bed46e8").step);
82 return step;
83}
84
85fn trimPrefix(comptime T: type, haystack: []const T, needle: []const T) []const T {
86 if (std.mem.startsWith(T, haystack, needle)) {
87 return haystack[needle.len .. haystack.len];
88 }
89 return haystack;
90}
91
92fn flip(foo: anytype) !void {
93 _ = foo catch return;
94 return error.ExpectedError;
95}
96
97pub fn addAllTo(exe: *std.Build.Step.Compile) void {
98 checkMinZig(builtin.zig_version, exe);
99 const fetch_step = fetch(exe);
100 @setEvalBranchQuota(1_000_000);
101 for (packages) |pkg| {
102 const module = pkg.module(exe, fetch_step);
103 exe.root_module.addImport(pkg.name, module);
104 }
105 // clear module memo cache so addAllTo can be called more than once in the same build.zig
106 inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl.name).module_memo = null;
107}
108
109var link_lib_c = false;
110pub const Package = struct {
111 name: string = "",
112 entry: ?string = null,
113 store: ?string = null,
114 deps: []const *Package = &.{},
115 c_include_dirs: []const string = &.{},
116 c_source_files: []const string = &.{},
117 c_source_flags: []const string = &.{},
118 system_libs: []const string = &.{},
119 frameworks: []const string = &.{},
120 module_memo: ?*std.Build.Module = null,
121
122 pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module {
123 if (self.module_memo) |cached| {
124 return cached;
125 }
126 const b = exe.step.owner;
127
128 const result = b.createModule(.{
129 .target = exe.root_module.resolved_target,
130 });
131 const target = result.resolved_target.?.result;
132 const dummy_library = b.addLibrary(.{
133 .linkage = .static,
134 .name = b.fmt("dummy-{s}", .{self.name}),
135 .root_module = b.createModule(.{
136 .target = exe.root_module.resolved_target orelse b.graph.host,
137 .optimize = exe.root_module.optimize.?,
138 }),
139 });
140 dummy_library.step.dependOn(fetch_step);
141 var links: u32 = 0;
142 if (self.entry) |capture| {
143 result.root_source_file = .{ .cwd_relative = capture };
144 }
145 for (self.deps) |item| {
146 const module_dep = item.module(exe, fetch_step);
147 if (module_dep.root_source_file != null) {
148 result.addImport(item.name, module_dep);
149 }
150 for (module_dep.include_dirs.items) |jtem| {
151 switch (jtem) {
152 .path => result.addIncludePath(jtem.path),
153 .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {},
154 .embed_path => {},
155 }
156 }
157 }
158 for (self.c_include_dirs) |item| {
159 result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
160 dummy_library.root_module.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
161 link_lib_c = true;
162 links += 1;
163 }
164 for (self.c_source_files) |item| {
165 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 });
166 links += 1;
167 }
168 for (self.system_libs) |item| {
169 if (std.zig.target.isLibCLibName(&target, item)) continue;
170 dummy_library.root_module.linkSystemLibrary(item, .{});
171 links += 1;
172 }
173 for (self.frameworks) |item| {
174 dummy_library.root_module.linkFramework(item, .{});
175 links += 1;
176 }
177 if (links > 0) {
178 dummy_library.root_module.linkSystemLibrary("c", .{});
179 exe.root_module.linkLibrary(dummy_library);
180 link_lib_c = true;
181 }
182 if (link_lib_c) {
183 result.link_libc = true;
184 }
185 self.module_memo = result;
186 return result;
187 }
188};
189
190fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {
191 const min = std.SemanticVersion.parse("0.16.0") catch return;
192 if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{f} does not meet the minimum build requirement of v{f}", .{current, min}));
193}
194
195pub const package_data = struct {
196 pub var _o6ogpor87xc2 = Package{
197 .store = "/git/github.com/marlersoft/zigwin32/9f15c276b4e9d05afd34a10d8662a7dfc34647ea",
198 .name = "win32",
199 .entry = "/git/github.com/marlersoft/zigwin32/9f15c276b4e9d05afd34a10d8662a7dfc34647ea/win32.zig",
200 };
201 pub var _u7sysdckdymi = Package{
202 .store = "/git/github.com/nektro/arqv-ini/d2465c64833590a04bd9b7f50c87363fd03e65bf",
203 .name = "ini",
204 .entry = "/git/github.com/nektro/arqv-ini/d2465c64833590a04bd9b7f50c87363fd03e65bf/src/ini.zig",
205 };
206 pub var _s84v9o48ucb0 = Package{
207 .store = "/git/github.com/nektro/zig-ansi/bebb39ae30d9848a1c212cee582d0b1c102d8b87",
208 .name = "ansi",
209 .entry = "/git/github.com/nektro/zig-ansi/bebb39ae30d9848a1c212cee582d0b1c102d8b87/src/lib.zig",
210 };
211 pub var _f7dubzb7cyqe = Package{
212 .store = "/git/github.com/nektro/zig-extras/feae209ba5cbc9b92a240f2e8e531c1b913bef3f",
213 .name = "extras",
214 .entry = "/git/github.com/nektro/zig-extras/feae209ba5cbc9b92a240f2e8e531c1b913bef3f/src/lib.zig",
215 };
216 pub var _c1xirp1ota5p = Package{
217 .store = "/git/github.com/nektro/zig-inquirer/e745b018f87ddc4c8958370332e6cf61625403cc",
218 .name = "inquirer",
219 .entry = "/git/github.com/nektro/zig-inquirer/e745b018f87ddc4c8958370332e6cf61625403cc/src/lib.zig",
220 .deps = &[_]*Package{ &_s84v9o48ucb0 },
221 };
222 pub var _96h80ezrvj7i = Package{
223 .store = "/git/github.com/nektro/zig-leven/014971d4b1e327a5c61322c3a6b9369fd1863864",
224 .name = "leven",
225 .entry = "/git/github.com/nektro/zig-leven/014971d4b1e327a5c61322c3a6b9369fd1863864/src/lib.zig",
226 };
227 pub var _0npcrzfdlrvk = Package{
228 .store = "/git/github.com/nektro/zig-licenses/bc1cd51625c13d6c7df819fd0d85968e617f5c57",
229 .name = "licenses",
230 .entry = "/git/github.com/nektro/zig-licenses/bc1cd51625c13d6c7df819fd0d85968e617f5c57/src/lib.zig",
231 };
232 pub var _pt88y5d80m25 = Package{
233 .store = "/git/github.com/nektro/zig-licenses-text/a9d067c3c4d6c226a1de5531b66785bc15d869ee",
234 .name = "licenses-text",
235 .entry = "/git/github.com/nektro/zig-licenses-text/a9d067c3c4d6c226a1de5531b66785bc15d869ee/src/lib.zig",
236 };
237 pub var _73bukkeci2u6 = Package{
238 .store = "/git/github.com/nektro/zig-sys-darwin/b349aa32b55aae4cf2ae56740003f8aff0394920",
239 .name = "sys-darwin",
240 .entry = "/git/github.com/nektro/zig-sys-darwin/b349aa32b55aae4cf2ae56740003f8aff0394920/sys_darwin.zig",
241 };
242 pub var _qfev2g50alvp = Package{
243 .store = "/git/github.com/nektro/zig-sys-freebsd/a80eaba4499e56256ed2d42959fed5174b1fbf60",
244 .name = "sys-freebsd",
245 .entry = "/git/github.com/nektro/zig-sys-freebsd/a80eaba4499e56256ed2d42959fed5174b1fbf60/freebsd.zig",
246 };
247 pub var _h7tv7ayhffak = Package{
248 .store = "/git/github.com/nektro/zig-sys-linux/24cc89eb39fbb1f8b4caa53beeca1c785ce78546",
249 .name = "sys-linux",
250 .entry = "/git/github.com/nektro/zig-sys-linux/24cc89eb39fbb1f8b4caa53beeca1c785ce78546/mod.zig",
251 };
252 pub var _uvkgl6xf1azv = Package{
253 .store = "/git/github.com/nektro/zig-sys-netbsd/5ad432ca421c59099be3630b9d0dda49e8bef0a7",
254 .name = "sys-netbsd",
255 .entry = "/git/github.com/nektro/zig-sys-netbsd/5ad432ca421c59099be3630b9d0dda49e8bef0a7/netbsd.zig",
256 };
257 pub var _4rmxgmcykiba = Package{
258 .store = "/git/github.com/nektro/zig-sys-openbsd/1a77f0cfe55b5fdfa6ac2bedf587bb3b8015c357",
259 .name = "sys-openbsd",
260 .entry = "/git/github.com/nektro/zig-sys-openbsd/1a77f0cfe55b5fdfa6ac2bedf587bb3b8015c357/openbsd.zig",
261 };
262 pub var _kscsl0145t7x = Package{
263 .store = "/git/github.com/nektro/zig-nio/61cf2b1af033a83ec2137e21824a8afa01318388",
264 .name = "nio",
265 .entry = "/git/github.com/nektro/zig-nio/61cf2b1af033a83ec2137e21824a8afa01318388/nio.zig",
266 .deps = &[_]*Package{ &_h7tv7ayhffak, &_f7dubzb7cyqe, &_73bukkeci2u6, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
267 };
268 pub var _7l3oxw6nqqws = Package{
269 .store = "/git/github.com/nektro/zig-intrusive-parser/800cbe5b241fc52370cb8f892f0d9c6f97133725",
270 .name = "intrusive-parser",
271 .entry = "/git/github.com/nektro/zig-intrusive-parser/800cbe5b241fc52370cb8f892f0d9c6f97133725/intrusive_parser.zig",
272 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_kscsl0145t7x },
273 };
274 pub var _iecwp4b3bsfm = Package{
275 .store = "/git/github.com/nektro/zig-time/cacde79ed6c866a370dd58f97ed1baa31b0b2c35",
276 .name = "time",
277 .entry = "/git/github.com/nektro/zig-time/cacde79ed6c866a370dd58f97ed1baa31b0b2c35/time.zig",
278 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_h7tv7ayhffak, &_73bukkeci2u6, &_kscsl0145t7x, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
279 };
280 pub var _vph9l0hxpeze = Package{
281 .store = "/git/github.com/nektro/zig-nfs/1163f0e7be1400c7e2f80b5719114a7d1dc2cd36",
282 .name = "nfs",
283 .entry = "/git/github.com/nektro/zig-nfs/1163f0e7be1400c7e2f80b5719114a7d1dc2cd36/nfs.zig",
284 .deps = &[_]*Package{ &_h7tv7ayhffak, &_kscsl0145t7x, &_iecwp4b3bsfm, &_73bukkeci2u6, &_qfev2g50alvp, &_uvkgl6xf1azv, &_4rmxgmcykiba },
285 };
286 pub var _2ovav391ivak = Package{
287 .store = "/git/github.com/nektro/zig-detect-license/6de79b4ff8f7462e26f224f4bed3c81710c8893b",
288 .name = "detect-license",
289 .entry = "/git/github.com/nektro/zig-detect-license/6de79b4ff8f7462e26f224f4bed3c81710c8893b/src/lib.zig",
290 .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i, &_vph9l0hxpeze },
291 };
292 pub var _ede2wygpe1iy = Package{
293 .store = "/git/github.com/nektro/zig-tracer/4ad0602d52a3f40ef74f59f648602c61409f7ba7",
294 .name = "tracer",
295 .entry = "/git/github.com/nektro/zig-tracer/4ad0602d52a3f40ef74f59f648602c61409f7ba7/src/mod.zig",
296 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_h7tv7ayhffak, &_vph9l0hxpeze, &_kscsl0145t7x, &_iecwp4b3bsfm },
297 };
298 pub var _0k64oe2nuzvj = Package{
299 .store = "/git/github.com/nektro/zig-git/88b94a1960be841bb93a0bca65d556cb6385d1fd",
300 .name = "git",
301 .entry = "/git/github.com/nektro/zig-git/88b94a1960be841bb93a0bca65d556cb6385d1fd/git.zig",
302 .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy, &_vph9l0hxpeze, &_kscsl0145t7x, &_0e2d06bb494b },
303 };
304 pub var _ocmr9rtohgcc = Package{
305 .store = "/git/github.com/nektro/zig-json/60425cbb04ce4b00edfad895771e5bd4029cf1c5",
306 .name = "json",
307 .entry = "/git/github.com/nektro/zig-json/60425cbb04ce4b00edfad895771e5bd4029cf1c5/json.zig",
308 .deps = &[_]*Package{ &_f7dubzb7cyqe, &_ede2wygpe1iy, &_7l3oxw6nqqws, &_kscsl0145t7x },
309 };
310 pub var _g982zq6e8wsv = Package{
311 .store = "/git/github.com/nektro/zig-yaml/dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b",
312 .name = "yaml",
313 .entry = "/git/github.com/nektro/zig-yaml/dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b/yaml.zig",
314 .deps = &[_]*Package{ &_8mdbh0zuneb0 },
315 };
316 pub var _0e2d06bb494b = Package{
317 .store = "/git/github.com/madler/zlib/da607da739fa6047df13e66a2af6b8bec7c2a498",
318 .c_include_dirs = &.{ "" },
319 .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" },
320 .c_source_flags = &.{ "-DZ_HAVE_UNISTD_H=1" },
321 };
322 pub var _8mdbh0zuneb0 = Package{
323 .store = "/git/github.com/yaml/libyaml/2c891fc7a770e8ba2fec34fc6b545c672beb37e6",
324 .c_include_dirs = &.{ "include" },
325 .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" },
326 .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" },
327 };
328 pub var _2ta738wrqbaq = Package{
329 .store = "/git/github.com/ziglibs/known-folders/207c34a16e4365edc20d92c7892f962b3bed46e8",
330 .name = "known-folders",
331 .entry = "/git/github.com/ziglibs/known-folders/207c34a16e4365edc20d92c7892f962b3bed46e8/known-folders.zig",
332 };
333 pub var _89ujp8gq842x = Package{
334 .name = "zigmod",
335 .entry = "/../..//src/lib.zig",
336 .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj, &_ocmr9rtohgcc, &_kscsl0145t7x, &_vph9l0hxpeze },
337 };
338 pub var _root = Package{
339 };
340};
341
342pub const packages = [_]*Package{
343 &package_data._89ujp8gq842x,
344 &package_data._o6ogpor87xc2,
345 &package_data._f7dubzb7cyqe,
346 &package_data._s84v9o48ucb0,
347 &package_data._kscsl0145t7x,
348 &package_data._vph9l0hxpeze,
349};
350
351pub const pkgs = struct {
352 pub const zigmod = &package_data._89ujp8gq842x;
353 pub const win32 = &package_data._o6ogpor87xc2;
354 pub const extras = &package_data._f7dubzb7cyqe;
355 pub const ansi = &package_data._s84v9o48ucb0;
356 pub const nio = &package_data._kscsl0145t7x;
357 pub const nfs = &package_data._vph9l0hxpeze;
358};
359
360pub const imports = struct {
361};