| ... | @@ -9650,6 +9650,21 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose | ... | @@ -9650,6 +9650,21 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose |
| 9650 | return ErrorNone; | 9650 | return ErrorNone; |
| 9651 | } | 9651 | } |
| 9652 | | 9652 | |
| | 9653 | static bool need_llvm_module(CodeGen *g) { |
| | 9654 | return buf_len(&g->main_pkg->root_src_path) != 0; |
| | 9655 | } |
| | 9656 | |
| | 9657 | // before gen_c_objects |
| | 9658 | static bool main_output_dir_is_just_one_c_object_pre(CodeGen *g) { |
| | 9659 | return g->enable_cache && g->c_source_files.length == 1 && !need_llvm_module(g) && |
| | 9660 | g->out_type == OutTypeObj && g->link_objects.length == 0; |
| | 9661 | } |
| | 9662 | |
| | 9663 | // after gen_c_objects |
| | 9664 | static bool main_output_dir_is_just_one_c_object_post(CodeGen *g) { |
| | 9665 | return g->enable_cache && g->link_objects.length == 1 && !need_llvm_module(g) && g->out_type == OutTypeObj; |
| | 9666 | } |
| | 9667 | |
| 9653 | // returns true if it was a cache miss | 9668 | // returns true if it was a cache miss |
| 9654 | static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | 9669 | static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 9655 | Error err; | 9670 | Error err; |
| ... | @@ -9667,7 +9682,12 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -9667,7 +9682,12 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 9667 | buf_len(c_source_basename), 0); | 9682 | buf_len(c_source_basename), 0); |
| 9668 | | 9683 | |
| 9669 | Buf *final_o_basename = buf_alloc(); | 9684 | Buf *final_o_basename = buf_alloc(); |
| 9670 | os_path_extname(c_source_basename, final_o_basename, nullptr); | 9685 | // We special case when doing build-obj for just one C file |
| | 9686 | if (main_output_dir_is_just_one_c_object_pre(g)) { |
| | 9687 | buf_init_from_buf(final_o_basename, g->root_out_name); |
| | 9688 | } else { |
| | 9689 | os_path_extname(c_source_basename, final_o_basename, nullptr); |
| | 9690 | } |
| 9671 | buf_append_str(final_o_basename, target_o_file_ext(g->zig_target)); | 9691 | buf_append_str(final_o_basename, target_o_file_ext(g->zig_target)); |
| 9672 | | 9692 | |
| 9673 | CacheHash *cache_hash; | 9693 | CacheHash *cache_hash; |
| ... | @@ -10467,10 +10487,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { | ... | @@ -10467,10 +10487,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10467 | return ErrorNone; | 10487 | return ErrorNone; |
| 10468 | } | 10488 | } |
| 10469 | | 10489 | |
| 10470 | static bool need_llvm_module(CodeGen *g) { | | |
| 10471 | return buf_len(&g->main_pkg->root_src_path) != 0; | | |
| 10472 | } | | |
| 10473 | | | |
| 10474 | static void resolve_out_paths(CodeGen *g) { | 10490 | static void resolve_out_paths(CodeGen *g) { |
| 10475 | assert(g->output_dir != nullptr); | 10491 | assert(g->output_dir != nullptr); |
| 10476 | assert(g->root_out_name != nullptr); | 10492 | assert(g->root_out_name != nullptr); |
| ... | @@ -10576,12 +10592,8 @@ static void output_type_information(CodeGen *g) { | ... | @@ -10576,12 +10592,8 @@ static void output_type_information(CodeGen *g) { |
| 10576 | } | 10592 | } |
| 10577 | } | 10593 | } |
| 10578 | | 10594 | |
| 10579 | static bool main_output_dir_is_just_one_c_object(CodeGen *g) { | | |
| 10580 | return g->enable_cache && g->link_objects.length == 1 && !need_llvm_module(g); | | |
| 10581 | } | | |
| 10582 | | | |
| 10583 | static void init_output_dir(CodeGen *g, Buf *digest) { | 10595 | static void init_output_dir(CodeGen *g, Buf *digest) { |
| 10584 | if (main_output_dir_is_just_one_c_object(g)) { | 10596 | if (main_output_dir_is_just_one_c_object_post(g)) { |
| 10585 | g->output_dir = buf_alloc(); | 10597 | g->output_dir = buf_alloc(); |
| 10586 | os_path_dirname(g->link_objects.at(0), g->output_dir); | 10598 | os_path_dirname(g->link_objects.at(0), g->output_dir); |
| 10587 | } else { | 10599 | } else { |