diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-05-27 13:51:16 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-27 20:56:49 -0700 |
| commit | 44389253c2c3bd47c2c741aa6c804d18d1642ee7 (patch) | |
| tree | 97d48a74cfd0389ef30907a6e248e7f998d0a56a /src | |
| parent | 2367a1ff846ef2f146d4f7e449044970d399046b (diff) | |
| download | zig-44389253c2c3bd47c2c741aa6c804d18d1642ee7.tar.gz zig-44389253c2c3bd47c2c741aa6c804d18d1642ee7.zip | |
fix zig translate-c creating root progress node twice
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main.zig b/src/main.zig index a1a7260552..987a7cec5a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3404,15 +3404,15 @@ fn buildOutputType( }, } - if (arg_mode == .translate_c) { - return cmdTranslateC(comp, arena, null); - } - const root_prog_node = std.Progress.start(.{ .disable_printing = (color == .off), }); defer root_prog_node.end(); + if (arg_mode == .translate_c) { + return cmdTranslateC(comp, arena, null, root_prog_node); + } + updateModule(comp, color, root_prog_node) catch |err| switch (err) { error.SemanticAnalyzeFail => { assert(listen == .none); @@ -4048,7 +4048,7 @@ fn serve( defer arena_instance.deinit(); const arena = arena_instance.allocator(); var output: Compilation.CImportResult = undefined; - try cmdTranslateC(comp, arena, &output); + try cmdTranslateC(comp, arena, &output, main_progress_node); defer output.deinit(gpa); if (output.errors.errorMessageCount() != 0) { try server.serveErrorBundle(output.errors); @@ -4398,7 +4398,12 @@ fn updateModule(comp: *Compilation, color: Color, prog_node: std.Progress.Node) } } -fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilation.CImportResult) !void { +fn cmdTranslateC( + comp: *Compilation, + arena: Allocator, + fancy_output: ?*Compilation.CImportResult, + prog_node: std.Progress.Node, +) !void { if (build_options.only_core_functionality) @panic("@translate-c is not available in a zig2.c build"); const color: Color = .auto; assert(comp.c_source_files.len == 1); @@ -4459,6 +4464,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati .root_src_path = "aro_translate_c.zig", .depend_on_aro = true, .capture = &stdout, + .progress_node = prog_node, }); break :f stdout; }, @@ -5236,6 +5242,7 @@ const JitCmdOptions = struct { capture: ?*[]u8 = null, /// Send error bundles via std.zig.Server over stdout server: bool = false, + progress_node: std.Progress.Node = .{ .index = .none }, }; fn jitCmd( @@ -5245,9 +5252,12 @@ fn jitCmd( options: JitCmdOptions, ) !void { const color: Color = .auto; - const root_prog_node = std.Progress.start(.{ - .disable_printing = (color == .off), - }); + const root_prog_node = if (options.progress_node.index != .none) + options.progress_node + else + std.Progress.start(.{ + .disable_printing = (color == .off), + }); const target_query: std.Target.Query = .{}; const resolved_target: Package.Module.ResolvedTarget = .{ |
