| ... | ... | @@ -220,31 +220,33 @@ fn print_sys_libs_to(w: std.fs.File.Writer, list: []u.Module, list2: *std.ArrayL |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | fn print_pkg_data_to(w: std.fs.File.Writer, list: *std.ArrayList(u.Module), list2: *std.ArrayList(u.Module)) anyerror!void { |
| 224 | | var i: usize = 0; |
| 225 | | while (i < list.items.len) : (i += 1) { |
| 226 | | const mod = list.items[i]; |
| 227 | | if (contains_all(mod.deps, list2)) { |
| 228 | | try w.print(" pub const _{s} = std.build.Pkg{{ .name = \"{s}\", .path = cache ++ \"/{}/{s}\", .dependencies = &[_]std.build.Pkg{{", .{ mod.id, mod.name, std.zig.fmtEscapes(mod.clean_path), mod.main }); |
| 229 | | for (mod.deps) |d| { |
| 230 | | if (d.main.len > 0) { |
| 231 | | try w.print(" _{s},", .{d.id[0..12]}); |
| 223 | fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), done: *std.ArrayList(u.Module)) !void { |
| 224 | var len: usize = notdone.items.len; |
| 225 | while (notdone.items.len > 0) { |
| 226 | for (notdone.items) |mod, i| { |
| 227 | if (contains_all(mod.deps, done.items)) { |
| 228 | try w.print(" pub const _{s} = std.build.Pkg{{ .name = \"{s}\", .path = cache ++ \"/{}/{s}\", .dependencies = &[_]std.build.Pkg{{", .{ mod.id[0..12], mod.name, std.zig.fmtEscapes(mod.clean_path), mod.main }); |
| 229 | for (mod.deps) |d| { |
| 230 | if (d.main.len > 0) { |
| 231 | try w.print(" _{s},", .{d.id[0..12]}); |
| 232 | } |
| 232 | 233 | } |
| 233 | | } |
| 234 | | try w.print(" }} }};\n", .{}); |
| 234 | try w.print(" }} }};\n", .{}); |
| 235 | 235 | |
| 236 | | try list2.append(mod); |
| 237 | | _ = list.orderedRemove(i); |
| 238 | | break; |
| 236 | try done.append(mod); |
| 237 | _ = notdone.orderedRemove(i); |
| 238 | break; |
| 239 | } |
| 239 | 240 | } |
| 240 | | } |
| 241 | | if (list.items.len > 0) { |
| 242 | | try print_pkg_data_to(w, list, list2); |
| 241 | if (notdone.items.len == len) { |
| 242 | u.assert(false, "notdone still has {d} items", .{len}); |
| 243 | } |
| 244 | len = notdone.items.len; |
| 243 | 245 | } |
| 244 | 246 | } |
| 245 | 247 | |
| 246 | 248 | /// returns if all of the zig modules in needles are in haystack |
| 247 | | fn contains_all(needles: []u.Module, haystack: *std.ArrayList(u.Module)) bool { |
| 249 | fn contains_all(needles: []u.Module, haystack: []const u.Module) bool { |
| 248 | 250 | for (needles) |item| { |
| 249 | 251 | if (item.main.len > 0 and !u.list_contains_gen(u.Module, haystack, item)) { |
| 250 | 252 | return false; |