c interop type foundation
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import "./compiler"
|
||||
import "./compiler/linker"
|
||||
import "./compiler/target"
|
||||
import "core:fmt"
|
||||
import "core:os/os2"
|
||||
|
||||
@@ -9,13 +10,14 @@ Cli_Options :: struct {
|
||||
input_path: string,
|
||||
output_path: string,
|
||||
link_arguments: []linker.Argument,
|
||||
target: target.Target,
|
||||
}
|
||||
|
||||
parse_cli_args :: proc(args: []string, allocator := context.allocator) -> (Cli_Options, bool) {
|
||||
if len(args) < 4 {
|
||||
return {}, false
|
||||
}
|
||||
options := Cli_Options{input_path=args[1]}
|
||||
options := Cli_Options{input_path=args[1], target=target.DEFAULT}
|
||||
link_arguments: [dynamic]linker.Argument
|
||||
link_arguments.allocator = allocator
|
||||
output_set := false
|
||||
@@ -43,6 +45,13 @@ parse_cli_args :: proc(args: []string, allocator := context.allocator) -> (Cli_O
|
||||
append(&link_arguments, linker.Argument{kind=.Library_Path, value=value})
|
||||
case "--library":
|
||||
append(&link_arguments, linker.Argument{kind=.Library, value=value})
|
||||
case "--target":
|
||||
selected, ok := target.parse(value)
|
||||
if !ok {
|
||||
delete(link_arguments)
|
||||
return {}, false
|
||||
}
|
||||
options.target = selected
|
||||
case:
|
||||
delete(link_arguments)
|
||||
return {}, false
|
||||
@@ -58,7 +67,7 @@ parse_cli_args :: proc(args: []string, allocator := context.allocator) -> (Cli_O
|
||||
|
||||
print_usage :: proc() {
|
||||
fmt.eprintln(
|
||||
"usage: brolang <package-directory> -o <executable> [--link <path> | --library-path <dir> | --library <name>]...",
|
||||
"usage: brolang <package-directory> -o <executable> [--target aarch64-macos] [--link <path> | --library-path <dir> | --library <name>]...",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,7 +78,7 @@ main :: proc() {
|
||||
os2.exit(2)
|
||||
}
|
||||
defer delete(options.link_arguments)
|
||||
status := compiler.compile_package(options.input_path, options.output_path, options.link_arguments)
|
||||
status := compiler.compile_package(options.input_path, options.output_path, options.link_arguments, options.target)
|
||||
if status != 0 {
|
||||
os2.exit(status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user