| author | |
| committer | |
| log | 4c0259b107236b39f7b1e8f423d2bf9f48e89b54 |
| tree | 84905cc38d0908fb28c43b9a18295db4e6cbc72c |
| parent | b738cbdc768796b59b19a07a29a95892937d6f11 |
5 files changed, 19 insertions(+), 0 deletions(-)
src/all_types.hpp+2| ... | ... | @@ -1195,6 +1195,8 @@ struct CodeGen { |
| 1195 | 1195 | ZigLLVMDICompileUnit *compile_unit; |
| 1196 | 1196 | |
| 1197 | 1197 | ZigList<Buf *> link_libs; // non-libc link libs |
| 1198 | // add -framework [name] args to linker | |
| 1199 | ZigList<Buf *> darwin_frameworks; | |
| 1198 | 1200 | |
| 1199 | 1201 | // reminder: hash tables must be initialized before use |
| 1200 | 1202 | HashMap<Buf *, ImportTableEntry *, buf_hash, buf_eql_buf> import_table; |
src/codegen.cpp+4| ... | ... | @@ -193,6 +193,10 @@ void codegen_add_link_lib(CodeGen *g, const char *lib) { |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | void codegen_add_framework(CodeGen *g, const char *framework) { | |
| 197 | g->darwin_frameworks.append(buf_create_from_str(framework)); | |
| 198 | } | |
| 199 | ||
| 196 | 200 | void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole) { |
| 197 | 201 | g->windows_subsystem_windows = mwindows; |
| 198 | 202 | g->windows_subsystem_console = mconsole; |
src/codegen.hpp+1| ... | ... | @@ -38,6 +38,7 @@ void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole); |
| 38 | 38 | void codegen_set_windows_unicode(CodeGen *g, bool municode); |
| 39 | 39 | void codegen_add_lib_dir(CodeGen *codegen, const char *dir); |
| 40 | 40 | void codegen_add_link_lib(CodeGen *codegen, const char *lib); |
| 41 | void codegen_add_framework(CodeGen *codegen, const char *name); | |
| 41 | 42 | void codegen_set_mlinker_version(CodeGen *g, Buf *darwin_linker_version); |
| 42 | 43 | void codegen_set_rdynamic(CodeGen *g, bool rdynamic); |
| 43 | 44 | void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min); |
src/link.cpp+5| ... | ... | @@ -671,6 +671,11 @@ static void construct_linker_job_darwin(LinkJob *lj) { |
| 671 | 671 | zig_panic("TODO"); |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | for (int i = 0; i < g->darwin_frameworks.length; i += 1) { | |
| 675 | lj->args.append("-framework"); | |
| 676 | lj->args.append(buf_ptr(g->darwin_frameworks.at(i))); | |
| 677 | } | |
| 678 | ||
| 674 | 679 | } |
| 675 | 680 | |
| 676 | 681 | static void construct_linker_job(LinkJob *lj) { |
src/main.cpp+7| ... | ... | @@ -53,6 +53,7 @@ static int usage(const char *arg0) { |
| 53 | 53 | " -rdynamic add all symbols to the dynamic symbol table\n" |
| 54 | 54 | " -mmacosx-version-min [ver] (darwin only) set Mac OS X deployment target\n" |
| 55 | 55 | " -mios-version-min [ver] (darwin only) set iOS deployment target\n" |
| 56 | " -framework [name] (darwin only) link against framework\n" | |
| 56 | 57 | " --check-unused perform semantic analysis on unused declarations\n" |
| 57 | 58 | , arg0); |
| 58 | 59 | return EXIT_FAILURE; |
| ... | ... | @@ -125,6 +126,7 @@ int main(int argc, char **argv) { |
| 125 | 126 | ZigList<const char *> clang_argv = {0}; |
| 126 | 127 | ZigList<const char *> lib_dirs = {0}; |
| 127 | 128 | ZigList<const char *> link_libs = {0}; |
| 129 | ZigList<const char *> frameworks = {0}; | |
| 128 | 130 | int err; |
| 129 | 131 | const char *target_arch = nullptr; |
| 130 | 132 | const char *target_os = nullptr; |
| ... | ... | @@ -226,6 +228,8 @@ int main(int argc, char **argv) { |
| 226 | 228 | mmacosx_version_min = argv[i]; |
| 227 | 229 | } else if (strcmp(arg, "-mios-version-min") == 0) { |
| 228 | 230 | mios_version_min = argv[i]; |
| 231 | } else if (strcmp(arg, "-framework") == 0) { | |
| 232 | frameworks.append(argv[i]); | |
| 229 | 233 | } else { |
| 230 | 234 | fprintf(stderr, "Invalid argument: %s\n", arg); |
| 231 | 235 | return usage(arg0); |
| ... | ... | @@ -377,6 +381,9 @@ int main(int argc, char **argv) { |
| 377 | 381 | for (int i = 0; i < link_libs.length; i += 1) { |
| 378 | 382 | codegen_add_link_lib(g, link_libs.at(i)); |
| 379 | 383 | } |
| 384 | for (int i = 0; i < frameworks.length; i += 1) { | |
| 385 | codegen_add_framework(g, frameworks.at(i)); | |
| 386 | } | |
| 380 | 387 | |
| 381 | 388 | codegen_set_windows_subsystem(g, mwindows, mconsole); |
| 382 | 389 | codegen_set_windows_unicode(g, municode); |