build system: consolidate duplicate code and more
* add ability to add assembly files when building an exe, obj, or lib * add implicit cast from `[N]T` to `?[]const T` (closes #343) * remove link_exe and link_lib in favor of allowing build_exe and build_lib support no root zig source file
This commit is contained in:
14
src/link.cpp
14
src/link.cpp
@@ -33,9 +33,11 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) {
|
||||
|
||||
static Buf *build_o(CodeGen *parent_gen, const char *oname) {
|
||||
Buf *source_basename = buf_sprintf("%s.zig", oname);
|
||||
Buf *full_path = buf_alloc();
|
||||
os_path_join(parent_gen->zig_std_special_dir, source_basename, full_path);
|
||||
|
||||
ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
|
||||
CodeGen *child_gen = codegen_create(parent_gen->zig_std_special_dir, child_target);
|
||||
CodeGen *child_gen = codegen_create(full_path, child_target);
|
||||
child_gen->link_libc = parent_gen->link_libc;
|
||||
|
||||
child_gen->link_libs.resize(parent_gen->link_libs.length);
|
||||
@@ -60,15 +62,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {
|
||||
codegen_set_mmacosx_version_min(child_gen, parent_gen->mmacosx_version_min);
|
||||
codegen_set_mios_version_min(child_gen, parent_gen->mios_version_min);
|
||||
|
||||
Buf *full_path = buf_alloc();
|
||||
os_path_join(parent_gen->zig_std_special_dir, source_basename, full_path);
|
||||
|
||||
Buf source_code = BUF_INIT;
|
||||
if (os_fetch_file_path(full_path, &source_code)) {
|
||||
zig_panic("unable to fetch file: %s\n", buf_ptr(full_path));
|
||||
}
|
||||
|
||||
codegen_add_root_code(child_gen, parent_gen->zig_std_special_dir, source_basename, &source_code);
|
||||
codegen_build(child_gen);
|
||||
const char *o_ext = target_o_file_ext(&child_gen->zig_target);
|
||||
Buf *o_out = buf_sprintf("%s%s", oname, o_ext);
|
||||
codegen_link(child_gen, buf_ptr(o_out));
|
||||
|
||||
Reference in New Issue
Block a user