| ... | ... | @@ -27,7 +27,7 @@ pub const CollectOptions = struct { |
| 27 | 27 | } |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | | pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module { |
| 30 | pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module { |
| 31 | 31 | const m = try u.ModFile.init(gpa, mpath); |
| 32 | 32 | try options.init(); |
| 33 | 33 | 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 |
| 36 | 36 | if (m.root_files.len > 0) { |
| 37 | 37 | try moduledeps.append(try add_files_package("root", m.root_files, m.name)); |
| 38 | 38 | } |
| 39 | | try moduledeps.append(try collect_deps(dir, mpath, options)); |
| 39 | try moduledeps.append(try collect_deps(cachepath, mpath, options)); |
| 40 | 40 | 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| { |
| 42 | 42 | try moduledeps.append(founddep); |
| 43 | 43 | } |
| 44 | 44 | } |
| ... | ... | @@ -54,7 +54,7 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOp |
| 54 | 54 | }; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | | pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module { |
| 57 | pub fn collect_deps(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module { |
| 58 | 58 | const m = try u.ModFile.init(gpa, mpath); |
| 59 | 59 | var moduledeps = std.ArrayList(u.Module).init(gpa); |
| 60 | 60 | defer moduledeps.deinit(); |
| ... | ... | @@ -62,7 +62,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions |
| 62 | 62 | try moduledeps.append(try add_files_package(m.id, m.files, m.name)); |
| 63 | 63 | } |
| 64 | 64 | 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| { |
| 66 | 66 | try moduledeps.append(founddep); |
| 67 | 67 | } |
| 68 | 68 | } |
| ... | ... | @@ -196,7 +196,7 @@ pub fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, option |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | | pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, options: *CollectOptions) anyerror!?u.Module { |
| 199 | pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []const u8, options: *CollectOptions) anyerror!?u.Module { |
| 200 | 200 | if (options.lock) |lock| { |
| 201 | 201 | for (lock) |item| { |
| 202 | 202 | 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, |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | | const moddir = try get_moddir(dir, d.*, parent_name, options); |
| 210 | const moddir = try get_moddir(cachepath, d.*, parent_name, options); |
| 211 | 211 | |
| 212 | 212 | const nocache = d.type == .local or d.type == .system_lib; |
| 213 | 213 | 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, |
| 228 | 228 | }; |
| 229 | 229 | }, |
| 230 | 230 | 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) { |
| 232 | 232 | error.FileNotFound => { |
| 233 | 233 | 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..]; |
| 236 | 236 | if (mod_from.is_for_this()) return mod_from; |
| 237 | 237 | return null; |
| 238 | 238 | } |
| ... | ... | @@ -245,8 +245,8 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, |
| 245 | 245 | if (trymain) |_| { |
| 246 | 246 | d.*.name = tryname; |
| 247 | 247 | 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..]; |
| 250 | 250 | if (mod_from.is_for_this()) return mod_from; |
| 251 | 251 | return null; |
| 252 | 252 | } |
| ... | ... | @@ -257,7 +257,7 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, |
| 257 | 257 | }; |
| 258 | 258 | dd.dep = d.*; |
| 259 | 259 | 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..]; |
| 261 | 261 | if (dd.id.len == 0) dd.id = try u.random_string(48); |
| 262 | 262 | if (d.name.len > 0) dd.name = d.name; |
| 263 | 263 | if (d.main.len > 0) dd.main = d.main; |