mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 17:12:31 +00:00
ability to specify -framework linker args for MacOS
This commit is contained in:
parent
b738cbdc76
commit
4c0259b107
@ -1195,6 +1195,8 @@ struct CodeGen {
|
||||
ZigLLVMDICompileUnit *compile_unit;
|
||||
|
||||
ZigList<Buf *> link_libs; // non-libc link libs
|
||||
// add -framework [name] args to linker
|
||||
ZigList<Buf *> darwin_frameworks;
|
||||
|
||||
// reminder: hash tables must be initialized before use
|
||||
HashMap<Buf *, ImportTableEntry *, buf_hash, buf_eql_buf> import_table;
|
||||
|
@ -193,6 +193,10 @@ void codegen_add_link_lib(CodeGen *g, const char *lib) {
|
||||
}
|
||||
}
|
||||
|
||||
void codegen_add_framework(CodeGen *g, const char *framework) {
|
||||
g->darwin_frameworks.append(buf_create_from_str(framework));
|
||||
}
|
||||
|
||||
void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole) {
|
||||
g->windows_subsystem_windows = mwindows;
|
||||
g->windows_subsystem_console = mconsole;
|
||||
|
@ -38,6 +38,7 @@ void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole);
|
||||
void codegen_set_windows_unicode(CodeGen *g, bool municode);
|
||||
void codegen_add_lib_dir(CodeGen *codegen, const char *dir);
|
||||
void codegen_add_link_lib(CodeGen *codegen, const char *lib);
|
||||
void codegen_add_framework(CodeGen *codegen, const char *name);
|
||||
void codegen_set_mlinker_version(CodeGen *g, Buf *darwin_linker_version);
|
||||
void codegen_set_rdynamic(CodeGen *g, bool rdynamic);
|
||||
void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min);
|
||||
|
@ -671,6 +671,11 @@ static void construct_linker_job_darwin(LinkJob *lj) {
|
||||
zig_panic("TODO");
|
||||
}
|
||||
|
||||
for (int i = 0; i < g->darwin_frameworks.length; i += 1) {
|
||||
lj->args.append("-framework");
|
||||
lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void construct_linker_job(LinkJob *lj) {
|
||||
|
@ -53,6 +53,7 @@ static int usage(const char *arg0) {
|
||||
" -rdynamic add all symbols to the dynamic symbol table\n"
|
||||
" -mmacosx-version-min [ver] (darwin only) set Mac OS X deployment target\n"
|
||||
" -mios-version-min [ver] (darwin only) set iOS deployment target\n"
|
||||
" -framework [name] (darwin only) link against framework\n"
|
||||
" --check-unused perform semantic analysis on unused declarations\n"
|
||||
, arg0);
|
||||
return EXIT_FAILURE;
|
||||
@ -125,6 +126,7 @@ int main(int argc, char **argv) {
|
||||
ZigList<const char *> clang_argv = {0};
|
||||
ZigList<const char *> lib_dirs = {0};
|
||||
ZigList<const char *> link_libs = {0};
|
||||
ZigList<const char *> frameworks = {0};
|
||||
int err;
|
||||
const char *target_arch = nullptr;
|
||||
const char *target_os = nullptr;
|
||||
@ -226,6 +228,8 @@ int main(int argc, char **argv) {
|
||||
mmacosx_version_min = argv[i];
|
||||
} else if (strcmp(arg, "-mios-version-min") == 0) {
|
||||
mios_version_min = argv[i];
|
||||
} else if (strcmp(arg, "-framework") == 0) {
|
||||
frameworks.append(argv[i]);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid argument: %s\n", arg);
|
||||
return usage(arg0);
|
||||
@ -377,6 +381,9 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i < link_libs.length; i += 1) {
|
||||
codegen_add_link_lib(g, link_libs.at(i));
|
||||
}
|
||||
for (int i = 0; i < frameworks.length; i += 1) {
|
||||
codegen_add_framework(g, frameworks.at(i));
|
||||
}
|
||||
|
||||
codegen_set_windows_subsystem(g, mwindows, mconsole);
|
||||
codegen_set_windows_unicode(g, municode);
|
||||
|
Loading…
Reference in New Issue
Block a user