| ... | ... | @@ -16,51 +16,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec |
| 16 | 16 | const m = try u.ModFile.init(gpa, mpath); |
| 17 | 17 | const moduledeps = &std.ArrayList(u.Module).init(gpa); |
| 18 | 18 | for (m.deps) |d| { |
| 19 | | const moddir = try get_moddir(dir, d, m.name, options); |
| 20 | | switch (d.type) { |
| 21 | | .system_lib => { |
| 22 | | if (d.is_for_this()) try moduledeps.append(u.Module{ |
| 23 | | .is_sys_lib = true, |
| 24 | | .id = "", |
| 25 | | .name = d.path, |
| 26 | | .only_os = d.only_os, |
| 27 | | .except_os = d.except_os, |
| 28 | | .main = "", |
| 29 | | .c_include_dirs = &.{}, |
| 30 | | .c_source_flags = &.{}, |
| 31 | | .c_source_files = &.{}, |
| 32 | | .deps = &[_]u.Module{}, |
| 33 | | .clean_path = d.path, |
| 34 | | .yaml = null, |
| 35 | | }); |
| 36 | | }, |
| 37 | | else => blk: { |
| 38 | | var dd = try collect_deps(dir, try u.concat(&.{moddir, "/zig.mod"}), options) catch |e| switch (e) { |
| 39 | | error.FileNotFound => { |
| 40 | | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 41 | | var mod_from = try u.Module.from(d); |
| 42 | | if (mod_from.id.len == 0) mod_from.id = try u.random_string(48); |
| 43 | | mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 44 | | if (mod_from.is_for_this()) try moduledeps.append(mod_from); |
| 45 | | } |
| 46 | | break :blk; |
| 47 | | }, |
| 48 | | else => e, |
| 49 | | }; |
| 50 | | dd.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 51 | | |
| 52 | | if (dd.id.len == 0) dd.id = try u.random_string(48); |
| 53 | | if (d.name.len > 0) dd.name = d.name; |
| 54 | | if (d.main.len > 0) dd.main = d.main; |
| 55 | | if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; |
| 56 | | if (d.c_source_flags.len > 0) dd.c_source_flags = d.c_source_flags; |
| 57 | | if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files; |
| 58 | | if (d.only_os.len > 0) dd.only_os = d.only_os; |
| 59 | | if (d.except_os.len > 0) dd.except_os = d.except_os; |
| 60 | | |
| 61 | | if (dd.is_for_this()) try moduledeps.append(dd); |
| 62 | | }, |
| 63 | | } |
| 19 | try get_module_from_dep(moduledeps, d, dir, m.name, options); |
| 64 | 20 | } |
| 65 | 21 | return u.Module{ |
| 66 | 22 | .is_sys_lib = false, |
| ... | ... | @@ -173,3 +129,51 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, comptime o |
| 173 | 129 | }, |
| 174 | 130 | } |
| 175 | 131 | } |
| 132 | |
| 133 | fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, comptime options: CollectOptions) !void { |
| 134 | const moddir = try get_moddir(dir, d, parent_name, options); |
| 135 | switch (d.type) { |
| 136 | .system_lib => { |
| 137 | if (d.is_for_this()) try list.append(u.Module{ |
| 138 | .is_sys_lib = true, |
| 139 | .id = "", |
| 140 | .name = d.path, |
| 141 | .only_os = d.only_os, |
| 142 | .except_os = d.except_os, |
| 143 | .main = "", |
| 144 | .c_include_dirs = &.{}, |
| 145 | .c_source_flags = &.{}, |
| 146 | .c_source_files = &.{}, |
| 147 | .deps = &[_]u.Module{}, |
| 148 | .clean_path = d.path, |
| 149 | .yaml = null, |
| 150 | }); |
| 151 | }, |
| 152 | else => blk: { |
| 153 | var dd = try collect_deps(dir, try u.concat(&.{moddir, "/zig.mod"}), options) catch |e| switch (e) { |
| 154 | error.FileNotFound => { |
| 155 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 156 | var mod_from = try u.Module.from(d); |
| 157 | if (mod_from.id.len == 0) mod_from.id = try u.random_string(48); |
| 158 | mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 159 | if (mod_from.is_for_this()) try list.append(mod_from); |
| 160 | } |
| 161 | break :blk; |
| 162 | }, |
| 163 | else => e, |
| 164 | }; |
| 165 | dd.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 166 | |
| 167 | if (dd.id.len == 0) dd.id = try u.random_string(48); |
| 168 | if (d.name.len > 0) dd.name = d.name; |
| 169 | if (d.main.len > 0) dd.main = d.main; |
| 170 | if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; |
| 171 | if (d.c_source_flags.len > 0) dd.c_source_flags = d.c_source_flags; |
| 172 | if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files; |
| 173 | if (d.only_os.len > 0) dd.only_os = d.only_os; |
| 174 | if (d.except_os.len > 0) dd.except_os = d.except_os; |
| 175 | |
| 176 | if (dd.is_for_this()) try list.append(dd); |
| 177 | }, |
| 178 | } |
| 179 | } |