mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 02:33:07 +00:00
add ability to specify darwin framework search dirs
This commit is contained in:
parent
0c4d47c6d5
commit
0fe28855c5
@ -2003,6 +2003,7 @@ struct CodeGen {
|
|||||||
ZigList<Buf *> assembly_files;
|
ZigList<Buf *> assembly_files;
|
||||||
ZigList<CFile *> c_source_files;
|
ZigList<CFile *> c_source_files;
|
||||||
ZigList<const char *> lib_dirs;
|
ZigList<const char *> lib_dirs;
|
||||||
|
ZigList<const char *> framework_dirs;
|
||||||
|
|
||||||
ZigLibCInstallation *libc;
|
ZigLibCInstallation *libc;
|
||||||
|
|
||||||
|
|||||||
@ -9803,6 +9803,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
|
|||||||
cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len);
|
cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len);
|
||||||
cache_list_of_str(ch, g->clang_argv, g->clang_argv_len);
|
cache_list_of_str(ch, g->clang_argv, g->clang_argv_len);
|
||||||
cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length);
|
cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length);
|
||||||
|
cache_list_of_str(ch, g->framework_dirs.items, g->framework_dirs.length);
|
||||||
if (g->libc) {
|
if (g->libc) {
|
||||||
cache_buf(ch, &g->libc->include_dir);
|
cache_buf(ch, &g->libc->include_dir);
|
||||||
cache_buf(ch, &g->libc->sys_include_dir);
|
cache_buf(ch, &g->libc->sys_include_dir);
|
||||||
|
|||||||
@ -2510,6 +2510,12 @@ static void construct_linker_job_macho(LinkJob *lj) {
|
|||||||
lj->args.append("dynamic_lookup");
|
lj->args.append("dynamic_lookup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < g->framework_dirs.length; i += 1) {
|
||||||
|
const char *framework_dir = g->framework_dirs.at(i);
|
||||||
|
lj->args.append("-F");
|
||||||
|
lj->args.append(framework_dir);
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < g->darwin_frameworks.length; i += 1) {
|
for (size_t i = 0; i < g->darwin_frameworks.length; i += 1) {
|
||||||
lj->args.append("-framework");
|
lj->args.append("-framework");
|
||||||
lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));
|
lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));
|
||||||
|
|||||||
@ -104,6 +104,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
|
|||||||
" -rdynamic add all symbols to the dynamic symbol table\n"
|
" -rdynamic add all symbols to the dynamic symbol table\n"
|
||||||
" -rpath [path] add directory to the runtime library search path\n"
|
" -rpath [path] add directory to the runtime library search path\n"
|
||||||
" --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
|
" --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
|
||||||
|
" -F[dir] (darwin) add search path for frameworks\n"
|
||||||
" -framework [name] (darwin) link against framework\n"
|
" -framework [name] (darwin) link against framework\n"
|
||||||
" -mios-version-min [ver] (darwin) set iOS deployment target\n"
|
" -mios-version-min [ver] (darwin) set iOS deployment target\n"
|
||||||
" -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
|
" -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
|
||||||
@ -454,6 +455,7 @@ int main(int argc, char **argv) {
|
|||||||
ZigList<const char *> lib_dirs = {0};
|
ZigList<const char *> lib_dirs = {0};
|
||||||
ZigList<const char *> link_libs = {0};
|
ZigList<const char *> link_libs = {0};
|
||||||
ZigList<const char *> forbidden_link_libs = {0};
|
ZigList<const char *> forbidden_link_libs = {0};
|
||||||
|
ZigList<const char *> framework_dirs = {0};
|
||||||
ZigList<const char *> frameworks = {0};
|
ZigList<const char *> frameworks = {0};
|
||||||
bool have_libc = false;
|
bool have_libc = false;
|
||||||
const char *target_string = nullptr;
|
const char *target_string = nullptr;
|
||||||
@ -686,6 +688,8 @@ int main(int argc, char **argv) {
|
|||||||
} else if (arg[1] == 'L' && arg[2] != 0) {
|
} else if (arg[1] == 'L' && arg[2] != 0) {
|
||||||
// alias for --library-path
|
// alias for --library-path
|
||||||
lib_dirs.append(&arg[2]);
|
lib_dirs.append(&arg[2]);
|
||||||
|
} else if (arg[1] == 'F' && arg[2] != 0) {
|
||||||
|
framework_dirs.append(&arg[2]);
|
||||||
} else if (strcmp(arg, "--pkg-begin") == 0) {
|
} else if (strcmp(arg, "--pkg-begin") == 0) {
|
||||||
if (i + 2 >= argc) {
|
if (i + 2 >= argc) {
|
||||||
fprintf(stderr, "Expected 2 arguments after --pkg-begin\n");
|
fprintf(stderr, "Expected 2 arguments after --pkg-begin\n");
|
||||||
@ -772,6 +776,8 @@ int main(int argc, char **argv) {
|
|||||||
main_pkg_path = buf_create_from_str(argv[i]);
|
main_pkg_path = buf_create_from_str(argv[i]);
|
||||||
} else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) {
|
} else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) {
|
||||||
lib_dirs.append(argv[i]);
|
lib_dirs.append(argv[i]);
|
||||||
|
} else if (strcmp(arg, "-F") == 0) {
|
||||||
|
framework_dirs.append(argv[i]);
|
||||||
} else if (strcmp(arg, "--library") == 0) {
|
} else if (strcmp(arg, "--library") == 0) {
|
||||||
if (strcmp(argv[i], "c") == 0)
|
if (strcmp(argv[i], "c") == 0)
|
||||||
have_libc = true;
|
have_libc = true;
|
||||||
@ -1153,6 +1159,9 @@ int main(int argc, char **argv) {
|
|||||||
for (size_t i = 0; i < lib_dirs.length; i += 1) {
|
for (size_t i = 0; i < lib_dirs.length; i += 1) {
|
||||||
codegen_add_lib_dir(g, lib_dirs.at(i));
|
codegen_add_lib_dir(g, lib_dirs.at(i));
|
||||||
}
|
}
|
||||||
|
for (size_t i = 0; i < framework_dirs.length; i += 1) {
|
||||||
|
g->framework_dirs.append(framework_dirs.at(i));
|
||||||
|
}
|
||||||
for (size_t i = 0; i < link_libs.length; i += 1) {
|
for (size_t i = 0; i < link_libs.length; i += 1) {
|
||||||
LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i)));
|
LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i)));
|
||||||
link_lib->provided_explicitly = true;
|
link_lib->provided_explicitly = true;
|
||||||
|
|||||||
@ -1228,6 +1228,7 @@ pub const LibExeObjStep = struct {
|
|||||||
name_only_filename: []const u8,
|
name_only_filename: []const u8,
|
||||||
strip: bool,
|
strip: bool,
|
||||||
lib_paths: ArrayList([]const u8),
|
lib_paths: ArrayList([]const u8),
|
||||||
|
framework_dirs: ArrayList([]const u8),
|
||||||
frameworks: BufSet,
|
frameworks: BufSet,
|
||||||
verbose_link: bool,
|
verbose_link: bool,
|
||||||
verbose_cc: bool,
|
verbose_cc: bool,
|
||||||
@ -1341,6 +1342,7 @@ pub const LibExeObjStep = struct {
|
|||||||
.include_dirs = ArrayList(IncludeDir).init(builder.allocator),
|
.include_dirs = ArrayList(IncludeDir).init(builder.allocator),
|
||||||
.link_objects = ArrayList(LinkObject).init(builder.allocator),
|
.link_objects = ArrayList(LinkObject).init(builder.allocator),
|
||||||
.lib_paths = ArrayList([]const u8).init(builder.allocator),
|
.lib_paths = ArrayList([]const u8).init(builder.allocator),
|
||||||
|
.framework_dirs = ArrayList([]const u8).init(builder.allocator),
|
||||||
.object_src = undefined,
|
.object_src = undefined,
|
||||||
.build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable,
|
.build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable,
|
||||||
.c_std = Builder.CStd.C99,
|
.c_std = Builder.CStd.C99,
|
||||||
@ -1614,6 +1616,10 @@ pub const LibExeObjStep = struct {
|
|||||||
self.lib_paths.append(path) catch unreachable;
|
self.lib_paths.append(path) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void {
|
||||||
|
self.framework_dirs.append(dir_path) catch unreachable;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
|
pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
|
||||||
self.packages.append(Pkg{
|
self.packages.append(Pkg{
|
||||||
.name = name,
|
.name = name,
|
||||||
@ -1860,8 +1866,8 @@ pub const LibExeObjStep = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (self.lib_paths.toSliceConst()) |lib_path| {
|
for (self.lib_paths.toSliceConst()) |lib_path| {
|
||||||
zig_args.append("--library-path") catch unreachable;
|
try zig_args.append("-L");
|
||||||
zig_args.append(lib_path) catch unreachable;
|
try zig_args.append(lib_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.need_system_paths and self.target == Target.Native) {
|
if (self.need_system_paths and self.target == Target.Native) {
|
||||||
@ -1882,6 +1888,11 @@ pub const LibExeObjStep = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self.target.isDarwin()) {
|
if (self.target.isDarwin()) {
|
||||||
|
for (self.framework_dirs.toSliceConst()) |dir| {
|
||||||
|
try zig_args.append("-F");
|
||||||
|
try zig_args.append(dir);
|
||||||
|
}
|
||||||
|
|
||||||
var it = self.frameworks.iterator();
|
var it = self.frameworks.iterator();
|
||||||
while (it.next()) |entry| {
|
while (it.next()) |entry| {
|
||||||
zig_args.append("-framework") catch unreachable;
|
zig_args.append("-framework") catch unreachable;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user