authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-02 16:21:52 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-02 16:21:52 -07:00
logdf8e9fbb79dfeb0634ade259486d01da9e6cef71
treec75294963aa6680a3eafc17a3926c2d1f5407e78
parent21683f9329aa22ed8a2d0e3cdff48a398521b65c

generate: fix build graph dependency ordering bug

the addition of dummy_library needed to be added in the build dep tree

2 files changed, 34 insertions(+), 30 deletions(-)

deps.zig+25-23
......@@ -31,7 +31,6 @@ pub const GitExactStep = struct {
3131
3232 var clonestep = std.Build.Step.Run.create(b, "clone");
3333 clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
34 result.step.dependOn(&clonestep.step);
3534
3635 var checkoutstep = std.Build.Step.Run.create(b, "checkout");
3736 checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
......@@ -47,30 +46,32 @@ pub const GitExactStep = struct {
4746 }
4847};
4948
50pub fn fetch(exe: *std.Build.Step.Compile) void {
49pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step {
5150 const b = exe.step.owner;
51 const step = b.step("fetch", "");
5252 inline for (comptime std.meta.declarations(package_data)) |decl| {
5353 const path = &@field(package_data, decl.name).entry;
5454 const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";
5555 if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });
5656 }
57 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "c778640d3dc153e900fbe37e2816b5176af3c802").step);
58 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "38a018ad3a19d5b4663a5364d2d31271f250846b").step);
59 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "4dc8850883b49e4a452871298788b06b1af9fe24").step);
60 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "863be236188e5f24d16554f9dcd7df96dd254a13").step);
61 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "c3e439f86b0484e4428f38c4d8b07b7b5ae1634b").step);
62 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step);
63 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step);
64 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "9e1d873db79e9ffa6ae6e06bd372428c9be85d97").step);
65 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e548b0bcc7b6f34f636c0b6b905928d31254c54d").step);
66 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step);
67 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step);
68 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step);
69 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "ba546bbf2e8438c9b2325f36f392c9d95b432e8e").step);
70 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step);
71 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "a7f03a1e652abe8c89b376d090cec50acb0d2a1a").step);
72 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "0ad514dcfb7525e32ae349b9acc0a53976f3a9fa").step);
73 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);
57 step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "c778640d3dc153e900fbe37e2816b5176af3c802").step);
58 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "38a018ad3a19d5b4663a5364d2d31271f250846b").step);
59 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "4dc8850883b49e4a452871298788b06b1af9fe24").step);
60 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "863be236188e5f24d16554f9dcd7df96dd254a13").step);
61 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "c3e439f86b0484e4428f38c4d8b07b7b5ae1634b").step);
62 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step);
63 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step);
64 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "9e1d873db79e9ffa6ae6e06bd372428c9be85d97").step);
65 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e548b0bcc7b6f34f636c0b6b905928d31254c54d").step);
66 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step);
67 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step);
68 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step);
69 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "ba546bbf2e8438c9b2325f36f392c9d95b432e8e").step);
70 step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step);
71 step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "a7f03a1e652abe8c89b376d090cec50acb0d2a1a").step);
72 step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "0ad514dcfb7525e32ae349b9acc0a53976f3a9fa").step);
73 step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);
74 return step;
7475}
7576
7677fn trimPrefix(comptime T: type, haystack: []const T, needle: []const T) []const T {
......@@ -87,10 +88,10 @@ fn flip(foo: anytype) !void {
8788
8889pub fn addAllTo(exe: *std.Build.Step.Compile) void {
8990 checkMinZig(builtin.zig_version, exe);
90 fetch(exe);
91 const fetch_step = fetch(exe);
9192 @setEvalBranchQuota(1_000_000);
9293 for (packages) |pkg| {
93 const module = pkg.module(exe);
94 const module = pkg.module(exe, fetch_step);
9495 exe.root_module.addImport(pkg.name, module);
9596 }
9697}
......@@ -108,7 +109,7 @@ pub const Package = struct {
108109 frameworks: []const string = &.{},
109110 module_memo: ?*std.Build.Module = null,
110111
111 pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
112 pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module {
112113 if (self.module_memo) |cached| {
113114 return cached;
114115 }
......@@ -120,11 +121,12 @@ pub const Package = struct {
120121 .target = exe.root_module.resolved_target orelse b.host,
121122 .optimize = exe.root_module.optimize.?,
122123 });
124 dummy_library.step.dependOn(fetch_step);
123125 if (self.entry) |capture| {
124126 result.root_source_file = .{ .path = capture };
125127 }
126128 for (self.deps) |item| {
127 const module_dep = item.module(exe);
129 const module_dep = item.module(exe, fetch_step);
128130 if (module_dep.root_source_file != null) {
129131 result.addImport(item.name, module_dep);
130132 }
src/cmd/generate.zig+9-7
......@@ -72,7 +72,6 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
7272 \\
7373 \\ var clonestep = std.Build.Step.Run.create(b, "clone");
7474 \\ clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
75 \\ result.step.dependOn(&clonestep.step);
7675 \\
7776 \\ var checkoutstep = std.Build.Step.Run.create(b, "checkout");
7877 \\ checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
......@@ -90,8 +89,9 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
9089 \\ }
9190 \\};
9291 \\
93 \\pub fn fetch(exe: *std.Build.Step.Compile) void {
92 \\pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step {
9493 \\ const b = exe.step.owner;
94 \\ const step = b.step("fetch", "");
9595 \\ inline for (comptime std.meta.declarations(package_data)) |decl| {
9696 \\ const path = &@field(package_data, decl.name).entry;
9797 \\ const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";
......@@ -104,12 +104,13 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
104104 .local => {},
105105 .system_lib => {},
106106 .framework => {},
107 .git => try w.print(" exe.step.dependOn(&GitExactStep.create(b, \"{s}\", \"{s}\").step);\n", .{ module.dep.?.path, try module.pin(alloc, cachepath) }),
107 .git => try w.print(" step.dependOn(&GitExactStep.create(b, \"{s}\", \"{s}\").step);\n", .{ module.dep.?.path, try module.pin(alloc, cachepath) }),
108108 .hg => @panic("TODO"),
109109 .http => @panic("TODO"),
110110 }
111111 }
112112 try w.writeAll(
113 \\ return step;
113114 \\}
114115 \\
115116 \\fn trimPrefix(comptime T: type, haystack: []const T, needle: []const T) []const T {
......@@ -126,10 +127,10 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
126127 \\
127128 \\pub fn addAllTo(exe: *std.Build.Step.Compile) void {
128129 \\ checkMinZig(builtin.zig_version, exe);
129 \\ fetch(exe);
130 \\ const fetch_step = fetch(exe);
130131 \\ @setEvalBranchQuota(1_000_000);
131132 \\ for (packages) |pkg| {
132 \\ const module = pkg.module(exe);
133 \\ const module = pkg.module(exe, fetch_step);
133134 \\ exe.root_module.addImport(pkg.name, module);
134135 \\ }
135136 \\}
......@@ -147,7 +148,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
147148 \\ frameworks: []const string = &.{},
148149 \\ module_memo: ?*std.Build.Module = null,
149150 \\
150 \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
151 \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module {
151152 \\ if (self.module_memo) |cached| {
152153 \\ return cached;
153154 \\ }
......@@ -159,11 +160,12 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
159160 \\ .target = exe.root_module.resolved_target orelse b.host,
160161 \\ .optimize = exe.root_module.optimize.?,
161162 \\ });
163 \\ dummy_library.step.dependOn(fetch_step);
162164 \\ if (self.entry) |capture| {
163165 \\ result.root_source_file = .{ .path = capture };
164166 \\ }
165167 \\ for (self.deps) |item| {
166 \\ const module_dep = item.module(exe);
168 \\ const module_dep = item.module(exe, fetch_step);
167169 \\ if (module_dep.root_source_file != null) {
168170 \\ result.addImport(item.name, module_dep);
169171 \\ }