authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-02 11:32:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-02 11:48:06-04:00
log0fe28855c5a32b16dc092ab1d70efde38ef89a7b
tree2fa44bb189ada171ff0666bb77fd609da4e584b0
parent0c4d47c6d5a7d27ce54e8584da84613751df7dac
signaturelock-open Commit is signed but in an unrecognized format.

add ability to specify darwin framework search dirs


5 files changed, 30 insertions(+), 2 deletions(-)

src/all_types.hpp+1
...@@ -2003,6 +2003,7 @@ struct CodeGen {...@@ -2003,6 +2003,7 @@ struct CodeGen {
2003 ZigList<Buf *> assembly_files;2003 ZigList<Buf *> assembly_files;
2004 ZigList<CFile *> c_source_files;2004 ZigList<CFile *> c_source_files;
2005 ZigList<const char *> lib_dirs;2005 ZigList<const char *> lib_dirs;
2006 ZigList<const char *> framework_dirs;
20062007
2007 ZigLibCInstallation *libc;2008 ZigLibCInstallation *libc;
20082009
src/codegen.cpp+1
...@@ -9803,6 +9803,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -9803,6 +9803,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
9803 cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len);9803 cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len);
9804 cache_list_of_str(ch, g->clang_argv, g->clang_argv_len);9804 cache_list_of_str(ch, g->clang_argv, g->clang_argv_len);
9805 cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length);9805 cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length);
9806 cache_list_of_str(ch, g->framework_dirs.items, g->framework_dirs.length);
9806 if (g->libc) {9807 if (g->libc) {
9807 cache_buf(ch, &g->libc->include_dir);9808 cache_buf(ch, &g->libc->include_dir);
9808 cache_buf(ch, &g->libc->sys_include_dir);9809 cache_buf(ch, &g->libc->sys_include_dir);
src/link.cpp+6
...@@ -2510,6 +2510,12 @@ static void construct_linker_job_macho(LinkJob *lj) {...@@ -2510,6 +2510,12 @@ static void construct_linker_job_macho(LinkJob *lj) {
2510 lj->args.append("dynamic_lookup");2510 lj->args.append("dynamic_lookup");
2511 }2511 }
25122512
2513 for (size_t i = 0; i < g->framework_dirs.length; i += 1) {
2514 const char *framework_dir = g->framework_dirs.at(i);
2515 lj->args.append("-F");
2516 lj->args.append(framework_dir);
2517 }
2518
2513 for (size_t i = 0; i < g->darwin_frameworks.length; i += 1) {2519 for (size_t i = 0; i < g->darwin_frameworks.length; i += 1) {
2514 lj->args.append("-framework");2520 lj->args.append("-framework");
2515 lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));2521 lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));
src/main.cpp+9
...@@ -104,6 +104,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -104,6 +104,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
104 " -rdynamic add all symbols to the dynamic symbol table\n"104 " -rdynamic add all symbols to the dynamic symbol table\n"
105 " -rpath [path] add directory to the runtime library search path\n"105 " -rpath [path] add directory to the runtime library search path\n"
106 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"106 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
107 " -F[dir] (darwin) add search path for frameworks\n"
107 " -framework [name] (darwin) link against framework\n"108 " -framework [name] (darwin) link against framework\n"
108 " -mios-version-min [ver] (darwin) set iOS deployment target\n"109 " -mios-version-min [ver] (darwin) set iOS deployment target\n"
109 " -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"110 " -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
...@@ -454,6 +455,7 @@ int main(int argc, char **argv) {...@@ -454,6 +455,7 @@ int main(int argc, char **argv) {
454 ZigList<const char *> lib_dirs = {0};455 ZigList<const char *> lib_dirs = {0};
455 ZigList<const char *> link_libs = {0};456 ZigList<const char *> link_libs = {0};
456 ZigList<const char *> forbidden_link_libs = {0};457 ZigList<const char *> forbidden_link_libs = {0};
458 ZigList<const char *> framework_dirs = {0};
457 ZigList<const char *> frameworks = {0};459 ZigList<const char *> frameworks = {0};
458 bool have_libc = false;460 bool have_libc = false;
459 const char *target_string = nullptr;461 const char *target_string = nullptr;
...@@ -686,6 +688,8 @@ int main(int argc, char **argv) {...@@ -686,6 +688,8 @@ int main(int argc, char **argv) {
686 } else if (arg[1] == 'L' && arg[2] != 0) {688 } else if (arg[1] == 'L' && arg[2] != 0) {
687 // alias for --library-path689 // alias for --library-path
688 lib_dirs.append(&arg[2]);690 lib_dirs.append(&arg[2]);
691 } else if (arg[1] == 'F' && arg[2] != 0) {
692 framework_dirs.append(&arg[2]);
689 } else if (strcmp(arg, "--pkg-begin") == 0) {693 } else if (strcmp(arg, "--pkg-begin") == 0) {
690 if (i + 2 >= argc) {694 if (i + 2 >= argc) {
691 fprintf(stderr, "Expected 2 arguments after --pkg-begin\n");695 fprintf(stderr, "Expected 2 arguments after --pkg-begin\n");
...@@ -772,6 +776,8 @@ int main(int argc, char **argv) {...@@ -772,6 +776,8 @@ int main(int argc, char **argv) {
772 main_pkg_path = buf_create_from_str(argv[i]);776 main_pkg_path = buf_create_from_str(argv[i]);
773 } else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) {777 } else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) {
774 lib_dirs.append(argv[i]);778 lib_dirs.append(argv[i]);
779 } else if (strcmp(arg, "-F") == 0) {
780 framework_dirs.append(argv[i]);
775 } else if (strcmp(arg, "--library") == 0) {781 } else if (strcmp(arg, "--library") == 0) {
776 if (strcmp(argv[i], "c") == 0)782 if (strcmp(argv[i], "c") == 0)
777 have_libc = true;783 have_libc = true;
...@@ -1153,6 +1159,9 @@ int main(int argc, char **argv) {...@@ -1153,6 +1159,9 @@ int main(int argc, char **argv) {
1153 for (size_t i = 0; i < lib_dirs.length; i += 1) {1159 for (size_t i = 0; i < lib_dirs.length; i += 1) {
1154 codegen_add_lib_dir(g, lib_dirs.at(i));1160 codegen_add_lib_dir(g, lib_dirs.at(i));
1155 }1161 }
1162 for (size_t i = 0; i < framework_dirs.length; i += 1) {
1163 g->framework_dirs.append(framework_dirs.at(i));
1164 }
1156 for (size_t i = 0; i < link_libs.length; i += 1) {1165 for (size_t i = 0; i < link_libs.length; i += 1) {
1157 LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i)));1166 LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i)));
1158 link_lib->provided_explicitly = true;1167 link_lib->provided_explicitly = true;
std/build.zig+13-2
...@@ -1228,6 +1228,7 @@ pub const LibExeObjStep = struct {...@@ -1228,6 +1228,7 @@ pub const LibExeObjStep = struct {
1228 name_only_filename: []const u8,1228 name_only_filename: []const u8,
1229 strip: bool,1229 strip: bool,
1230 lib_paths: ArrayList([]const u8),1230 lib_paths: ArrayList([]const u8),
1231 framework_dirs: ArrayList([]const u8),
1231 frameworks: BufSet,1232 frameworks: BufSet,
1232 verbose_link: bool,1233 verbose_link: bool,
1233 verbose_cc: bool,1234 verbose_cc: bool,
...@@ -1341,6 +1342,7 @@ pub const LibExeObjStep = struct {...@@ -1341,6 +1342,7 @@ pub const LibExeObjStep = struct {
1341 .include_dirs = ArrayList(IncludeDir).init(builder.allocator),1342 .include_dirs = ArrayList(IncludeDir).init(builder.allocator),
1342 .link_objects = ArrayList(LinkObject).init(builder.allocator),1343 .link_objects = ArrayList(LinkObject).init(builder.allocator),
1343 .lib_paths = ArrayList([]const u8).init(builder.allocator),1344 .lib_paths = ArrayList([]const u8).init(builder.allocator),
1345 .framework_dirs = ArrayList([]const u8).init(builder.allocator),
1344 .object_src = undefined,1346 .object_src = undefined,
1345 .build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable,1347 .build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable,
1346 .c_std = Builder.CStd.C99,1348 .c_std = Builder.CStd.C99,
...@@ -1614,6 +1616,10 @@ pub const LibExeObjStep = struct {...@@ -1614,6 +1616,10 @@ pub const LibExeObjStep = struct {
1614 self.lib_paths.append(path) catch unreachable;1616 self.lib_paths.append(path) catch unreachable;
1615 }1617 }
16161618
1619 pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void {
1620 self.framework_dirs.append(dir_path) catch unreachable;
1621 }
1622
1617 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {1623 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
1618 self.packages.append(Pkg{1624 self.packages.append(Pkg{
1619 .name = name,1625 .name = name,
...@@ -1860,8 +1866,8 @@ pub const LibExeObjStep = struct {...@@ -1860,8 +1866,8 @@ pub const LibExeObjStep = struct {
1860 }1866 }
18611867
1862 for (self.lib_paths.toSliceConst()) |lib_path| {1868 for (self.lib_paths.toSliceConst()) |lib_path| {
1863 zig_args.append("--library-path") catch unreachable;1869 try zig_args.append("-L");
1864 zig_args.append(lib_path) catch unreachable;1870 try zig_args.append(lib_path);
1865 }1871 }
18661872
1867 if (self.need_system_paths and self.target == Target.Native) {1873 if (self.need_system_paths and self.target == Target.Native) {
...@@ -1882,6 +1888,11 @@ pub const LibExeObjStep = struct {...@@ -1882,6 +1888,11 @@ pub const LibExeObjStep = struct {
1882 }1888 }
18831889
1884 if (self.target.isDarwin()) {1890 if (self.target.isDarwin()) {
1891 for (self.framework_dirs.toSliceConst()) |dir| {
1892 try zig_args.append("-F");
1893 try zig_args.append(dir);
1894 }
1895
1885 var it = self.frameworks.iterator();1896 var it = self.frameworks.iterator();
1886 while (it.next()) |entry| {1897 while (it.next()) |entry| {
1887 zig_args.append("-framework") catch unreachable;1898 zig_args.append("-framework") catch unreachable;