| ... | @@ -225,7 +225,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -225,7 +225,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 225 | var skip_oom_steps = false; | 225 | var skip_oom_steps = false; |
| 226 | var test_timeout_ns: ?u64 = null; | 226 | var test_timeout_ns: ?u64 = null; |
| 227 | var color: Color = .settingFromEnvironment(&graph.environ_map); | 227 | var color: Color = .settingFromEnvironment(&graph.environ_map); |
| 228 | var watch = false; | 228 | var watch_flag = false; |
| 229 | var fuzz: ?Fuzz.Mode = null; | 229 | var fuzz: ?Fuzz.Mode = null; |
| 230 | var debounce_interval_ms: u16 = 50; | 230 | var debounce_interval_ms: u16 = 50; |
| 231 | var listen: bool = false; | 231 | var listen: bool = false; |
| ... | @@ -474,7 +474,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -474,7 +474,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 474 | } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) { | 474 | } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) { |
| 475 | graph.verbose_llvm_ir = true; | 475 | graph.verbose_llvm_ir = true; |
| 476 | } else if (mem.eql(u8, arg, "--watch")) { | 476 | } else if (mem.eql(u8, arg, "--watch")) { |
| 477 | watch = true; | 477 | watch_flag = true; |
| 478 | } else if (mem.eql(u8, arg, "--time-report")) { | 478 | } else if (mem.eql(u8, arg, "--time-report")) { |
| 479 | graph.time_report = true; | 479 | graph.time_report = true; |
| 480 | if (webui_listen == null) webui_listen = .{ .ip6 = .loopback(0) }; | 480 | if (webui_listen == null) webui_listen = .{ .ip6 = .loopback(0) }; |
| ... | @@ -574,7 +574,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -574,7 +574,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 574 | } | 574 | } |
| 575 | | 575 | |
| 576 | const early_exit_mode = fetch_only or help_menu or steps_menu or print_configuration != .none; | 576 | const early_exit_mode = fetch_only or help_menu or steps_menu or print_configuration != .none; |
| 577 | const server_mode = !early_exit_mode and (watch or webui_listen != null or fuzz != null or listen); | 577 | const server_mode = !early_exit_mode and (watch_flag or webui_listen != null or fuzz != null or listen); |
| 578 | | 578 | |
| 579 | process.raiseFileDescriptorLimit(); | 579 | process.raiseFileDescriptorLimit(); |
| 580 | | 580 | |
| ... | @@ -701,7 +701,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -701,7 +701,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 701 | var protocol_server_allocation: AvoidableServer = undefined; | 701 | var protocol_server_allocation: AvoidableServer = undefined; |
| 702 | const protocol_server: ?*AvoidableServer = if (listen) s: { | 702 | const protocol_server: ?*AvoidableServer = if (listen) s: { |
| 703 | if (builtin.single_threaded) fatal("--listen is not yet supported on single-threaded hosts", .{}); | 703 | if (builtin.single_threaded) fatal("--listen is not yet supported on single-threaded hosts", .{}); |
| 704 | if (watch) fatal("using '--watch' and '--listen' together is not supported", .{}); | 704 | if (watch_flag) fatal("using '--watch' and '--listen' together is not supported", .{}); |
| 705 | if (fuzz != null) fatal("using '--fuzz' and '--listen' together is not supported", .{}); | 705 | if (fuzz != null) fatal("using '--fuzz' and '--listen' together is not supported", .{}); |
| 706 | if (step_names.items.len > 0) fatal("build steps must be provided over the protocol instead of using CLI arguments", .{}); | 706 | if (step_names.items.len > 0) fatal("build steps must be provided over the protocol instead of using CLI arguments", .{}); |
| 707 | protocol_server_allocation = .{ | 707 | protocol_server_allocation = .{ |
| ... | @@ -788,7 +788,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -788,7 +788,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 788 | .skip_oom_steps = skip_oom_steps, | 788 | .skip_oom_steps = skip_oom_steps, |
| 789 | .unit_test_timeout_ns = test_timeout_ns, | 789 | .unit_test_timeout_ns = test_timeout_ns, |
| 790 | | 790 | |
| 791 | .watch = watch, | 791 | .watch = watch_flag, |
| 792 | .web_server = web_server, | 792 | .web_server = web_server, |
| 793 | .protocol_server = protocol_server, | 793 | .protocol_server = protocol_server, |
| 794 | .protocol_server_mutex = .init, | 794 | .protocol_server_mutex = .init, |
| ... | @@ -801,7 +801,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -801,7 +801,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 801 | .multiline_errors = multiline_errors, | 801 | .multiline_errors = multiline_errors, |
| 802 | .summary = summary orelse if (listen) | 802 | .summary = summary orelse if (listen) |
| 803 | .none | 803 | .none |
| 804 | else if (watch or webui_listen != null) | 804 | else if (watch_flag or webui_listen != null) |
| 805 | .new | 805 | .new |
| 806 | else | 806 | else |
| 807 | .failures, | 807 | .failures, |
| ... | @@ -820,7 +820,8 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -820,7 +820,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 820 | if (protocol_server) |s| { | 820 | if (protocol_server) |s| { |
| 821 | try s.serveStringMessage(.bsp_configuration, try arena.print("{f}", .{scanned_config.path})); | 821 | try s.serveStringMessage(.bsp_configuration, try arena.print("{f}", .{scanned_config.path})); |
| 822 | | 822 | |
| 823 | var w: ?Watch = null; | 823 | var watch: ?Watch = null; |
| | 824 | defer if (watch) |*w| w.deinit(); |
| 824 | | 825 | |
| 825 | const Event = union(enum) { | 826 | const Event = union(enum) { |
| 826 | message: Reader.Error!Client.Message.Header, | 827 | message: Reader.Error!Client.Message.Header, |
| ... | @@ -869,11 +870,11 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -869,11 +870,11 @@ pub fn main(init: process.Init.Minimal) !void { |
| 869 | | 870 | |
| 870 | if (body.flags.watch) { | 871 | if (body.flags.watch) { |
| 871 | if (!Watch.have_impl) unreachable; | 872 | if (!Watch.have_impl) unreachable; |
| 872 | if (w == null) w = try .init(&maker); | 873 | if (watch == null) watch = try .init(&maker); |
| 873 | | 874 | |
| 874 | try updateWatch(&maker, &w.?); | 875 | try updateWatch(&maker, &watch.?); |
| 875 | try select.concurrent(.fs_event, Watch.wait, .{ | 876 | try select.concurrent(.fs_event, Watch.wait, .{ |
| 876 | &w.?, | 877 | &watch.?, |
| 877 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, | 878 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, |
| 878 | }); | 879 | }); |
| 879 | } | 880 | } |
| ... | @@ -902,7 +903,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -902,7 +903,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 902 | .clean => {}, | 903 | .clean => {}, |
| 903 | } | 904 | } |
| 904 | try select.concurrent(.fs_event, Watch.wait, .{ | 905 | try select.concurrent(.fs_event, Watch.wait, .{ |
| 905 | &w.?, | 906 | &watch.?, |
| 906 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, | 907 | if (in_debounce) .{ .ms = debounce_interval_ms } else .none, |
| 907 | }); | 908 | }); |
| 908 | continue :loop try select.await(); | 909 | continue :loop try select.await(); |
| ... | @@ -924,10 +925,11 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -924,10 +925,11 @@ pub fn main(init: process.Init.Minimal) !void { |
| 924 | }; | 925 | }; |
| 925 | | 926 | |
| 926 | var w: Watch = w: { | 927 | var w: Watch = w: { |
| 927 | if (!watch) break :w undefined; | 928 | if (!watch_flag) break :w undefined; |
| 928 | if (!Watch.have_impl) fatal("--watch not yet implemented for {t}", .{native_os}); | 929 | if (!Watch.have_impl) fatal("--watch not yet implemented for {t}", .{native_os}); |
| 929 | break :w try .init(&maker); | 930 | break :w try .init(&maker); |
| 930 | }; | 931 | }; |
| | 932 | defer w.deinit(); |
| 931 | | 933 | |
| 932 | if (web_server) |ws| try ws.updateConfiguration(&maker); | 934 | if (web_server) |ws| try ws.updateConfiguration(&maker); |
| 933 | | 935 | |
| ... | @@ -942,7 +944,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -942,7 +944,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 942 | | 944 | |
| 943 | if (web_server) |ws| { | 945 | if (web_server) |ws| { |
| 944 | const c = &scanned_config.configuration; | 946 | const c = &scanned_config.configuration; |
| 945 | assert(!watch); // fatal error after CLI parsing | 947 | assert(!watch_flag); // fatal error after CLI parsing |
| 946 | while (true) switch (try ws.wait()) { | 948 | while (true) switch (try ws.wait()) { |
| 947 | .rebuild => { | 949 | .rebuild => { |
| 948 | for (maker.step_stack.keys()) |step_index| { | 950 | for (maker.step_stack.keys()) |step_index| { |
| ... | @@ -1019,7 +1021,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -1019,7 +1021,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 1019 | if (protocol_server != null) { | 1021 | if (protocol_server != null) { |
| 1020 | fatal("(zig build system) TODO send error messages to client when build.zig compilation fails", .{}); | 1022 | fatal("(zig build system) TODO send error messages to client when build.zig compilation fails", .{}); |
| 1021 | } | 1023 | } |
| 1022 | if (watch and can_fs_watch) { | 1024 | if (watch_flag and can_fs_watch) { |
| 1023 | fatal("(zig build system) TODO set up fs watching even when build.zig compilation fails", .{}); | 1025 | fatal("(zig build system) TODO set up fs watching even when build.zig compilation fails", .{}); |
| 1024 | } else { | 1026 | } else { |
| 1025 | fatal("(zig build system) TODO stay running and wait for user to request rebuild even when build.zig compilation fails", .{}); | 1027 | fatal("(zig build system) TODO stay running and wait for user to request rebuild even when build.zig compilation fails", .{}); |