Browse Source

Move `core:runtime` to `base:runtime`; keep alias around

gingerBill 1 year ago
parent
commit
09fa1c29cd
42 changed files with 54 additions and 7 deletions
  1. 0 0
      base/runtime/core.odin
  2. 0 0
      base/runtime/core_builtin.odin
  3. 0 0
      base/runtime/core_builtin_matrix.odin
  4. 0 0
      base/runtime/core_builtin_soa.odin
  5. 0 0
      base/runtime/default_allocators_arena.odin
  6. 0 0
      base/runtime/default_allocators_general.odin
  7. 0 0
      base/runtime/default_allocators_js.odin
  8. 0 0
      base/runtime/default_allocators_nil.odin
  9. 0 0
      base/runtime/default_allocators_wasi.odin
  10. 0 0
      base/runtime/default_allocators_windows.odin
  11. 0 0
      base/runtime/default_temporary_allocator.odin
  12. 0 0
      base/runtime/docs.odin
  13. 0 0
      base/runtime/dynamic_array_internal.odin
  14. 0 0
      base/runtime/dynamic_map_internal.odin
  15. 0 0
      base/runtime/entry_unix.odin
  16. 0 0
      base/runtime/entry_unix_no_crt_amd64.asm
  17. 0 0
      base/runtime/entry_unix_no_crt_darwin_arm64.asm
  18. 0 0
      base/runtime/entry_unix_no_crt_i386.asm
  19. 0 0
      base/runtime/entry_wasm.odin
  20. 0 0
      base/runtime/entry_windows.odin
  21. 0 0
      base/runtime/error_checks.odin
  22. 0 0
      base/runtime/internal.odin
  23. 0 0
      base/runtime/os_specific.odin
  24. 0 0
      base/runtime/os_specific_any.odin
  25. 0 0
      base/runtime/os_specific_darwin.odin
  26. 0 0
      base/runtime/os_specific_freestanding.odin
  27. 0 0
      base/runtime/os_specific_js.odin
  28. 0 0
      base/runtime/os_specific_wasi.odin
  29. 0 0
      base/runtime/os_specific_windows.odin
  30. 0 0
      base/runtime/print.odin
  31. 0 0
      base/runtime/procs.odin
  32. 0 0
      base/runtime/procs_darwin.odin
  33. 0 0
      base/runtime/procs_js.odin
  34. 0 0
      base/runtime/procs_wasm.odin
  35. 0 0
      base/runtime/procs_windows_amd64.asm
  36. 0 0
      base/runtime/procs_windows_amd64.odin
  37. 0 0
      base/runtime/procs_windows_i386.odin
  38. 0 0
      base/runtime/udivmod128.odin
  39. 21 1
      src/build_settings.cpp
  40. 25 3
      src/checker.cpp
  41. 1 0
      src/main.cpp
  42. 7 3
      src/parser.cpp

+ 0 - 0
core/runtime/core.odin → base/runtime/core.odin


+ 0 - 0
core/runtime/core_builtin.odin → base/runtime/core_builtin.odin


+ 0 - 0
core/runtime/core_builtin_matrix.odin → base/runtime/core_builtin_matrix.odin


+ 0 - 0
core/runtime/core_builtin_soa.odin → base/runtime/core_builtin_soa.odin


+ 0 - 0
core/runtime/default_allocators_arena.odin → base/runtime/default_allocators_arena.odin


+ 0 - 0
core/runtime/default_allocators_general.odin → base/runtime/default_allocators_general.odin


+ 0 - 0
core/runtime/default_allocators_js.odin → base/runtime/default_allocators_js.odin


+ 0 - 0
core/runtime/default_allocators_nil.odin → base/runtime/default_allocators_nil.odin


+ 0 - 0
core/runtime/default_allocators_wasi.odin → base/runtime/default_allocators_wasi.odin


+ 0 - 0
core/runtime/default_allocators_windows.odin → base/runtime/default_allocators_windows.odin


+ 0 - 0
core/runtime/default_temporary_allocator.odin → base/runtime/default_temporary_allocator.odin


+ 0 - 0
core/runtime/docs.odin → base/runtime/docs.odin


