c interop type foundation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package backend
|
||||
|
||||
import "../linker"
|
||||
import "../target"
|
||||
import "core:fmt"
|
||||
import "core:mem"
|
||||
import "core:os"
|
||||
@@ -14,6 +15,7 @@ append_owned :: proc(command: ^[dynamic]string, value: string, allocator: mem.Al
|
||||
build_command :: proc(
|
||||
llvm_path, output_path: string,
|
||||
link_arguments: []linker.Argument,
|
||||
selected := target.DEFAULT,
|
||||
allocator := context.allocator,
|
||||
) -> []string {
|
||||
command: [dynamic]string
|
||||
@@ -21,6 +23,8 @@ build_command :: proc(
|
||||
append_owned(&command, "/usr/bin/env", allocator)
|
||||
append_owned(&command, "zig", allocator)
|
||||
append_owned(&command, "cc", allocator)
|
||||
append_owned(&command, "-target", allocator)
|
||||
append_owned(&command, target.name(selected), allocator)
|
||||
append_owned(&command, "-Wno-override-module", allocator)
|
||||
append_owned(&command, llvm_path, allocator)
|
||||
for argument in link_arguments {
|
||||
@@ -45,12 +49,16 @@ destroy_command :: proc(command: []string, allocator := context.allocator) {
|
||||
delete(command, allocator)
|
||||
}
|
||||
|
||||
compile :: proc(llvm_path, output_path: string, link_arguments: []linker.Argument = nil) -> bool {
|
||||
compile :: proc(
|
||||
llvm_path, output_path: string,
|
||||
link_arguments: []linker.Argument = nil,
|
||||
selected := target.DEFAULT,
|
||||
) -> bool {
|
||||
pid := os2.get_pid()
|
||||
temporary_output := fmt.tprintf("%s.brolang-tmp-%d", output_path, pid)
|
||||
defer _ = os.remove(temporary_output)
|
||||
|
||||
command := build_command(llvm_path, temporary_output, link_arguments)
|
||||
command := build_command(llvm_path, temporary_output, link_arguments, selected)
|
||||
defer destroy_command(command)
|
||||
state, stdout, stderr, err := os2.process_exec(
|
||||
os2.Process_Desc{command=command},
|
||||
|
||||
Reference in New Issue
Block a user