| ... | @@ -63,9 +63,9 @@ protocol_server_mutex: Io.Mutex, | ... | @@ -63,9 +63,9 @@ protocol_server_mutex: Io.Mutex, |
| 63 | web_server: ?*AvoidableWebServer, | 63 | web_server: ?*AvoidableWebServer, |
| 64 | /// Allocated into `gpa`. | 64 | /// Allocated into `gpa`. |
| 65 | memory_blocked_steps: std.ArrayList(Configuration.Step.Index), | 65 | memory_blocked_steps: std.ArrayList(Configuration.Step.Index), |
| 66 | /// Allocated into `gpa`. | 66 | /// Allocated into `gpa` during `prepare`. |
| 67 | initial_steps: std.array_hash_map.Auto(Configuration.Step.Index, void), | 67 | initial_steps: std.array_hash_map.Auto(Configuration.Step.Index, void), |
| 68 | /// Allocated into `gpa`. | 68 | /// Allocated into `gpa` during `prepare`. |
| 69 | step_stack: std.array_hash_map.Auto(Configuration.Step.Index, void), | 69 | step_stack: std.array_hash_map.Auto(Configuration.Step.Index, void), |
| 70 | pkg_config: PkgConfig, | 70 | pkg_config: PkgConfig, |
| 71 | | 71 | |
| ... | @@ -762,10 +762,8 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -762,10 +762,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 762 | .include = install_include_path, | 762 | .include = install_include_path, |
| 763 | }, | 763 | }, |
| 764 | | 764 | |
| 765 | // Extra step at the end which is the autogenerated placeholder | 765 | .steps = &.{}, |
| 766 | // step which indicates that we need to reconfigure. | 766 | .generated_files = &.{}, |
| 767 | .steps = try arena.alloc(Step, scanned_config.configuration.steps.len + 1), | | |
| 768 | .generated_files = try arena.alloc(Path, scanned_config.configuration.generated_files_len), | | |
| 769 | .run_args = run_args, | 767 | .run_args = run_args, |
| 770 | | 768 | |
| 771 | .available_rss = max_rss, | 769 | .available_rss = max_rss, |
| ... | @@ -792,11 +790,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -792,11 +790,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 792 | else | 790 | else |
| 793 | .failures, | 791 | .failures, |
| 794 | }; | 792 | }; |
| 795 | defer { | 793 | defer maker.deinit(); |
| 796 | maker.memory_blocked_steps.deinit(gpa); | | |
| 797 | maker.initial_steps.deinit(gpa); | | |
| 798 | maker.step_stack.deinit(gpa); | | |
| 799 | } | | |
| 800 | | 794 | |
| 801 | if (maker.available_rss == 0) { | 795 | if (maker.available_rss == 0) { |
| 802 | maker.available_rss = process.totalSystemMemory() catch std.math.maxInt(u64); | 796 | maker.available_rss = process.totalSystemMemory() catch std.math.maxInt(u64); |
| ... | @@ -863,6 +857,9 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -863,6 +857,9 @@ pub fn main(init: process.Init.Minimal) !void { |
| 863 | &watch.?, | 857 | &watch.?, |
| 864 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, | 858 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, |
| 865 | }); | 859 | }); |
| | 860 | } else if (watch) |*w| { |
| | 861 | w.deinit(); |
| | 862 | watch = null; |
| 866 | } | 863 | } |
| 867 | | 864 | |
| 868 | continue :loop try select.await(); | 865 | continue :loop try select.await(); |
| ... | @@ -915,7 +912,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -915,7 +912,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 915 | if (!Watch.have_impl) fatal("--watch not yet implemented for {t}", .{native_os}); | 912 | if (!Watch.have_impl) fatal("--watch not yet implemented for {t}", .{native_os}); |
| 916 | break :w try .init(&maker); | 913 | break :w try .init(&maker); |
| 917 | }; | 914 | }; |
| 918 | defer w.deinit(); | 915 | defer if (watch_flag) w.deinit(); |
| 919 | | 916 | |
| 920 | if (web_server) |ws| try ws.updateConfiguration(&maker); | 917 | if (web_server) |ws| try ws.updateConfiguration(&maker); |
| 921 | | 918 | |
| ... | @@ -2229,6 +2226,11 @@ fn prepare( | ... | @@ -2229,6 +2226,11 @@ fn prepare( |
| 2229 | const step_stack = &maker.step_stack; | 2226 | const step_stack = &maker.step_stack; |
| 2230 | const c = &maker.scanned_config.configuration; | 2227 | const c = &maker.scanned_config.configuration; |
| 2231 | | 2228 | |
| | 2229 | // Extra step at the end which is the autogenerated placeholder |
| | 2230 | // step which indicates that we need to reconfigure. |
| | 2231 | maker.steps = try arena.alloc(Step, c.steps.len + 1); |
| | 2232 | maker.generated_files = try arena.alloc(Path, c.generated_files_len); |
| | 2233 | |
| 2232 | // The last element is a reserved special pseudostep which contains the | 2234 | // The last element is a reserved special pseudostep which contains the |
| 2233 | // watch inputs for the configurer executable. | 2235 | // watch inputs for the configurer executable. |
| 2234 | for (maker.steps[0 .. maker.steps.len - 1], 0..) |*step, step_index_usize| { | 2236 | for (maker.steps[0 .. maker.steps.len - 1], 0..) |*step, step_index_usize| { |
| ... | @@ -2549,7 +2551,7 @@ fn makeSteps( | ... | @@ -2549,7 +2551,7 @@ fn makeSteps( |
| 2549 | }; | 2551 | }; |
| 2550 | if (code == 0) { | 2552 | if (code == 0) { |
| 2551 | removePoisonedConfiguration(io, maker.scanned_config); | 2553 | removePoisonedConfiguration(io, maker.scanned_config); |
| 2552 | if (debugMakerLeaks()) return deinit(maker); | 2554 | if (debugMakerLeaks()) return; |
| 2553 | } | 2555 | } |
| 2554 | cleanup_task.await(io); // There is a defer above but an exit below. | 2556 | cleanup_task.await(io); // There is a defer above but an exit below. |
| 2555 | _ = io.lockStderr(&.{}, graph.stderr_mode) catch {}; | 2557 | _ = io.lockStderr(&.{}, graph.stderr_mode) catch {}; |
| ... | @@ -2558,12 +2560,10 @@ fn makeSteps( | ... | @@ -2558,12 +2560,10 @@ fn makeSteps( |
| 2558 | | 2560 | |
| 2559 | fn deinit(maker: *Maker) void { | 2561 | fn deinit(maker: *Maker) void { |
| 2560 | const gpa = maker.gpa; | 2562 | const gpa = maker.gpa; |
| 2561 | for (maker.steps) |*step| { | 2563 | for (maker.steps) |*step| step.deinit(gpa); |
| 2562 | step.clearResultStderr(gpa); | 2564 | maker.memory_blocked_steps.deinit(gpa); |
| 2563 | step.clearFailedCommand(gpa); | 2565 | maker.initial_steps.deinit(gpa); |
| 2564 | step.clearErrorBundle(gpa); | 2566 | maker.step_stack.deinit(gpa); |
| 2565 | step.inputs.deinit(gpa); | | |
| 2566 | } | | |
| 2567 | } | 2567 | } |
| 2568 | | 2568 | |
| 2569 | fn stepReady( | 2569 | fn stepReady( |