aboutsummaryrefslogtreecommitdiff
path: root/src/build_settings.cpp
diff options
context:
space:
mode:
authormarcs feh <82233333+marcs-feh@users.noreply.github.com>2024-02-02 21:56:40 -0300
committerGitHub <noreply@github.com>2024-02-02 21:56:40 -0300
commitfc113315f6ccd5d58652e8d2f326ed150e74adf1 (patch)
tree00c4df54de73cb2bf0a344e02e64b7fcb3df3768 /src/build_settings.cpp
parentd931bfcf83894b65d6db3bc846110efb400ab4a1 (diff)
parentcec08114fdd9812819c10c66cd10f0a9d63866b2 (diff)
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src/build_settings.cpp')
-rw-r--r--src/build_settings.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp
index af518bcb4..374ecbdfa 100644
--- a/src/build_settings.cpp
+++ b/src/build_settings.cpp
@@ -323,6 +323,7 @@ struct BuildContext {
bool ODIN_DEBUG; // Odin in debug mode
bool ODIN_DISABLE_ASSERT; // Whether the default 'assert' et al is disabled in code or not
bool ODIN_DEFAULT_TO_NIL_ALLOCATOR; // Whether the default allocator is a "nil" allocator or not (i.e. it does nothing)
+ bool ODIN_DEFAULT_TO_PANIC_ALLOCATOR; // Whether the default allocator is a "panic" allocator or not (i.e. panics on any call to it)
bool ODIN_FOREIGN_ERROR_PROCEDURES;
bool ODIN_VALGRIND_SUPPORT;
@@ -422,6 +423,7 @@ struct BuildContext {
Array<String> extra_packages;
StringSet test_names;
+ bool test_all_packages;
gbAffinity affinity;
isize thread_count;
@@ -1161,7 +1163,27 @@ gb_internal String get_fullpath_relative(gbAllocator a, String base_dir, String
}
-gb_internal String get_fullpath_core(gbAllocator a, String path) {
+gb_internal String get_fullpath_base_collection(gbAllocator a, String path) {
+ String module_dir = odin_root_dir();
+
+ String base = str_lit("base/");
+
+ isize str_len = module_dir.len + base.len + path.len;
+ u8 *str = gb_alloc_array(heap_allocator(), u8, str_len+1);
+ defer (gb_free(heap_allocator(), str));
+
+ isize i = 0;
+ gb_memmove(str+i, module_dir.text, module_dir.len); i += module_dir.len;
+ gb_memmove(str+i, base.text, base.len); i += base.len;
+ gb_memmove(str+i, path.text, path.len); i += path.len;
+ str[i] = 0;
+
+ String res = make_string(str, i);
+ res = string_trim_whitespace(res);
+ return path_to_fullpath(a, res);
+}
+
+gb_internal String get_fullpath_core_collection(gbAllocator a, String path) {
String module_dir = odin_root_dir();
String core = str_lit("core/");
@@ -1454,6 +1476,16 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
break;
}
}
+
+ if (bc->metrics.os == TargetOs_freestanding) {
+ bc->ODIN_DEFAULT_TO_NIL_ALLOCATOR = !bc->ODIN_DEFAULT_TO_PANIC_ALLOCATOR;
+ } else if (is_arch_wasm()) {
+ if (bc->metrics.os == TargetOs_js || bc->metrics.os == TargetOs_wasi) {
+ // TODO(bill): Should these even have a default "heap-like" allocator?
+ }
+ bc->ODIN_DEFAULT_TO_PANIC_ALLOCATOR = true;
+ bc->ODIN_DEFAULT_TO_NIL_ALLOCATOR = !bc->ODIN_DEFAULT_TO_PANIC_ALLOCATOR;
+ }
}
#if defined(GB_SYSTEM_WINDOWS)
@@ -1588,8 +1620,8 @@ gb_internal bool init_build_paths(String init_filename) {
produces_output_file = true;
}
-
- if (build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR) {
+ if (build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR ||
+ build_context.ODIN_DEFAULT_TO_PANIC_ALLOCATOR) {
bc->no_dynamic_literals = true;
}