mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix os.open
This commit is contained in:
@@ -65,7 +65,7 @@ is_path_separator :: proc(r: rune) -> bool {
|
|||||||
return r == '/' || r == '\\';
|
return r == '/' || r == '\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
open :: proc(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errno) {
|
open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errno) {
|
||||||
if len(path) == 0 do return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
|
if len(path) == 0 do return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
|
||||||
|
|
||||||
access: u32;
|
access: u32;
|
||||||
|
|||||||
+107
-103
@@ -933,110 +933,10 @@ i32 exec_llvm_llc(String output_base) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int arg_count, char const **arg_ptr) {
|
void print_show_help(String const arg0, String const &command) {
|
||||||
if (arg_count < 2) {
|
print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(arg0));
|
||||||
usage(make_string_c(arg_ptr[0]));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Timings *timings = &global_timings;
|
|
||||||
|
|
||||||
timings_init(timings, str_lit("Total Time"), 128);
|
|
||||||
defer (timings_destroy(timings));
|
|
||||||
|
|
||||||
init_string_buffer_memory();
|
|
||||||
init_global_error_collector();
|
|
||||||
global_big_int_init();
|
|
||||||
arena_init(&global_ast_arena, heap_allocator());
|
|
||||||
|
|
||||||
array_init(&library_collections, heap_allocator());
|
|
||||||
// NOTE(bill): 'core' cannot be (re)defined by the user
|
|
||||||
add_library_collection(str_lit("core"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("core")));
|
|
||||||
|
|
||||||
map_init(&build_context.defined_values, heap_allocator());
|
|
||||||
|
|
||||||
Array<String> args = setup_args(arg_count, arg_ptr);
|
|
||||||
|
|
||||||
String command = args[1];
|
|
||||||
String init_filename = {};
|
|
||||||
String run_args_string = {};
|
|
||||||
|
|
||||||
bool run_output = false;
|
|
||||||
if (command == "run") {
|
|
||||||
if (args.count < 3) {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
|
|
||||||
defer (array_free(&run_args));
|
|
||||||
|
|
||||||
isize last_non_run_arg = args.count;
|
|
||||||
for_array(i, args) {
|
|
||||||
if (args[i] == "--") {
|
|
||||||
last_non_run_arg = i;
|
|
||||||
}
|
|
||||||
if (i <= last_non_run_arg) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
array_add(&run_args, args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
args = array_slice(args, 0, last_non_run_arg);
|
|
||||||
run_args_string = string_join_and_quote(heap_allocator(), run_args);
|
|
||||||
init_filename = args[2];
|
|
||||||
run_output = true;
|
|
||||||
} else if (command == "build") {
|
|
||||||
if (args.count < 3) {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
init_filename = args[2];
|
|
||||||
} else if (command == "check") {
|
|
||||||
if (args.count < 3) {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
build_context.no_output_files = true;
|
|
||||||
init_filename = args[2];
|
|
||||||
} else if (command == "query") {
|
|
||||||
if (args.count < 3) {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
build_context.no_output_files = true;
|
|
||||||
build_context.query_data_set_settings.ok = true;
|
|
||||||
init_filename = args[2];
|
|
||||||
} else if (command == "docs") {
|
|
||||||
if (args.count < 3) {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_filename = args[2];
|
|
||||||
build_context.generate_docs = true;
|
|
||||||
#if 1
|
|
||||||
print_usage_line(0, "Documentation generation is not yet supported");
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
} else if (command == "version") {
|
|
||||||
gb_printf("%.*s version %.*s\n", LIT(args[0]), LIT(ODIN_VERSION));
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
usage(args[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
build_context.command = command;
|
|
||||||
|
|
||||||
if (!parse_build_flags(args)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build_context.show_help) {
|
|
||||||
print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(args[0]));
|
|
||||||
print_usage_line(0, "Usage");
|
print_usage_line(0, "Usage");
|
||||||
print_usage_line(1, "%.*s %.*s [arguments]", LIT(args[0]), LIT(command));
|
print_usage_line(1, "%.*s %.*s [arguments]", LIT(arg0), LIT(command));
|
||||||
print_usage_line(0, "");
|
print_usage_line(0, "");
|
||||||
|
|
||||||
if (command == "build") {
|
if (command == "build") {
|
||||||
@@ -1173,6 +1073,110 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
print_usage_line(0, "");
|
print_usage_line(0, "");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int arg_count, char const **arg_ptr) {
|
||||||
|
if (arg_count < 2) {
|
||||||
|
usage(make_string_c(arg_ptr[0]));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timings *timings = &global_timings;
|
||||||
|
|
||||||
|
timings_init(timings, str_lit("Total Time"), 128);
|
||||||
|
defer (timings_destroy(timings));
|
||||||
|
|
||||||
|
init_string_buffer_memory();
|
||||||
|
init_global_error_collector();
|
||||||
|
global_big_int_init();
|
||||||
|
arena_init(&global_ast_arena, heap_allocator());
|
||||||
|
|
||||||
|
array_init(&library_collections, heap_allocator());
|
||||||
|
// NOTE(bill): 'core' cannot be (re)defined by the user
|
||||||
|
add_library_collection(str_lit("core"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("core")));
|
||||||
|
|
||||||
|
map_init(&build_context.defined_values, heap_allocator());
|
||||||
|
|
||||||
|
Array<String> args = setup_args(arg_count, arg_ptr);
|
||||||
|
|
||||||
|
String command = args[1];
|
||||||
|
String init_filename = {};
|
||||||
|
String run_args_string = {};
|
||||||
|
|
||||||
|
bool run_output = false;
|
||||||
|
if (command == "run") {
|
||||||
|
if (args.count < 3) {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
|
||||||
|
defer (array_free(&run_args));
|
||||||
|
|
||||||
|
isize last_non_run_arg = args.count;
|
||||||
|
for_array(i, args) {
|
||||||
|
if (args[i] == "--") {
|
||||||
|
last_non_run_arg = i;
|
||||||
|
}
|
||||||
|
if (i <= last_non_run_arg) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
array_add(&run_args, args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
args = array_slice(args, 0, last_non_run_arg);
|
||||||
|
run_args_string = string_join_and_quote(heap_allocator(), run_args);
|
||||||
|
init_filename = args[2];
|
||||||
|
run_output = true;
|
||||||
|
} else if (command == "build") {
|
||||||
|
if (args.count < 3) {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
init_filename = args[2];
|
||||||
|
} else if (command == "check") {
|
||||||
|
if (args.count < 3) {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
build_context.no_output_files = true;
|
||||||
|
init_filename = args[2];
|
||||||
|
} else if (command == "query") {
|
||||||
|
if (args.count < 3) {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
build_context.no_output_files = true;
|
||||||
|
build_context.query_data_set_settings.ok = true;
|
||||||
|
init_filename = args[2];
|
||||||
|
} else if (command == "docs") {
|
||||||
|
if (args.count < 3) {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_filename = args[2];
|
||||||
|
build_context.generate_docs = true;
|
||||||
|
#if 1
|
||||||
|
print_usage_line(0, "Documentation generation is not yet supported");
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
} else if (command == "version") {
|
||||||
|
gb_printf("%.*s version %.*s\n", LIT(args[0]), LIT(ODIN_VERSION));
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
usage(args[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
build_context.command = command;
|
||||||
|
|
||||||
|
if (!parse_build_flags(args)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (build_context.show_help) {
|
||||||
|
print_show_help(args[0], command);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user