authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-17 01:27:20 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-17 01:27:20 -08:00
log1788561fa7d3570b07e06b4cb52bacd2d5e120f6
treee2599cfda29cbd2af20cf9e3a43b47b4146087f2
parenta3772eac0fda962d3fbdf5ef73dcc7aa936a493e

fetch: use relative path in deps.zig for local c/h files


1 files changed, 16 insertions(+), 8 deletions(-)

src/cmd_fetch.zig+16-8
...@@ -47,11 +47,11 @@ pub fn execute(args: [][]u8) !void {...@@ -47,11 +47,11 @@ pub fn execute(args: [][]u8) !void {
47 try w.print(";\n", .{});47 try w.print(";\n", .{});
48 try w.print("\n", .{});48 try w.print("\n", .{});
49 try w.print("{}\n", .{"pub const c_include_dirs = &[_][]const u8{"});49 try w.print("{}\n", .{"pub const c_include_dirs = &[_][]const u8{"});
50 try print_incl_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa));50 try print_incl_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true);
51 try w.print("{};\n", .{"}"});51 try w.print("{};\n", .{"}"});
52 try w.print("\n", .{});52 try w.print("\n", .{});
53 try w.print("{}\n", .{"pub const c_source_files = &[_][]const u8{"});53 try w.print("{}\n", .{"pub const c_source_files = &[_][]const u8{"});
54 try print_csrc_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa));54 try print_csrc_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true);
55 try w.print("{};\n", .{"}"});55 try w.print("{};\n", .{"}"});
56}56}
5757
...@@ -119,28 +119,36 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an...@@ -119,28 +119,36 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an
119 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});119 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});
120}120}
121121
122fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8)) anyerror!void {122fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
123 if (u.list_contains(list, mod.clean_path)) {123 if (u.list_contains(list, mod.clean_path)) {
124 return;124 return;
125 }125 }
126 try list.append(mod.clean_path);126 try list.append(mod.clean_path);
127 for (mod.c_include_dirs) |it| {127 for (mod.c_include_dirs) |it| {
128 try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it});128 if (!local) {
129 try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it});
130 } else {
131 try w.print(" \".{}/{}\",\n", .{mod.clean_path, it});
132 }
129 }133 }
130 for (mod.deps) |d| {134 for (mod.deps) |d| {
131 try print_incl_dirs_to(w, d, list);135 try print_incl_dirs_to(w, d, list, false);
132 }136 }
133}137}
134138
135fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8)) anyerror!void {139fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
136 if (u.list_contains(list, mod.clean_path)) {140 if (u.list_contains(list, mod.clean_path)) {
137 return;141 return;
138 }142 }
139 try list.append(mod.clean_path);143 try list.append(mod.clean_path);
140 for (mod.c_source_files) |it| {144 for (mod.c_source_files) |it| {
141 try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it});145 if (!local) {
146 try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it});
147 } else {
148 try w.print(" \".{}/{}\",\n", .{mod.clean_path, it});
149 }
142 }150 }
143 for (mod.deps) |d| {151 for (mod.deps) |d| {
144 try print_csrc_dirs_to(w, d, list);152 try print_csrc_dirs_to(w, d, list, false);
145 }153 }
146}154}