| ... | ... | @@ -18,14 +18,13 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: CollectOpt |
| 18 | 18 | defer moduledeps.deinit(); |
| 19 | 19 | try std.fs.cwd().makePath(".zigmod/deps/files"); |
| 20 | 20 | if (m.root_files.len > 0) { |
| 21 | | try add_files_package("root", m.root_files, moduledeps, m.name); |
| 21 | try moduledeps.append(try add_files_package("root", m.root_files, m.name)); |
| 22 | 22 | } |
| 23 | 23 | try moduledeps.append(try collect_deps(dir, mpath, options)); |
| 24 | 24 | for (m.devdeps) |d| { |
| 25 | | if (!d.is_for_this()) { |
| 26 | | continue; |
| 25 | if (try get_module_from_dep(d, dir, m.name, options)) |founddep| { |
| 26 | try moduledeps.append(founddep); |
| 27 | 27 | } |
| 28 | | try get_module_from_dep(moduledeps, d, dir, m.name, options); |
| 29 | 28 | } |
| 30 | 29 | return u.Module{ |
| 31 | 30 | .is_sys_lib = false, |
| ... | ... | @@ -49,13 +48,12 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: CollectOptions) |
| 49 | 48 | const moduledeps = &std.ArrayList(u.Module).init(gpa); |
| 50 | 49 | defer moduledeps.deinit(); |
| 51 | 50 | if (m.files.len > 0) { |
| 52 | | try add_files_package(m.id, m.files, moduledeps, m.name); |
| 51 | try moduledeps.append(try add_files_package(m.id, m.files, m.name)); |
| 53 | 52 | } |
| 54 | 53 | for (m.deps) |d| { |
| 55 | | if (!d.is_for_this()) { |
| 56 | | continue; |
| 54 | if (try get_module_from_dep(d, dir, m.name, options)) |founddep| { |
| 55 | try moduledeps.append(founddep); |
| 57 | 56 | } |
| 58 | | try get_module_from_dep(moduledeps, d, dir, m.name, options); |
| 59 | 57 | } |
| 60 | 58 | return u.Module{ |
| 61 | 59 | .is_sys_lib = false, |
| ... | ... | @@ -182,11 +180,11 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: C |
| 182 | 180 | } |
| 183 | 181 | } |
| 184 | 182 | |
| 185 | | pub fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, options: CollectOptions) anyerror!void { |
| 183 | pub fn get_module_from_dep(d: u.Dep, dir: []const u8, parent_name: []const u8, options: CollectOptions) anyerror!?u.Module { |
| 186 | 184 | const moddir = try get_moddir(dir, d, parent_name, options); |
| 187 | 185 | switch (d.type) { |
| 188 | 186 | .system_lib => { |
| 189 | | try list.append(u.Module{ |
| 187 | return u.Module{ |
| 190 | 188 | .is_sys_lib = true, |
| 191 | 189 | .id = "", |
| 192 | 190 | .name = d.path, |
| ... | ... | @@ -200,7 +198,7 @@ pub fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []cons |
| 200 | 198 | .clean_path = d.path, |
| 201 | 199 | .yaml = null, |
| 202 | 200 | .dep = d, |
| 203 | | }); |
| 201 | }; |
| 204 | 202 | }, |
| 205 | 203 | else => { |
| 206 | 204 | var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) { |
| ... | ... | @@ -208,9 +206,10 @@ pub fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []cons |
| 208 | 206 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 209 | 207 | var mod_from = try u.Module.from(d, dir, options); |
| 210 | 208 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 211 | | if (mod_from.is_for_this()) try list.append(mod_from); |
| 209 | if (mod_from.is_for_this()) return mod_from; |
| 210 | return null; |
| 212 | 211 | } |
| 213 | | return; |
| 212 | return e; |
| 214 | 213 | }, |
| 215 | 214 | else => e, |
| 216 | 215 | }; |
| ... | ... | @@ -226,12 +225,13 @@ pub fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []cons |
| 226 | 225 | if (d.only_os.len > 0) dd.only_os = d.only_os; |
| 227 | 226 | if (d.except_os.len > 0) dd.except_os = d.except_os; |
| 228 | 227 | if (d.type == .local) dd.main = try std.fs.path.join(gpa, &.{ d.main, save.main }); |
| 229 | | if (dd.is_for_this()) try list.append(dd); |
| 228 | if (dd.is_for_this()) return dd; |
| 229 | return null; |
| 230 | 230 | }, |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | | fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, list: *std.ArrayList(u.Module), parent_name: []const u8) !void { |
| 234 | fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, parent_name: []const u8) !u.Module { |
| 235 | 235 | const destination = ".zigmod/deps/files"; |
| 236 | 236 | const fname = try std.mem.join(gpa, "", &.{ pkg_name, ".zig" }); |
| 237 | 237 | |
| ... | ... | @@ -289,8 +289,8 @@ fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, list: *std. |
| 289 | 289 | .yaml = null, |
| 290 | 290 | .deps = &.{}, |
| 291 | 291 | }; |
| 292 | | try get_module_from_dep(list, d, destination, parent_name, .{ |
| 292 | return (try get_module_from_dep(d, destination, parent_name, .{ |
| 293 | 293 | .log = false, |
| 294 | 294 | .update = false, |
| 295 | | }); |
| 295 | })).?; |
| 296 | 296 | } |