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 {
4747 try w.print(";\n", .{});
4848 try w.print("\n", .{});
4949 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);
5151 try w.print("{};\n", .{"}"});
5252 try w.print("\n", .{});
5353 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);
5555 try w.print("{};\n", .{"}"});
5656}
5757
......@@ -119,28 +119,36 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an
119119 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});
120120}
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 {
123123 if (u.list_contains(list, mod.clean_path)) {
124124 return;
125125 }
126126 try list.append(mod.clean_path);
127127 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 }
129133 }
130134 for (mod.deps) |d| {
131 try print_incl_dirs_to(w, d, list);
135 try print_incl_dirs_to(w, d, list, false);
132136 }
133137}
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 {
136140 if (u.list_contains(list, mod.clean_path)) {
137141 return;
138142 }
139143 try list.append(mod.clean_path);
140144 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 }
142150 }
143151 for (mod.deps) |d| {
144 try print_csrc_dirs_to(w, d, list);
152 try print_csrc_dirs_to(w, d, list, false);
145153 }
146154}