flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.
* stage2: fix cleanup bug when creating Module
* flatten lib/std/special/* to lib/*
- this was motivated by making main_pkg_is_inside_std false for
compiler_rt & friends.
* rename "mini libc" to "universal libc"
This commit is contained in:
@@ -10088,7 +10088,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
|
||||
}
|
||||
|
||||
static ZigPackage *create_test_runner_pkg(CodeGen *g) {
|
||||
return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "test_runner.zig", "std.special");
|
||||
return codegen_create_package(g, buf_ptr(g->zig_lib_dir), "test_runner.zig", "");
|
||||
}
|
||||
|
||||
static Error define_builtin_compile_vars(CodeGen *g) {
|
||||
@@ -10141,12 +10141,17 @@ static Error define_builtin_compile_vars(CodeGen *g) {
|
||||
} else {
|
||||
g->root_pkg = g->main_pkg;
|
||||
}
|
||||
|
||||
ZigPackage *compiler_rt_pkg = codegen_create_package(g, buf_ptr(g->zig_lib_dir),
|
||||
"compiler_rt.zig", "compiler_rt");
|
||||
|
||||
g->compile_var_package->package_table.put(buf_create_from_str("std"), g->std_package);
|
||||
g->main_pkg->package_table.put(buf_create_from_str("builtin"), g->compile_var_package);
|
||||
g->main_pkg->package_table.put(buf_create_from_str("root"), g->root_pkg);
|
||||
g->std_package->package_table.put(buf_create_from_str("builtin"), g->compile_var_package);
|
||||
g->std_package->package_table.put(buf_create_from_str("std"), g->std_package);
|
||||
g->std_package->package_table.put(buf_create_from_str("root"), g->root_pkg);
|
||||
g->std_package->package_table.put(buf_create_from_str("compiler_rt"), compiler_rt_pkg);
|
||||
g->compile_var_import = add_source_file(g, g->compile_var_package, g->builtin_zig_path, contents,
|
||||
SourceKindPkgMain);
|
||||
|
||||
@@ -10454,11 +10459,11 @@ static void gen_root_source(CodeGen *g) {
|
||||
Buf *import_target_path;
|
||||
Buf full_path = BUF_INIT;
|
||||
ZigType *compiler_rt_import;
|
||||
if ((err = analyze_import(g, std_import, buf_create_from_str("./special/compiler_rt.zig"),
|
||||
if ((err = analyze_import(g, std_import, buf_create_from_str("compiler_rt"),
|
||||
&compiler_rt_import, &import_target_path, &full_path)))
|
||||
{
|
||||
if (err == ErrorFileNotFound) {
|
||||
fprintf(stderr, "unable to find '%s'", buf_ptr(import_target_path));
|
||||
fprintf(stderr, "unable to find '%s'\n", buf_ptr(import_target_path));
|
||||
} else {
|
||||
fprintf(stderr, "unable to open '%s': %s\n", buf_ptr(&full_path), err_str(err));
|
||||
}
|
||||
@@ -10538,11 +10543,11 @@ void codegen_build_object(CodeGen *g) {
|
||||
fprintf(stderr, "Unable to create directory %s: %s\n", buf_ptr(doc_dir_path), err_str(err));
|
||||
exit(1);
|
||||
}
|
||||
Buf *index_html_src_path = buf_sprintf("%s" OS_SEP "special" OS_SEP "docs" OS_SEP "index.html",
|
||||
buf_ptr(g->zig_std_dir));
|
||||
Buf *index_html_src_path = buf_sprintf("%s" OS_SEP "docs" OS_SEP "index.html",
|
||||
buf_ptr(g->zig_lib_dir));
|
||||
Buf *index_html_dest_path = buf_sprintf("%s" OS_SEP "index.html", buf_ptr(doc_dir_path));
|
||||
Buf *main_js_src_path = buf_sprintf("%s" OS_SEP "special" OS_SEP "docs" OS_SEP "main.js",
|
||||
buf_ptr(g->zig_std_dir));
|
||||
Buf *main_js_src_path = buf_sprintf("%s" OS_SEP "docs" OS_SEP "main.js",
|
||||
buf_ptr(g->zig_lib_dir));
|
||||
Buf *main_js_dest_path = buf_sprintf("%s" OS_SEP "main.js", buf_ptr(doc_dir_path));
|
||||
|
||||
if ((err = os_copy_file(index_html_src_path, index_html_dest_path))) {
|
||||
@@ -10702,9 +10707,6 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
|
||||
g->main_pkg = new_package(".", "", "");
|
||||
}
|
||||
|
||||
g->zig_std_special_dir = buf_alloc();
|
||||
os_path_join(g->zig_std_dir, buf_sprintf("special"), g->zig_std_special_dir);
|
||||
|
||||
target_triple_llvm(&g->llvm_triple_str, g->zig_target);
|
||||
g->pointer_size_bytes = target_arch_pointer_bit_width(g->zig_target->arch) / 8;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user