authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 21:53:57 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 21:53:57 -07:00
log07eca3ffcc1fd5977d1532233cbbd1b89173c3c2
tree03a97ec4038d8f74c04a469b3e2bbd0d712fb113
parent090a4e57e0f600139fdf7aa7971ece3ac00cb4b3

common- rename dir to cachepath where it doesnt refer to a fs.Dir


1 files changed, 13 insertions(+), 13 deletions(-)

src/common.zig+13-13
......@@ -27,7 +27,7 @@ pub const CollectOptions = struct {
2727 }
2828};
2929
30pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module {
30pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module {
3131 const m = try u.ModFile.init(gpa, mpath);
3232 try options.init();
3333 var moduledeps = std.ArrayList(u.Module).init(gpa);
......@@ -36,9 +36,9 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOp
3636 if (m.root_files.len > 0) {
3737 try moduledeps.append(try add_files_package("root", m.root_files, m.name));
3838 }
39 try moduledeps.append(try collect_deps(dir, mpath, options));
39 try moduledeps.append(try collect_deps(cachepath, mpath, options));
4040 for (m.devdeps) |*d| {
41 if (try get_module_from_dep(d, dir, m.name, options)) |founddep| {
41 if (try get_module_from_dep(d, cachepath, m.name, options)) |founddep| {
4242 try moduledeps.append(founddep);
4343 }
4444 }
......@@ -54,7 +54,7 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOp
5454 };
5555}
5656
57pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module {
57pub fn collect_deps(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module {
5858 const m = try u.ModFile.init(gpa, mpath);
5959 var moduledeps = std.ArrayList(u.Module).init(gpa);
6060 defer moduledeps.deinit();
......@@ -62,7 +62,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions
6262 try moduledeps.append(try add_files_package(m.id, m.files, m.name));
6363 }
6464 for (m.deps) |*d| {
65 if (try get_module_from_dep(d, dir, m.name, options)) |founddep| {
65 if (try get_module_from_dep(d, cachepath, m.name, options)) |founddep| {
6666 try moduledeps.append(founddep);
6767 }
6868 }
......@@ -196,7 +196,7 @@ pub fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, option
196196 }
197197}
198198
199pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, options: *CollectOptions) anyerror!?u.Module {
199pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []const u8, options: *CollectOptions) anyerror!?u.Module {
200200 if (options.lock) |lock| {
201201 for (lock) |item| {
202202 if (std.mem.eql(u8, item[0], try d.clean_path())) {
......@@ -207,7 +207,7 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
207207 }
208208 }
209209 }
210 const moddir = try get_moddir(dir, d.*, parent_name, options);
210 const moddir = try get_moddir(cachepath, d.*, parent_name, options);
211211
212212 const nocache = d.type == .local or d.type == .system_lib;
213213 if (!nocache) try options.already_fetched.append(moddir);
......@@ -228,11 +228,11 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
228228 };
229229 },
230230 else => {
231 var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) {
231 var dd = try collect_deps(cachepath, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) {
232232 error.FileNotFound => {
233233 if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) {
234 var mod_from = try u.Module.from(d.*, dir, options);
235 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..];
234 var mod_from = try u.Module.from(d.*, cachepath, options);
235 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, cachepath)[1..];
236236 if (mod_from.is_for_this()) return mod_from;
237237 return null;
238238 }
......@@ -245,8 +245,8 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
245245 if (trymain) |_| {
246246 d.*.name = tryname;
247247 d.*.main = trymain.?;
248 var mod_from = try u.Module.from(d.*, dir, options);
249 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..];
248 var mod_from = try u.Module.from(d.*, cachepath, options);
249 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, cachepath)[1..];
250250 if (mod_from.is_for_this()) return mod_from;
251251 return null;
252252 }
......@@ -257,7 +257,7 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
257257 };
258258 dd.dep = d.*;
259259 const save = dd;
260 if (d.type != .local) dd.clean_path = u.trim_prefix(moddir, dir)[1..];
260 if (d.type != .local) dd.clean_path = u.trim_prefix(moddir, cachepath)[1..];
261261 if (dd.id.len == 0) dd.id = try u.random_string(48);
262262 if (d.name.len > 0) dd.name = d.name;
263263 if (d.main.len > 0) dd.main = d.main;