| ... | @@ -4082,12 +4082,7 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void | ... | @@ -4082,12 +4082,7 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void |
| 4082 | defer errors.deinit(comp.gpa); | 4082 | defer errors.deinit(comp.gpa); |
| 4083 | | 4083 | |
| 4084 | if (errors.errorMessageCount() > 0) { | 4084 | if (errors.errorMessageCount() > 0) { |
| 4085 | const ttyconf: std.debug.TTY.Config = switch (comp.color) { | 4085 | errors.renderToStdErr(get_tty_conf(comp.color)); |
| 4086 | .auto => std.debug.detectTTYConfig(std.io.getStdErr()), | | |
| 4087 | .on => .escape_codes, | | |
| 4088 | .off => .no_color, | | |
| 4089 | }; | | |
| 4090 | errors.renderToStdErr(ttyconf); | | |
| 4091 | const log_text = comp.getCompileLogOutput(); | 4086 | const log_text = comp.getCompileLogOutput(); |
| 4092 | if (log_text.len != 0) { | 4087 | if (log_text.len != 0) { |
| 4093 | std.debug.print("\nCompile Log Output:\n{s}", .{log_text}); | 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,14 +4709,9 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4714 | &all_modules, | 4709 | &all_modules, |
| 4715 | ); | 4710 | ); |
| 4716 | if (wip_errors.root_list.items.len > 0) { | 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 | var errors = try wip_errors.toOwnedBundle(); | 4712 | var errors = try wip_errors.toOwnedBundle(); |
| 4723 | defer errors.deinit(gpa); | 4713 | defer errors.deinit(gpa); |
| 4724 | errors.renderToStdErr(ttyconf); | 4714 | errors.renderToStdErr(get_tty_conf(color)); |
| 4725 | process.exit(1); | 4715 | process.exit(1); |
| 4726 | } | 4716 | } |
| 4727 | try fetch_result; | 4717 | try fetch_result; |
| ... | @@ -4767,7 +4757,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -4767,7 +4757,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4767 | defer comp.destroy(); | 4757 | defer comp.destroy(); |
| 4768 | | 4758 | |
| 4769 | updateModule(gpa, comp, .none) catch |err| switch (err) { | 4759 | updateModule(gpa, comp, .none) catch |err| switch (err) { |
| 4770 | error.SemanticAnalyzeFail => process.exit(1), | 4760 | error.SemanticAnalyzeFail => process.exit(2), |
| 4771 | else => |e| return e, | 4761 | else => |e| return e, |
| 4772 | }; | 4762 | }; |
| 4773 | try comp.makeBinFileExecutable(); | 4763 | try comp.makeBinFileExecutable(); |
| ... | @@ -4982,14 +4972,9 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void | ... | @@ -4982,14 +4972,9 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 4982 | try wip_errors.init(gpa); | 4972 | try wip_errors.init(gpa); |
| 4983 | defer wip_errors.deinit(); | 4973 | defer wip_errors.deinit(); |
| 4984 | try Compilation.addZirErrorMessages(&wip_errors, &file); | 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 | var error_bundle = try wip_errors.toOwnedBundle(); | 4975 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 4991 | defer error_bundle.deinit(gpa); | 4976 | defer error_bundle.deinit(gpa); |
| 4992 | error_bundle.renderToStdErr(ttyconf); | 4977 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 4993 | process.exit(2); | 4978 | process.exit(2); |
| 4994 | } | 4979 | } |
| 4995 | } else if (tree.errors.len != 0) { | 4980 | } else if (tree.errors.len != 0) { |
| ... | @@ -5193,14 +5178,9 @@ fn fmtPathFile( | ... | @@ -5193,14 +5178,9 @@ fn fmtPathFile( |
| 5193 | try wip_errors.init(gpa); | 5178 | try wip_errors.init(gpa); |
| 5194 | defer wip_errors.deinit(); | 5179 | defer wip_errors.deinit(); |
| 5195 | try Compilation.addZirErrorMessages(&wip_errors, &file); | 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 | var error_bundle = try wip_errors.toOwnedBundle(); | 5181 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5202 | defer error_bundle.deinit(gpa); | 5182 | defer error_bundle.deinit(gpa); |
| 5203 | error_bundle.renderToStdErr(ttyconf); | 5183 | error_bundle.renderToStdErr(get_tty_conf(fmt.color)); |
| 5204 | fmt.any_error = true; | 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,14 +5215,9 @@ fn printAstErrorsToStderr(gpa: Allocator, tree: Ast, path: []const u8, color: Co |
| 5235 | | 5215 | |
| 5236 | try putAstErrorsIntoBundle(gpa, tree, path, &wip_errors); | 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 | var error_bundle = try wip_errors.toOwnedBundle(); | 5218 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5244 | defer error_bundle.deinit(gpa); | 5219 | defer error_bundle.deinit(gpa); |
| 5245 | error_bundle.renderToStdErr(ttyconf); | 5220 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 5246 | } | 5221 | } |
| 5247 | | 5222 | |
| 5248 | pub fn putAstErrorsIntoBundle( | 5223 | pub fn putAstErrorsIntoBundle( |
| ... | @@ -5848,11 +5823,6 @@ pub fn cmdAstCheck( | ... | @@ -5848,11 +5823,6 @@ pub fn cmdAstCheck( |
| 5848 | file.tree_loaded = true; | 5823 | file.tree_loaded = true; |
| 5849 | defer file.tree.deinit(gpa); | 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 | file.zir = try AstGen.generate(gpa, file.tree); | 5826 | file.zir = try AstGen.generate(gpa, file.tree); |
| 5857 | file.zir_loaded = true; | 5827 | file.zir_loaded = true; |
| 5858 | defer file.zir.deinit(gpa); | 5828 | defer file.zir.deinit(gpa); |
| ... | @@ -5862,14 +5832,9 @@ pub fn cmdAstCheck( | ... | @@ -5862,14 +5832,9 @@ pub fn cmdAstCheck( |
| 5862 | try wip_errors.init(gpa); | 5832 | try wip_errors.init(gpa); |
| 5863 | defer wip_errors.deinit(); | 5833 | defer wip_errors.deinit(); |
| 5864 | try Compilation.addZirErrorMessages(&wip_errors, &file); | 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 | var error_bundle = try wip_errors.toOwnedBundle(); | 5835 | var error_bundle = try wip_errors.toOwnedBundle(); |
| 5871 | defer error_bundle.deinit(gpa); | 5836 | defer error_bundle.deinit(gpa); |
| 5872 | error_bundle.renderToStdErr(ttyconf); | 5837 | error_bundle.renderToStdErr(get_tty_conf(color)); |
| 5873 | process.exit(1); | 5838 | process.exit(1); |
| 5874 | } | 5839 | } |
| 5875 | | 5840 | |
| ... | @@ -5974,11 +5939,6 @@ pub fn cmdChangelist( | ... | @@ -5974,11 +5939,6 @@ pub fn cmdChangelist( |
| 5974 | file.tree_loaded = true; | 5939 | file.tree_loaded = true; |
| 5975 | defer file.tree.deinit(gpa); | 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 | file.zir = try AstGen.generate(gpa, file.tree); | 5942 | file.zir = try AstGen.generate(gpa, file.tree); |
| 5983 | file.zir_loaded = true; | 5943 | file.zir_loaded = true; |
| 5984 | defer file.zir.deinit(gpa); | 5944 | defer file.zir.deinit(gpa); |
| ... | @@ -6013,11 +5973,6 @@ pub fn cmdChangelist( | ... | @@ -6013,11 +5973,6 @@ pub fn cmdChangelist( |
| 6013 | var new_tree = try Ast.parse(gpa, new_source, .zig); | 5973 | var new_tree = try Ast.parse(gpa, new_source, .zig); |
| 6014 | defer new_tree.deinit(gpa); | 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 | var old_zir = file.zir; | 5976 | var old_zir = file.zir; |
| 6022 | defer old_zir.deinit(gpa); | 5977 | defer old_zir.deinit(gpa); |
| 6023 | file.zir_loaded = false; | 5978 | file.zir_loaded = false; |
| ... | @@ -6293,3 +6248,11 @@ const ClangSearchSanitizer = struct { | ... | @@ -6293,3 +6248,11 @@ const ClangSearchSanitizer = struct { |
| 6293 | iframework: bool = false, | 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 | } |