aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-02-07 17:15:59 +0000
committergingerBill <bill@gingerbill.org>2024-02-07 17:15:59 +0000
commita08250ac5b88068cf928552e2628d1e3c7ade95c (patch)
treee8dddf143a8c240401402e76719b3a4ed9ba5f05 /src/main.cpp
parentabaa906f34dbf81f5abe275b34fc8ef7a0bf9b3d (diff)
Improve error handling for missing library collection provided by the compiler
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1136db62a..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);
@@ -2581,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);