| ... | ... | @@ -180,6 +180,8 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget |
| 180 | 180 | g->root_package = new_package(".", "", ""); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | g->root_package->package_table.put(buf_create_from_str("root"), g->root_package); |
| 184 | |
| 183 | 185 | g->zig_std_special_dir = buf_alloc(); |
| 184 | 186 | os_path_join(g->zig_std_dir, buf_sprintf("special"), g->zig_std_special_dir); |
| 185 | 187 | |
| ... | ... | @@ -8053,6 +8055,8 @@ static Error define_builtin_compile_vars(CodeGen *g) { |
| 8053 | 8055 | g->root_package->package_table.put(buf_create_from_str("builtin"), g->compile_var_package); |
| 8054 | 8056 | g->std_package->package_table.put(buf_create_from_str("builtin"), g->compile_var_package); |
| 8055 | 8057 | g->std_package->package_table.put(buf_create_from_str("std"), g->std_package); |
| 8058 | g->std_package->package_table.put(buf_create_from_str("root"), |
| 8059 | g->is_test_build ? g->test_runner_package : g->root_package); |
| 8056 | 8060 | g->compile_var_import = add_source_file(g, g->compile_var_package, builtin_zig_path, contents, |
| 8057 | 8061 | SourceKindPkgMain); |
| 8058 | 8062 | |
| ... | ... | @@ -8522,7 +8526,7 @@ static ZigType *add_special_code(CodeGen *g, ZigPackage *package, const char *ba |
| 8522 | 8526 | |
| 8523 | 8527 | static ZigPackage *create_bootstrap_pkg(CodeGen *g, ZigPackage *pkg_with_main) { |
| 8524 | 8528 | ZigPackage *package = codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "bootstrap.zig", "std.special"); |
| 8525 | | package->package_table.put(buf_create_from_str("@root"), pkg_with_main); |
| 8529 | package->package_table.put(buf_create_from_str("root"), pkg_with_main); |
| 8526 | 8530 | return package; |
| 8527 | 8531 | } |
| 8528 | 8532 | |
| ... | ... | @@ -9375,6 +9379,7 @@ void codegen_add_time_event(CodeGen *g, const char *name) { |
| 9375 | 9379 | static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) { |
| 9376 | 9380 | if (buf_len(&pkg->root_src_path) == 0) |
| 9377 | 9381 | return; |
| 9382 | pkg->added_to_cache = true; |
| 9378 | 9383 | |
| 9379 | 9384 | Buf *rel_full_path = buf_alloc(); |
| 9380 | 9385 | os_path_join(&pkg->root_src_dir, &pkg->root_src_path, rel_full_path); |
| ... | ... | @@ -9386,9 +9391,7 @@ static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) { |
| 9386 | 9391 | if (!entry) |
| 9387 | 9392 | break; |
| 9388 | 9393 | |
| 9389 | | // TODO: I think we need a more sophisticated detection of |
| 9390 | | // packages we have already seen |
| 9391 | | if (entry->value != pkg) { |
| 9394 | if (!pkg->added_to_cache) { |
| 9392 | 9395 | cache_buf(ch, entry->key); |
| 9393 | 9396 | add_cache_pkg(g, ch, entry->value); |
| 9394 | 9397 | } |
| ... | ... | @@ -9645,6 +9648,10 @@ ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const c |
| 9645 | 9648 | if (g->std_package != nullptr) { |
| 9646 | 9649 | assert(g->compile_var_package != nullptr); |
| 9647 | 9650 | pkg->package_table.put(buf_create_from_str("std"), g->std_package); |
| 9651 | |
| 9652 | ZigPackage *main_pkg = g->is_test_build ? g->test_runner_package : g->root_package; |
| 9653 | pkg->package_table.put(buf_create_from_str("root"), main_pkg); |
| 9654 | |
| 9648 | 9655 | pkg->package_table.put(buf_create_from_str("builtin"), g->compile_var_package); |
| 9649 | 9656 | } |
| 9650 | 9657 | return pkg; |