| ... | @@ -274,20 +274,27 @@ fn make(b: *std.Build, step_names: []const []const u8) !void { | ... | @@ -274,20 +274,27 @@ fn make(b: *std.Build, step_names: []const []const u8) !void { |
| 274 | } | 274 | } |
| 275 | } | 275 | } |
| 276 | | 276 | |
| | 277 | for (wanted_steps.items) |s| { |
| | 278 | checkForDependencyLoop(b, s) catch |err| switch (err) { |
| | 279 | error.DependencyLoopDetected => return error.UncleanExit, |
| | 280 | else => |e| return e, |
| | 281 | }; |
| | 282 | } |
| | 283 | |
| 277 | for (wanted_steps.items) |s| { | 284 | for (wanted_steps.items) |s| { |
| 278 | try makeOneStep(b, s); | 285 | try makeOneStep(b, s); |
| 279 | } | 286 | } |
| 280 | } | 287 | } |
| 281 | | 288 | |
| 282 | fn makeOneStep(b: *std.Build, s: *std.Build.Step) anyerror!void { | 289 | fn checkForDependencyLoop(b: *std.Build, s: *std.Build.Step) !void { |
| 283 | if (s.loop_flag) { | 290 | if (s.loop_tag == .started) { |
| 284 | std.debug.print("dependency loop detected:\n {s}\n", .{s.name}); | 291 | std.debug.print("dependency loop detected:\n {s}\n", .{s.name}); |
| 285 | return error.DependencyLoopDetected; | 292 | return error.DependencyLoopDetected; |
| 286 | } | 293 | } |
| 287 | s.loop_flag = true; | 294 | s.loop_tag = .started; |
| 288 | | 295 | |
| 289 | for (s.dependencies.items) |dep| { | 296 | for (s.dependencies.items) |dep| { |
| 290 | makeOneStep(b, dep) catch |err| { | 297 | checkForDependencyLoop(b, dep) catch |err| { |
| 291 | if (err == error.DependencyLoopDetected) { | 298 | if (err == error.DependencyLoopDetected) { |
| 292 | std.debug.print(" {s}\n", .{s.name}); | 299 | std.debug.print(" {s}\n", .{s.name}); |
| 293 | } | 300 | } |
| ... | @@ -295,7 +302,13 @@ fn makeOneStep(b: *std.Build, s: *std.Build.Step) anyerror!void { | ... | @@ -295,7 +302,13 @@ fn makeOneStep(b: *std.Build, s: *std.Build.Step) anyerror!void { |
| 295 | }; | 302 | }; |
| 296 | } | 303 | } |
| 297 | | 304 | |
| 298 | s.loop_flag = false; | 305 | s.loop_tag = .done; |
| | 306 | } |
| | 307 | |
| | 308 | fn makeOneStep(b: *std.Build, s: *std.Build.Step) anyerror!void { |
| | 309 | for (s.dependencies.items) |dep| { |
| | 310 | try makeOneStep(b, dep); |
| | 311 | } |
| 299 | | 312 | |
| 300 | try s.make(); | 313 | try s.make(); |
| 301 | } | 314 | } |