| ... | @@ -27,7 +27,7 @@ pub const CollectOptions = struct { | ... | @@ -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 | const m = try u.ModFile.init(gpa, mpath); | 31 | const m = try u.ModFile.init(gpa, mpath); |
| 32 | try options.init(); | 32 | try options.init(); |
| 33 | var moduledeps = std.ArrayList(u.Module).init(gpa); | 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,9 +36,9 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOp |
| 36 | if (m.root_files.len > 0) { | 36 | if (m.root_files.len > 0) { |
| 37 | try moduledeps.append(try add_files_package("root", m.root_files, m.name)); | 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 | for (m.devdeps) |*d| { | 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 | try moduledeps.append(founddep); | 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,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 | const m = try u.ModFile.init(gpa, mpath); | 58 | const m = try u.ModFile.init(gpa, mpath); |
| 59 | var moduledeps = std.ArrayList(u.Module).init(gpa); | 59 | var moduledeps = std.ArrayList(u.Module).init(gpa); |
| 60 | defer moduledeps.deinit(); | 60 | defer moduledeps.deinit(); |
| ... | @@ -62,7 +62,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions | ... | @@ -62,7 +62,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions |
| 62 | try moduledeps.append(try add_files_package(m.id, m.files, m.name)); | 62 | try moduledeps.append(try add_files_package(m.id, m.files, m.name)); |
| 63 | } | 63 | } |
| 64 | for (m.deps) |*d| { | 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 | try moduledeps.append(founddep); | 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,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 | if (options.lock) |lock| { | 200 | if (options.lock) |lock| { |
| 201 | for (lock) |item| { | 201 | for (lock) |item| { |
| 202 | if (std.mem.eql(u8, item[0], try d.clean_path())) { | 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,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 | const nocache = d.type == .local or d.type == .system_lib; | 212 | const nocache = d.type == .local or d.type == .system_lib; |
| 213 | if (!nocache) try options.already_fetched.append(moddir); | 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,11 +228,11 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, |
| 228 | }; | 228 | }; |
| 229 | }, | 229 | }, |
| 230 | else => { | 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 | error.FileNotFound => { | 232 | error.FileNotFound => { |
| 233 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { | 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); | 234 | var mod_from = try u.Module.from(d.*, cachepath, options); |
| 235 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; | 235 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, cachepath)[1..]; |
| 236 | if (mod_from.is_for_this()) return mod_from; | 236 | if (mod_from.is_for_this()) return mod_from; |
| 237 | return null; | 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,8 +245,8 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, |
| 245 | if (trymain) |_| { | 245 | if (trymain) |_| { |
| 246 | d.*.name = tryname; | 246 | d.*.name = tryname; |
| 247 | d.*.main = trymain.?; | 247 | d.*.main = trymain.?; |
| 248 | var mod_from = try u.Module.from(d.*, dir, options); | 248 | var mod_from = try u.Module.from(d.*, cachepath, options); |
| 249 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; | 249 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, cachepath)[1..]; |
| 250 | if (mod_from.is_for_this()) return mod_from; | 250 | if (mod_from.is_for_this()) return mod_from; |
| 251 | return null; | 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,7 +257,7 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8, |
| 257 | }; | 257 | }; |
| 258 | dd.dep = d.*; | 258 | dd.dep = d.*; |
| 259 | const save = dd; | 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 | if (dd.id.len == 0) dd.id = try u.random_string(48); | 261 | if (dd.id.len == 0) dd.id = try u.random_string(48); |
| 262 | if (d.name.len > 0) dd.name = d.name; | 262 | if (d.name.len > 0) dd.name = d.name; |
| 263 | if (d.main.len > 0) dd.main = d.main; | 263 | if (d.main.len > 0) dd.main = d.main; |