From b09cdc0f256bca71ffcb5960c75127e8aaa55b87 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 24 Jul 2023 12:01:23 +0100 Subject: Hook up Tilde to the linker code --- src/linker.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/linker.cpp') diff --git a/src/linker.cpp b/src/linker.cpp index dc6e072d1..c0fbf596f 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -11,6 +11,39 @@ struct LinkerData { gb_internal i32 system_exec_command_line_app(char const *name, char const *fmt, ...); +gb_internal void linker_data_init(LinkerData *ld, CheckerInfo *info, String const &init_fullpath) { + gbAllocator ha = heap_allocator(); + array_init(&ld->output_object_paths, ha); + array_init(&ld->output_temp_paths, ha); + array_init(&ld->foreign_libraries, ha, 0, 1024); + ptr_set_init(&ld->foreign_libraries_set, 1024); + + if (build_context.out_filepath.len == 0) { + ld->output_name = remove_directory_from_path(init_fullpath); + ld->output_name = remove_extension_from_path(ld->output_name); + ld->output_name = string_trim_whitespace(ld->output_name); + if (ld->output_name.len == 0) { + ld->output_name = info->init_scope->pkg->name; + } + ld->output_base = ld->output_name; + } else { + ld->output_name = build_context.out_filepath; + ld->output_name = string_trim_whitespace(ld->output_name); + if (ld->output_name.len == 0) { + ld->output_name = info->init_scope->pkg->name; + } + isize pos = string_extension_position(ld->output_name); + if (pos < 0) { + ld->output_base = ld->output_name; + } else { + ld->output_base = substring(ld->output_name, 0, pos); + } + } + + ld->output_base = path_to_full_path(ha, ld->output_base); + +} + gb_internal i32 linker_stage(LinkerData *gen) { i32 result = 0; Timings *timings = &global_timings; -- cgit v1.2.3