diff options
| author | hryx <codroid@gmail.com> | 2019-06-23 12:31:22 -0700 |
|---|---|---|
| committer | hryx <codroid@gmail.com> | 2019-06-23 12:31:22 -0700 |
| commit | c423697c78462f4e817869a3b25e72af33ce09ed (patch) | |
| tree | 9fa567896dbf4c4b34ac5afc3fa2c899e8275b66 /src/main.cpp | |
| parent | 1c86a191da400bd47a5044a5b84cf9a05b15066b (diff) | |
| parent | 9153b17c922e3166a824d300781ca4e6da015787 (diff) | |
| download | zig-c423697c78462f4e817869a3b25e72af33ce09ed.tar.gz zig-c423697c78462f4e817869a3b25e72af33ce09ed.zip | |
Merge branch 'master' into translate-c-userland
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/main.cpp b/src/main.cpp index 29c17212cf..9b1892061b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -467,6 +467,7 @@ int main(int argc, char **argv) { init_all_targets(); ZigList<const char *> args = {0}; + args.append(NULL); // placeholder args.append(zig_exe_path); args.append(NULL); // placeholder args.append(NULL); // placeholder @@ -525,8 +526,8 @@ int main(int argc, char **argv) { g->enable_time_report = timing_info; codegen_set_out_name(g, buf_create_from_str("build")); - args.items[1] = buf_ptr(&build_file_dirname); - args.items[2] = buf_ptr(&full_cache_dir); + args.items[2] = buf_ptr(&build_file_dirname); + args.items[3] = buf_ptr(&full_cache_dir); bool build_file_exists; if ((err = os_file_exists(&build_file_abs, &build_file_exists))) { @@ -580,12 +581,14 @@ int main(int argc, char **argv) { codegen_build_and_link(g); Termination term; - os_spawn_process(buf_ptr(&g->output_file_path), args, &term); + args.items[0] = buf_ptr(&g->output_file_path); + os_spawn_process(args, &term); if (term.how != TerminationIdClean || term.code != 0) { fprintf(stderr, "\nBuild failed. The following command failed:\n"); - fprintf(stderr, "%s", buf_ptr(&g->output_file_path)); + const char *prefix = ""; for (size_t i = 0; i < args.length; i += 1) { - fprintf(stderr, " %s", args.at(i)); + fprintf(stderr, "%s%s", prefix, args.at(i)); + prefix = " "; } fprintf(stderr, "\n"); } @@ -954,6 +957,7 @@ int main(int argc, char **argv) { case CmdBuiltin: { CodeGen *g = codegen_create(main_pkg_path, nullptr, &target, out_type, build_mode, override_lib_dir, override_std_dir, nullptr, nullptr); + codegen_set_strip(g, strip); g->subsystem = subsystem; g->valgrind_support = valgrind_support; g->want_pic = want_pic; @@ -1160,7 +1164,7 @@ int main(int argc, char **argv) { args.pop(); Termination term; - os_spawn_process(exec_path, args, &term); + os_spawn_process(args, &term); return term.code; } else if (cmd == CmdBuild) { if (g->enable_cache) { @@ -1212,17 +1216,10 @@ int main(int argc, char **argv) { } Termination term; - if (test_exec_args.length > 0) { - ZigList<const char *> rest_args = {0}; - for (size_t i = 1; i < test_exec_args.length; i += 1) { - rest_args.append(test_exec_args.at(i)); - } - os_spawn_process(test_exec_args.items[0], rest_args, &term); - } else { - ZigList<const char *> no_args = {0}; - os_spawn_process(buf_ptr(test_exe_path), no_args, &term); + if (test_exec_args.length == 0) { + test_exec_args.append(buf_ptr(test_exe_path)); } - + os_spawn_process(test_exec_args, &term); if (term.how != TerminationIdClean || term.code != 0) { fprintf(stderr, "\nTests failed. Use the following command to reproduce the failure:\n"); fprintf(stderr, "%s\n", buf_ptr(test_exe_path)); |
