authorgravatar for jmi2k@openmailbox.orgJosé Miguel Sánchez <jmi2k@openmailbox.org> 2016-05-12 18:41:20+02:00
committergravatar for jmi2k@openmailbox.orgJosé Miguel Sánchez <jmi2k@openmailbox.org> 2016-05-12 18:41:20+02:00
loga1817f462a06cca5cb25609b892dbff73db8a938
tree46f281e9b2e22e7ee53a9bc3799f575ad77efa36
parent1eafc85f1f0643ca2594247615a14b7a34343a14

Add --zig-std-dir


5 files changed, 18 insertions(+), 3 deletions(-)

src/all_types.hpp+1
......@@ -1220,6 +1220,7 @@ struct CodeGen {
12201220 Buf *libc_lib_dir;
12211221 Buf *libc_static_lib_dir;
12221222 Buf *libc_include_dir;
1223 Buf *zig_std_dir;
12231224 Buf *dynamic_linker;
12241225 Buf *linker_path;
12251226 Buf *ar_path;
src/codegen.cpp+9-2
......@@ -84,6 +84,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
8484 g->libc_lib_dir = buf_create_from_str("");
8585 g->libc_static_lib_dir = buf_create_from_str("");
8686 g->libc_include_dir = buf_create_from_str("");
87 g->zig_std_dir = buf_create_from_str("");
8788 g->linker_path = buf_create_from_str("");
8889 g->ar_path = buf_create_from_str("");
8990 g->darwin_linker_version = buf_create_from_str("");
......@@ -96,6 +97,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
9697 g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR);
9798 g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR);
9899 g->libc_include_dir = buf_create_from_str(ZIG_LIBC_INCLUDE_DIR);
100 g->zig_std_dir = buf_create_from_str(ZIG_STD_DIR);
99101 g->linker_path = buf_create_from_str(ZIG_LD_PATH);
100102 g->ar_path = buf_create_from_str(ZIG_AR_PATH);
101103 g->darwin_linker_version = buf_create_from_str(ZIG_HOST_LINK_VERSION);
......@@ -165,6 +167,11 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) {
165167 g->libc_include_dir = libc_include_dir;
166168}
167169
170void codegen_set_zig_std_dir(CodeGen *g, Buf *zig_std_dir) {
171 g->zig_std_dir = zig_std_dir;
172 g->std_package->root_src_dir = *zig_std_dir;
173}
174
168175void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker) {
169176 g->dynamic_linker = dynamic_linker;
170177}
......@@ -4752,7 +4759,7 @@ void codegen_render_ast(CodeGen *g, FILE *f, int indent_size) {
47524759
47534760
47544761static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package, const char *basename) {
4755 Buf *std_dir = buf_create_from_str(ZIG_STD_DIR);
4762 Buf *std_dir = g->zig_std_dir;
47564763 Buf *code_basename = buf_create_from_str(basename);
47574764 Buf path_to_code_src = BUF_INIT;
47584765 os_path_join(std_dir, code_basename, &path_to_code_src);
......@@ -4770,7 +4777,7 @@ static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package
47704777}
47714778
47724779static PackageTableEntry *create_bootstrap_pkg(CodeGen *g) {
4773 PackageTableEntry *package = new_package(ZIG_STD_DIR, "");
4780 PackageTableEntry *package = new_package(buf_ptr(g->zig_std_dir), "");
47744781 package->package_table.put(buf_create_from_str("std"), g->std_package);
47754782 package->package_table.put(buf_create_from_str("@root"), g->root_package);
47764783 return package;
src/codegen.hpp+1
......@@ -30,6 +30,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name);
3030void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir);
3131void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir);
3232void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir);
33void codegen_set_zig_std_dir(CodeGen *codegen, Buf *zig_std_dir);
3334void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker);
3435void codegen_set_linker_path(CodeGen *g, Buf *linker_path);
3536void codegen_set_ar_path(CodeGen *g, Buf *ar_path);
src/link.cpp+1-1
......@@ -33,7 +33,7 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) {
3333
3434static Buf *build_o(CodeGen *parent_gen, const char *oname) {
3535 Buf *source_basename = buf_sprintf("%s.zig", oname);
36 Buf *std_dir_path = buf_create_from_str(ZIG_STD_DIR);
36 Buf *std_dir_path = parent_gen->zig_std_dir;
3737
3838 ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
3939 CodeGen *child_gen = codegen_create(std_dir_path, child_target);
src/main.cpp+6
......@@ -35,6 +35,7 @@ static int usage(const char *arg0) {
3535 " --libc-lib-dir [path] directory where libc crt1.o resides\n"
3636 " --libc-static-lib-dir [path] directory where libc crtbegin.o resides\n"
3737 " --libc-include-dir [path] directory where libc stdlib.h resides\n"
38 " --zig-std-dir [path] directory where zig standard library resides\n"
3839 " --dynamic-linker [path] set the path to ld.so\n"
3940 " --ld-path [path] set the path to the linker\n"
4041 " --ar-path [path] set the path to ar\n"
......@@ -117,6 +118,7 @@ int main(int argc, char **argv) {
117118 const char *libc_lib_dir = nullptr;
118119 const char *libc_static_lib_dir = nullptr;
119120 const char *libc_include_dir = nullptr;
121 const char *zig_std_dir = nullptr;
120122 const char *dynamic_linker = nullptr;
121123 const char *linker_path = nullptr;
122124 const char *ar_path = nullptr;
......@@ -194,6 +196,8 @@ int main(int argc, char **argv) {
194196 libc_static_lib_dir = argv[i];
195197 } else if (strcmp(arg, "--libc-include-dir") == 0) {
196198 libc_include_dir = argv[i];
199 } else if (strcmp(arg, "--zig-std-dir") == 0) {
200 zig_std_dir = argv[i];
197201 } else if (strcmp(arg, "--dynamic-linker") == 0) {
198202 dynamic_linker = argv[i];
199203 } else if (strcmp(arg, "--ld-path") == 0) {
......@@ -356,6 +360,8 @@ int main(int argc, char **argv) {
356360 codegen_set_libc_static_lib_dir(g, buf_create_from_str(libc_static_lib_dir));
357361 if (libc_include_dir)
358362 codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir));
363 if (zig_std_dir)
364 codegen_set_zig_std_dir(g, buf_create_from_str(zig_std_dir));
359365 if (dynamic_linker)
360366 codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker));
361367 if (linker_path)