mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
print the command that failed when C source code fails to build
also respect the --color arg when building C code
This commit is contained in:
parent
14ca0fd493
commit
3bfacf071e
@ -8164,6 +8164,14 @@ static void gen_global_asm(CodeGen *g) {
|
||||
}
|
||||
}
|
||||
|
||||
static void print_zig_cc_cmd(const char *zig_exe, ZigList<const char *> *args) {
|
||||
fprintf(stderr, zig_exe);
|
||||
for (size_t arg_i = 0; arg_i < args->length; arg_i += 1) {
|
||||
fprintf(stderr, " %s", args->at(arg_i));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
Error err;
|
||||
|
||||
@ -8190,6 +8198,19 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
args.append("-nostdinc");
|
||||
args.append("-fno-spell-checking");
|
||||
|
||||
switch (g->err_color) {
|
||||
case ErrColorAuto:
|
||||
break;
|
||||
case ErrColorOff:
|
||||
args.append("-fno-color-diagnostics");
|
||||
args.append("-fno-caret-diagnostics");
|
||||
break;
|
||||
case ErrColorOn:
|
||||
args.append("-fcolor-diagnostics");
|
||||
args.append("-fcaret-diagnostics");
|
||||
break;
|
||||
}
|
||||
|
||||
args.append("-isystem");
|
||||
args.append(buf_ptr(g->zig_c_headers_dir));
|
||||
|
||||
@ -8263,16 +8284,12 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
}
|
||||
|
||||
if (g->verbose_cc) {
|
||||
fprintf(stderr, "zig");
|
||||
for (size_t arg_i = 0; arg_i < args.length; arg_i += 1) {
|
||||
fprintf(stderr, " %s", args.at(arg_i));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
print_zig_cc_cmd("zig", &args);
|
||||
}
|
||||
|
||||
os_spawn_process(buf_ptr(self_exe_path), args, &term);
|
||||
if (term.how != TerminationIdClean || term.code != 0) {
|
||||
fprintf(stderr, "`zig cc` failed\n");
|
||||
fprintf(stderr, "\nThe following command failed:\n");
|
||||
print_zig_cc_cmd(buf_ptr(self_exe_path), &args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user