aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authormarcs feh <82233333+marcs-feh@users.noreply.github.com>2024-02-11 23:55:39 +0000
committerGitHub <noreply@github.com>2024-02-11 23:55:39 +0000
commit9c6574e053e9a1c27f2831ed81e56edf9a180a95 (patch)
treed65a1e5927317a9991263ac96d424b70af8a72ea /src/main.cpp
parentfc113315f6ccd5d58652e8d2f326ed150e74adf1 (diff)
parent4ca23499fa9bd59083b1beae6c44b5a5d890fcf2 (diff)
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6a033dd3f..7951ca2db 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -807,9 +807,10 @@ gb_internal bool parse_build_flags(Array<String> args) {
}
gbAllocator a = heap_allocator();
- String fullpath = path_to_fullpath(a, path);
- if (!path_is_directory(fullpath)) {
- gb_printf_err("Library collection '%.*s' path must be a directory, got '%.*s'\n", LIT(name), LIT(fullpath));
+ bool path_ok = false;
+ String fullpath = path_to_fullpath(a, path, &path_ok);
+ if (!path_ok || !path_is_directory(fullpath)) {
+ gb_printf_err("Library collection '%.*s' path must be a directory, got '%.*s'\n", LIT(name), LIT(path_ok ? fullpath : path));
gb_free(a, fullpath.text);
bad_flags = true;
break;
@@ -2395,9 +2396,18 @@ int main(int arg_count, char const **arg_ptr) {
TIME_SECTION("init default library collections");
array_init(&library_collections, heap_allocator());
// NOTE(bill): 'core' cannot be (re)defined by the user
- add_library_collection(str_lit("base"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("base")));
- add_library_collection(str_lit("core"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("core")));
- add_library_collection(str_lit("vendor"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("vendor")));
+
+ auto const &add_collection = [](String const &name) {
+ bool ok = false;
+ add_library_collection(name, get_fullpath_relative(heap_allocator(), odin_root_dir(), name, &ok));
+ if (!ok) {
+ compiler_error("Cannot find the library collection '%.*s'. Is the ODIN_ROOT set up correctly?", LIT(name));
+ }
+ };
+
+ add_collection(str_lit("base"));
+ add_collection(str_lit("core"));
+ add_collection(str_lit("vendor"));
TIME_SECTION("init args");
map_init(&build_context.defined_values);
@@ -2425,14 +2435,18 @@ int main(int arg_count, char const **arg_ptr) {
Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
defer (array_free(&run_args));
+ isize run_args_start_idx = -1;
for_array(i, args) {
if (args[i] == "--") {
- last_non_run_arg = i;
+ run_args_start_idx = i;
+ break;
}
- if (i <= last_non_run_arg) {
- continue;
+ }
+ if(run_args_start_idx != -1) {
+ last_non_run_arg = run_args_start_idx;
+ for(isize i = run_args_start_idx+1; i < args.count; ++i) {
+ array_add(&run_args, args[i]);
}
- array_add(&run_args, args[i]);
}
args = array_slice(args, 0, last_non_run_arg);
@@ -2577,7 +2591,7 @@ int main(int arg_count, char const **arg_ptr) {
// NOTE(bill): add 'shared' directory if it is not already set
if (!find_library_collection_path(str_lit("shared"), nullptr)) {
add_library_collection(str_lit("shared"),
- get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("shared")));
+ get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("shared"), nullptr));
}
init_build_context(selected_target_metrics ? selected_target_metrics->metrics : nullptr, selected_subtarget);