| ... | ... | @@ -4082,12 +4082,7 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void |
| 4082 | 4082 | defer errors.deinit(comp.gpa); |
| 4083 | 4083 | |
| 4084 | 4084 | if (errors.errorMessageCount() > 0) { |
| 4085 | | const ttyconf: std.debug.TTY.Config = switch (comp.color) { |
| 4086 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 4087 | | .on => .escape_codes, |
| 4088 | | .off => .no_color, |
| 4089 | | }; |
| 4090 | | errors.renderToStdErr(ttyconf); |
| 4085 | errors.renderToStdErr(get_tty_conf(comp.color)); |
| 4091 | 4086 | const log_text = comp.getCompileLogOutput(); |
| 4092 | 4087 | if (log_text.len != 0) { |
| 4093 | 4088 | std.debug.print("\nCompile Log Output:\n{s}", .{log_text}); |
| ... | ... | @@ -4714,14 +4709,9 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4714 | 4709 | &all_modules, |
| 4715 | 4710 | ); |
| 4716 | 4711 | if (wip_errors.root_list.items.len > 0) { |
| 4717 | | const ttyconf: std.debug.TTY.Config = switch (color) { |
| 4718 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 4719 | | .on => .escape_codes, |
| 4720 | | .off => .no_color, |
| 4721 | | }; |
| 4722 | 4712 | var errors = try wip_errors.toOwnedBundle(); |
| 4723 | 4713 | defer errors.deinit(gpa); |
| 4724 | | errors.renderToStdErr(ttyconf); |
| 4714 | errors.renderToStdErr(get_tty_conf(color)); |
| 4725 | 4715 | process.exit(1); |
| 4726 | 4716 | } |
| 4727 | 4717 | try fetch_result; |
| ... | ... | @@ -4767,7 +4757,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4767 | 4757 | defer comp.destroy(); |
| 4768 | 4758 | |
| 4769 | 4759 | updateModule(gpa, comp, .none) catch |err| switch (err) { |
| 4770 | | error.SemanticAnalyzeFail => process.exit(1), |
| 4760 | error.SemanticAnalyzeFail => process.exit(2), |
| 4771 | 4761 | else => |e| return e, |
| 4772 | 4762 | }; |
| 4773 | 4763 | try comp.makeBinFileExecutable(); |
| ... | ... | @@ -4982,14 +4972,9 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 4982 | 4972 | try wip_errors.init(gpa); |
| 4983 | 4973 | defer wip_errors.deinit(); |
| 4984 | 4974 | try Compilation.addZirErrorMessages(&wip_errors, &file); |
| 4985 | | const ttyconf: std.debug.TTY.Config = switch (color) { |
| 4986 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 4987 | | .on => .escape_codes, |
| 4988 | | .off => .no_color, |
| 4989 | | }; |
| 4990 | 4975 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 4991 | 4976 | defer error_bundle.deinit(gpa); |
| 4992 | | error_bundle.renderToStdErr(ttyconf); |
| 4977 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 4993 | 4978 | process.exit(2); |
| 4994 | 4979 | } |
| 4995 | 4980 | } else if (tree.errors.len != 0) { |
| ... | ... | @@ -5193,14 +5178,9 @@ fn fmtPathFile( |
| 5193 | 5178 | try wip_errors.init(gpa); |
| 5194 | 5179 | defer wip_errors.deinit(); |
| 5195 | 5180 | try Compilation.addZirErrorMessages(&wip_errors, &file); |
| 5196 | | const ttyconf: std.debug.TTY.Config = switch (fmt.color) { |
| 5197 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 5198 | | .on => .escape_codes, |
| 5199 | | .off => .no_color, |
| 5200 | | }; |
| 5201 | 5181 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5202 | 5182 | defer error_bundle.deinit(gpa); |
| 5203 | | error_bundle.renderToStdErr(ttyconf); |
| 5183 | error_bundle.renderToStdErr(get_tty_conf(fmt.color)); |
| 5204 | 5184 | fmt.any_error = true; |
| 5205 | 5185 | } |
| 5206 | 5186 | } |
| ... | ... | @@ -5235,14 +5215,9 @@ fn printAstErrorsToStderr(gpa: Allocator, tree: Ast, path: []const u8, color: Co |
| 5235 | 5215 | |
| 5236 | 5216 | try putAstErrorsIntoBundle(gpa, tree, path, &wip_errors); |
| 5237 | 5217 | |
| 5238 | | const ttyconf: std.debug.TTY.Config = switch (color) { |
| 5239 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 5240 | | .on => .escape_codes, |
| 5241 | | .off => .no_color, |
| 5242 | | }; |
| 5243 | 5218 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5244 | 5219 | defer error_bundle.deinit(gpa); |
| 5245 | | error_bundle.renderToStdErr(ttyconf); |
| 5220 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 5246 | 5221 | } |
| 5247 | 5222 | |
| 5248 | 5223 | pub fn putAstErrorsIntoBundle( |
| ... | ... | @@ -5848,11 +5823,6 @@ pub fn cmdAstCheck( |
| 5848 | 5823 | file.tree_loaded = true; |
| 5849 | 5824 | defer file.tree.deinit(gpa); |
| 5850 | 5825 | |
| 5851 | | try printAstErrorsToStderr(gpa, file.tree, file.sub_file_path, color); |
| 5852 | | if (file.tree.errors.len != 0) { |
| 5853 | | process.exit(1); |
| 5854 | | } |
| 5855 | | |
| 5856 | 5826 | file.zir = try AstGen.generate(gpa, file.tree); |
| 5857 | 5827 | file.zir_loaded = true; |
| 5858 | 5828 | defer file.zir.deinit(gpa); |
| ... | ... | @@ -5862,14 +5832,9 @@ pub fn cmdAstCheck( |
| 5862 | 5832 | try wip_errors.init(gpa); |
| 5863 | 5833 | defer wip_errors.deinit(); |
| 5864 | 5834 | try Compilation.addZirErrorMessages(&wip_errors, &file); |
| 5865 | | const ttyconf: std.debug.TTY.Config = switch (color) { |
| 5866 | | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 5867 | | .on => .escape_codes, |
| 5868 | | .off => .no_color, |
| 5869 | | }; |
| 5870 | 5835 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5871 | 5836 | defer error_bundle.deinit(gpa); |
| 5872 | | error_bundle.renderToStdErr(ttyconf); |
| 5837 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 5873 | 5838 | process.exit(1); |
| 5874 | 5839 | } |
| 5875 | 5840 | |
| ... | ... | @@ -5974,11 +5939,6 @@ pub fn cmdChangelist( |
| 5974 | 5939 | file.tree_loaded = true; |
| 5975 | 5940 | defer file.tree.deinit(gpa); |
| 5976 | 5941 | |
| 5977 | | try printAstErrorsToStderr(gpa, file.tree, old_source_file, .auto); |
| 5978 | | if (file.tree.errors.len != 0) { |
| 5979 | | process.exit(1); |
| 5980 | | } |
| 5981 | | |
| 5982 | 5942 | file.zir = try AstGen.generate(gpa, file.tree); |
| 5983 | 5943 | file.zir_loaded = true; |
| 5984 | 5944 | defer file.zir.deinit(gpa); |
| ... | ... | @@ -6013,11 +5973,6 @@ pub fn cmdChangelist( |
| 6013 | 5973 | var new_tree = try Ast.parse(gpa, new_source, .zig); |
| 6014 | 5974 | defer new_tree.deinit(gpa); |
| 6015 | 5975 | |
| 6016 | | try printAstErrorsToStderr(gpa, new_tree, new_source_file, .auto); |
| 6017 | | if (new_tree.errors.len != 0) { |
| 6018 | | process.exit(1); |
| 6019 | | } |
| 6020 | | |
| 6021 | 5976 | var old_zir = file.zir; |
| 6022 | 5977 | defer old_zir.deinit(gpa); |
| 6023 | 5978 | file.zir_loaded = false; |
| ... | ... | @@ -6293,3 +6248,11 @@ const ClangSearchSanitizer = struct { |
| 6293 | 6248 | iframework: bool = false, |
| 6294 | 6249 | }; |
| 6295 | 6250 | }; |
| 6251 | |
| 6252 | fn get_tty_conf(color: Color) std.debug.TTY.Config { |
| 6253 | return switch (color) { |
| 6254 | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), |
| 6255 | .on => .escape_codes, |
| 6256 | .off => .no_color, |
| 6257 | }; |
| 6258 | } |