restricted c header imports
This commit is contained in:
@@ -2,6 +2,7 @@ package backend
|
||||
|
||||
import "../linker"
|
||||
import "../target"
|
||||
import "../cimport"
|
||||
import "core:fmt"
|
||||
import "core:mem"
|
||||
import "core:os"
|
||||
@@ -16,6 +17,7 @@ build_command :: proc(
|
||||
llvm_path, output_path: string,
|
||||
link_arguments: []linker.Argument,
|
||||
selected := target.DEFAULT,
|
||||
c_options := cimport.Options{},
|
||||
allocator := context.allocator,
|
||||
) -> []string {
|
||||
command: [dynamic]string
|
||||
@@ -26,7 +28,14 @@ build_command :: proc(
|
||||
append_owned(&command, "-target", allocator)
|
||||
append_owned(&command, target.name(selected), allocator)
|
||||
append_owned(&command, "-Wno-override-module", allocator)
|
||||
append_owned(&command, "-Wno-unused-command-line-argument", allocator)
|
||||
append_owned(&command, llvm_path, allocator)
|
||||
for path in c_options.include_paths {
|
||||
append(&command, fmt.aprintf("-I%s", path, allocator=allocator))
|
||||
}
|
||||
for define in c_options.defines {
|
||||
append(&command, fmt.aprintf("-D%s", define, allocator=allocator))
|
||||
}
|
||||
for argument in link_arguments {
|
||||
switch argument.kind {
|
||||
case .Input:
|
||||
@@ -53,12 +62,13 @@ compile :: proc(
|
||||
llvm_path, output_path: string,
|
||||
link_arguments: []linker.Argument = nil,
|
||||
selected := target.DEFAULT,
|
||||
c_options := cimport.Options{},
|
||||
) -> 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, selected)
|
||||
command := build_command(llvm_path, temporary_output, link_arguments, selected, c_options)
|
||||
defer destroy_command(command)
|
||||
state, stdout, stderr, err := os2.process_exec(
|
||||
os2.Process_Desc{command=command},
|
||||
|
||||
Reference in New Issue
Block a user