| ... | ... | @@ -101,6 +101,10 @@ pub fn create_depszig(dir: []const u8, top_module: u.Module, list: *std.ArrayLis |
| 101 | 101 | try w.writeAll("pub const pkgs = "); |
| 102 | 102 | try print_pkgs(w, top_module); |
| 103 | 103 | try w.writeAll(";\n\n"); |
| 104 | |
| 105 | try w.writeAll("pub const imports = struct {\n"); |
| 106 | try print_imports(w, top_module, dir); |
| 107 | try w.writeAll("};\n\n"); |
| 104 | 108 | } |
| 105 | 109 | |
| 106 | 110 | fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void { |
| ... | ... | @@ -241,3 +245,14 @@ fn print_pkgs(w: std.fs.File.Writer, m: u.Module) !void { |
| 241 | 245 | } |
| 242 | 246 | try w.writeAll("}"); |
| 243 | 247 | } |
| 248 | |
| 249 | fn print_imports(w: std.fs.File.Writer, m: u.Module, dir: []const u8) !void { |
| 250 | for (m.deps) |d| { |
| 251 | if (d.main.len == 0) { |
| 252 | continue; |
| 253 | } |
| 254 | const r1 = try std.mem.replaceOwned(u8, gpa, d.name, "-", "_"); |
| 255 | const r2 = try std.mem.replaceOwned(u8, gpa, r1, "/", "_"); |
| 256 | try w.print(" pub const {s} = @import(\"{s}/{}/{s}\");\n", .{ r2, dir, std.zig.fmtEscapes(d.clean_path), d.main }); |
| 257 | } |
| 258 | } |