zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3f8f0b9bba5407ed5f7279bfdb7d22afaa126674 (tree)
parent b97bfc3ecba9655cdd989add13a7582272659268
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Wed, 21 Sep 2016 11:18:49 -0400

exporting an object creates an h file

Diffstat:
Msrc/all_types.hpp | 1+
Msrc/codegen.cpp | 1+
Msrc/link.cpp | 10++++++----
3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/all_types.hpp b/src/all_types.hpp @@ -1256,6 +1256,7 @@ struct CodeGen { bool is_big_endian; bool is_static; bool strip_debug_symbols; + bool want_h_file; bool have_exported_main; bool link_libc; Buf *libc_lib_dir; diff --git a/src/codegen.cpp b/src/codegen.cpp @@ -63,6 +63,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { g->generic_table.init(16); g->is_release_build = false; g->is_test_build = false; + g->want_h_file = true; // the error.Ok value g->error_decls.append(nullptr); diff --git a/src/link.cpp b/src/link.cpp @@ -38,6 +38,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) { ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target; CodeGen *child_gen = codegen_create(std_dir_path, child_target); child_gen->link_libc = parent_gen->link_libc; + child_gen->want_h_file = false; codegen_set_is_release(child_gen, parent_gen->is_release_build); @@ -793,10 +794,8 @@ void codegen_link(CodeGen *g, const char *out_file) { buf_init_from_buf(&lj.out_file_o, &lj.out_file); - if (g->out_type != OutTypeObj) { - const char *o_ext = get_o_file_extension(g); - buf_append_str(&lj.out_file_o, o_ext); - } + const char *o_ext = get_o_file_extension(g); + buf_append_str(&lj.out_file_o, o_ext); char *err_msg = nullptr; if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o), @@ -806,6 +805,9 @@ void codegen_link(CodeGen *g, const char *out_file) { } if (g->out_type == OutTypeObj) { + if (g->want_h_file) { + codegen_generate_h_file(g); + } if (g->verbose) { fprintf(stderr, "OK\n"); }