| author | |
| committer | |
| log | 70147b37a52266e970d2e762cf7c54617085af33 |
| tree | 1217b1f54a289e3bd636feb6f67da28b99582361 |
| parent | fe53c603ace946f51220e767e5286349dd4fb531 |
4 files changed, 26 insertions(+), 24 deletions(-)
src/cmd/fetch.zig+20-18| ... | @@ -220,31 +220,33 @@ fn print_sys_libs_to(w: std.fs.File.Writer, list: []u.Module, list2: *std.ArrayL | ... | @@ -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 { | 223 | fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), done: *std.ArrayList(u.Module)) !void { |
| 224 | var i: usize = 0; | 224 | var len: usize = notdone.items.len; |
| 225 | while (i < list.items.len) : (i += 1) { | 225 | while (notdone.items.len > 0) { |
| 226 | const mod = list.items[i]; | 226 | for (notdone.items) |mod, i| { |
| 227 | if (contains_all(mod.deps, list2)) { | 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, mod.name, std.zig.fmtEscapes(mod.clean_path), mod.main }); | 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| { | 229 | for (mod.deps) |d| { |
| 230 | if (d.main.len > 0) { | 230 | if (d.main.len > 0) { |
| 231 | try w.print(" _{s},", .{d.id[0..12]}); | 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); | 236 | try done.append(mod); |
| 237 | _ = list.orderedRemove(i); | 237 | _ = notdone.orderedRemove(i); |
| 238 | break; | 238 | break; |
| 239 | } | ||
| 239 | } | 240 | } |
| 240 | } | 241 | if (notdone.items.len == len) { |
| 241 | if (list.items.len > 0) { | 242 | u.assert(false, "notdone still has {d} items", .{len}); |
| 242 | try print_pkg_data_to(w, list, list2); | 243 | } |
| 244 | len = notdone.items.len; | ||
| 243 | } | 245 | } |
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | /// returns if all of the zig modules in needles are in haystack | 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 | for (needles) |item| { | 250 | for (needles) |item| { |
| 249 | if (item.main.len > 0 and !u.list_contains_gen(u.Module, haystack, item)) { | 251 | if (item.main.len > 0 and !u.list_contains_gen(u.Module, haystack, item)) { |
| 250 | return false; | 252 | return false; |
src/common.zig+3-3| ... | @@ -65,7 +65,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: CollectOptions) | ... | @@ -65,7 +65,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, options: CollectOptions) |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void { | 67 | pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void { |
| 68 | if (u.list_contains_gen(u.Module, list, mod)) { | 68 | if (u.list_contains_gen(u.Module, list.items, mod)) { |
| 69 | return; | 69 | return; |
| 70 | } | 70 | } |
| 71 | try list.append(mod); | 71 | try list.append(mod); |
| ... | @@ -185,7 +185,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8 | ... | @@ -185,7 +185,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8 |
| 185 | .yaml = null, | 185 | .yaml = null, |
| 186 | }); | 186 | }); |
| 187 | }, | 187 | }, |
| 188 | else => blk: { | 188 | else => { |
| 189 | var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) { | 189 | var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) { |
| 190 | error.FileNotFound => { | 190 | error.FileNotFound => { |
| 191 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { | 191 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| ... | @@ -194,7 +194,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8 | ... | @@ -194,7 +194,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8 |
| 194 | mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; | 194 | mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 195 | if (mod_from.is_for_this()) try list.append(mod_from); | 195 | if (mod_from.is_for_this()) try list.append(mod_from); |
| 196 | } | 196 | } |
| 197 | break :blk; | 197 | return; |
| 198 | }, | 198 | }, |
| 199 | else => e, | 199 | else => e, |
| 200 | }; | 200 | }; |
src/util/funcs.zig+2-2| ... | @@ -135,8 +135,8 @@ pub fn list_contains(haystack: [][]const u8, needle: []const u8) bool { | ... | @@ -135,8 +135,8 @@ pub fn list_contains(haystack: [][]const u8, needle: []const u8) bool { |
| 135 | return false; | 135 | return false; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | pub fn list_contains_gen(comptime T: type, haystack: *std.ArrayList(T), needle: T) bool { | 138 | pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool { |
| 139 | for (haystack.items) |item| { | 139 | for (haystack) |item| { |
| 140 | if (item.eql(needle)) { | 140 | if (item.eql(needle)) { |
| 141 | return true; | 141 | return true; |
| 142 | } | 142 | } |
src/util/module.zig+1-1| ... | @@ -32,7 +32,7 @@ pub const Module = struct { | ... | @@ -32,7 +32,7 @@ pub const Module = struct { |
| 32 | .c_include_dirs = dep.c_include_dirs, | 32 | .c_include_dirs = dep.c_include_dirs, |
| 33 | .c_source_flags = dep.c_source_flags, | 33 | .c_source_flags = dep.c_source_flags, |
| 34 | .c_source_files = dep.c_source_files, | 34 | .c_source_files = dep.c_source_files, |
| 35 | .deps = &[_]Module{}, | 35 | .deps = &.{}, |
| 36 | .clean_path = try dep.clean_path(), | 36 | .clean_path = try dep.clean_path(), |
| 37 | .only_os = dep.only_os, | 37 | .only_os = dep.only_os, |
| 38 | .except_os = dep.except_os, | 38 | .except_os = dep.except_os, |