+ 0 - 0
core/runtime/dynamic_array_internal.odin → base/runtime/dynamic_array_internal.odin


+ 0 - 0
core/runtime/dynamic_map_internal.odin → base/runtime/dynamic_map_internal.odin


+ 0 - 0
core/runtime/entry_unix.odin → base/runtime/entry_unix.odin


+ 0 - 0
core/runtime/entry_unix_no_crt_amd64.asm → base/runtime/entry_unix_no_crt_amd64.asm


+ 0 - 0
core/runtime/entry_unix_no_crt_darwin_arm64.asm → base/runtime/entry_unix_no_crt_darwin_arm64.asm


+ 0 - 0
core/runtime/entry_unix_no_crt_i386.asm → base/runtime/entry_unix_no_crt_i386.asm


+ 0 - 0
core/runtime/entry_wasm.odin → base/runtime/entry_wasm.odin


+ 0 - 0
core/runtime/entry_windows.odin → base/runtime/entry_windows.odin


+ 0 - 0
core/runtime/error_checks.odin → base/runtime/error_checks.odin


+ 0 - 0
core/runtime/internal.odin → base/runtime/internal.odin


+ 0 - 0
core/runtime/os_specific.odin → base/runtime/os_specific.odin


+ 0 - 0
core/runtime/os_specific_any.odin → base/runtime/os_specific_any.odin


+ 0 - 0
core/runtime/os_specific_darwin.odin → base/runtime/os_specific_darwin.odin


+ 0 - 0
core/runtime/os_specific_freestanding.odin → base/runtime/os_specific_freestanding.odin


+ 0 - 0
core/runtime/os_specific_js.odin → base/runtime/os_specific_js.odin


+ 0 - 0
core/runtime/os_specific_wasi.odin → base/runtime/os_specific_wasi.odin


+ 0 - 0
core/runtime/os_specific_windows.odin → base/runtime/os_specific_windows.odin


+ 0 - 0
core/runtime/print.odin → base/runtime/print.odin


+ 0 - 0
core/runtime/procs.odin → base/runtime/procs.odin


+ 0 - 0
core/runtime/procs_darwin.odin → base/runtime/procs_darwin.odin


+ 0 - 0
core/runtime/procs_js.odin → base/runtime/procs_js.odin


+ 0 - 0
core/runtime/procs_wasm.odin → base/runtime/procs_wasm.odin


+ 0 - 0
core/runtime/procs_windows_amd64.asm → base/runtime/procs_windows_amd64.asm


+ 0 - 0
core/runtime/procs_windows_amd64.odin → base/runtime/procs_windows_amd64.odin


+ 0 - 0
core/runtime/procs_windows_i386.odin → base/runtime/procs_windows_i386.odin


+ 0 - 0
core/runtime/udivmod128.odin → base/runtime/udivmod128.odin


+ 21 - 1
src/build_settings.cpp

@@ -1161,7 +1161,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 module_dir = odin_root_dir();
 
 
 	String core = str_lit("core/");
 	String core = str_lit("core/");

+ 25 - 3
src/checker.cpp

@@ -770,15 +770,17 @@ gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *
 	rw_mutex_unlock(&d->type_info_deps_mutex);
 	rw_mutex_unlock(&d->type_info_deps_mutex);
 }
 }
 
 
-gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) {
+
+gb_internal AstPackage *get_runtime_package(CheckerInfo *info) {
+	String name = str_lit("runtime");
 	gbAllocator a = heap_allocator();
 	gbAllocator a = heap_allocator();
-	String path = get_fullpath_core(a, name);
+	String path = get_fullpath_base_collection(a, name);
 	defer (gb_free(a, path.text));
 	defer (gb_free(a, path.text));
 	auto found = string_map_get(&info->packages, path);
 	auto found = string_map_get(&info->packages, path);
 	if (found == nullptr) {
 	if (found == nullptr) {
 		gb_printf_err("Name: %.*s\n", LIT(name));
 		gb_printf_err("Name: %.*s\n", LIT(name));
 		gb_printf_err("Fullpath: %.*s\n", LIT(path));
 		gb_printf_err("Fullpath: %.*s\n", LIT(path));
-		
+
 		for (auto const &entry : info->packages) {
 		for (auto const &entry : info->packages) {
 			gb_printf_err("%.*s\n", LIT(entry.key));
 			gb_printf_err("%.*s\n", LIT(entry.key));
 		}
 		}
@@ -787,6 +789,26 @@ gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) {
 	return *found;
 	return *found;
 }
 }
 
 
+gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) {
+	if (name == "runtime") {
+		return get_runtime_package(info);
+	}
+
+	gbAllocator a = heap_allocator();
+	String path = get_fullpath_core_collection(a, name);
+	defer (gb_free(a, path.text));
+	auto found = string_map_get(&info->packages, path);
+	if (found == nullptr) {
+		gb_printf_err("Name: %.*s\n", LIT(name));
+		gb_printf_err("Fullpath: %.*s\n", LIT(path));
+
+		for (auto const &entry : info->packages) {
+			gb_printf_err("%.*s\n", LIT(entry.key));
+		}
+		GB_ASSERT_MSG(found != nullptr, "Missing core package %.*s", LIT(name));
+	}
+	return *found;
+}
 
 
 gb_internal void add_package_dependency(CheckerContext *c, char const *package_name, char const *name) {
 gb_internal void add_package_dependency(CheckerContext *c, char const *package_name, char const *name) {
 	String n = make_string_c(name);
 	String n = make_string_c(name);

+ 1 - 0
src/main.cpp

@@ -2376,6 +2376,7 @@ int main(int arg_count, char const **arg_ptr) {
 	TIME_SECTION("init default library collections");
 	TIME_SECTION("init default library collections");
 	array_init(&library_collections, heap_allocator());
 	array_init(&library_collections, heap_allocator());
 	// NOTE(bill): 'core' cannot be (re)defined by the user
 	// 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("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")));
 	add_library_collection(str_lit("vendor"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("vendor")));
 
 

+ 7 - 3
src/parser.cpp

@@ -5460,6 +5460,11 @@ gb_internal bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node
 
 
 
 
 	if (collection_name.len > 0) {
 	if (collection_name.len > 0) {
+		// NOTE(bill): `base:runtime` == `core:runtime`
+		if (collection_name == "core" && string_starts_with(file_str, str_lit("runtime"))) {
+			collection_name = str_lit("base");
+		}
+
 		if (collection_name == "system") {
 		if (collection_name == "system") {
 			if (node->kind != Ast_ForeignImportDecl) {
 			if (node->kind != Ast_ForeignImportDecl) {
 				syntax_error(node, "The library collection 'system' is restrict for 'foreign_library'");
 				syntax_error(node, "The library collection 'system' is restrict for 'foreign_library'");
@@ -5489,7 +5494,6 @@ gb_internal bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node
 #endif
 #endif
 	}
 	}
 
 
-
 	if (is_package_name_reserved(file_str)) {
 	if (is_package_name_reserved(file_str)) {
 		*path = file_str;
 		*path = file_str;
 		if (collection_name == "core") {
 		if (collection_name == "core") {
@@ -6133,7 +6137,7 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) {
 	{ // Add these packages serially and then process them parallel
 	{ // Add these packages serially and then process them parallel
 		TokenPos init_pos = {};
 		TokenPos init_pos = {};
 		{
 		{
-			String s = get_fullpath_core(permanent_allocator(), str_lit("runtime"));
+			String s = get_fullpath_base_collection(permanent_allocator(), str_lit("runtime"));
 			try_add_import_path(p, s, s, init_pos, Package_Runtime);
 			try_add_import_path(p, s, s, init_pos, Package_Runtime);
 		}
 		}
 
 
@@ -6141,7 +6145,7 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) {
 		p->init_fullpath = init_fullpath;
 		p->init_fullpath = init_fullpath;
 
 
 		if (build_context.command_kind == Command_test) {
 		if (build_context.command_kind == Command_test) {
-			String s = get_fullpath_core(permanent_allocator(), str_lit("testing"));
+			String s = get_fullpath_core_collection(permanent_allocator(), str_lit("testing"));
 			try_add_import_path(p, s, s, init_pos, Package_Normal);
 			try_add_import_path(p, s, s, init_pos, Package_Normal);
 		}
 		}