| ... | ... | @@ -11,17 +11,18 @@ const common = @import("./../common.zig"); |
| 11 | 11 | |
| 12 | 12 | pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 13 | 13 | _ = self_name; |
| 14 | | _ = args; |
| 15 | 14 | |
| 16 | 15 | // |
| 17 | 16 | const gpa = std.heap.c_allocator; |
| 18 | 17 | const cachepath = try u.find_cachepath(); |
| 19 | 18 | const dir = std.fs.cwd(); |
| 19 | const should_lock = args.len >= 1 and std.mem.eql(u8, args[0], "--lock"); |
| 20 | 20 | |
| 21 | 21 | var options = common.CollectOptions{ |
| 22 | 22 | .log = false, |
| 23 | 23 | .update = false, |
| 24 | 24 | .alloc = gpa, |
| 25 | .lock = if (should_lock) try common.parse_lockfile(gpa, dir) else null, |
| 25 | 26 | }; |
| 26 | 27 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 27 | 28 | |
| ... | ... | @@ -30,10 +31,10 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 30 | 31 | |
| 31 | 32 | std.mem.sort(zigmod.Module, list.items, {}, zigmod.Module.lessThan); |
| 32 | 33 | |
| 33 | | try create_depszig(gpa, cachepath, dir, top_module, list.items); |
| 34 | try create_depszig(gpa, cachepath, dir, top_module, list.items, &options); |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.Dir, top_module: zigmod.Module, list: []const zigmod.Module) !void { |
| 37 | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.Dir, top_module: zigmod.Module, list: []const zigmod.Module, options: *common.CollectOptions) !void { |
| 37 | 38 | const f = try dir.createFile("deps.zig", .{}); |
| 38 | 39 | defer f.close(); |
| 39 | 40 | |
| ... | ... | @@ -104,7 +105,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 104 | 105 | .local => {}, |
| 105 | 106 | .system_lib => {}, |
| 106 | 107 | .framework => {}, |
| 107 | | .git => try w.print(" step.dependOn(&GitExactStep.create(b, \"{s}\", \"{s}\").step);\n", .{ module.dep.?.path, try module.pin(alloc, cachepath) }), |
| 108 | .git => try w.print(" step.dependOn(&GitExactStep.create(b, \"{s}\", \"{s}\").step);\n", .{ module.dep.?.path, try module.pin(alloc, cachepath, options) }), |
| 108 | 109 | .hg => @panic("TODO"), |
| 109 | 110 | .http => @panic("TODO"), |
| 110 | 111 | } |
| ... | ... | @@ -226,7 +227,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 226 | 227 | } |
| 227 | 228 | try duped.append(mod); |
| 228 | 229 | } |
| 229 | | try print_pkg_data_to(w, alloc, cachepath, &duped, &done); |
| 230 | try print_pkg_data_to(w, alloc, cachepath, &duped, &done, options); |
| 230 | 231 | try w.writeAll("};\n\n"); |
| 231 | 232 | |
| 232 | 233 | try w.writeAll("pub const packages = "); |
| ... | ... | @@ -267,7 +268,7 @@ fn print_deps(w: std.fs.File.Writer, m: zigmod.Module) !void { |
| 267 | 268 | try w.writeAll("}"); |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | | fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: string, notdone: *std.ArrayList(zigmod.Module), done: *std.ArrayList(zigmod.Module)) !void { |
| 271 | fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: string, notdone: *std.ArrayList(zigmod.Module), done: *std.ArrayList(zigmod.Module), options: *common.CollectOptions) !void { |
| 271 | 272 | var len: usize = notdone.items.len; |
| 272 | 273 | while (notdone.items.len > 0) { |
| 273 | 274 | for (notdone.items, 0..) |mod, i| { |
| ... | ... | @@ -282,13 +283,13 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 282 | 283 | switch (mod.type) { |
| 283 | 284 | .system_lib, .framework => {}, |
| 284 | 285 | .local => {}, |
| 285 | | .git => try w.print(" .store = \"/{}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath) }), |
| 286 | .git => try w.print(" .store = \"/{}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath, options) }), |
| 286 | 287 | .hg => @panic("TODO"), |
| 287 | 288 | .http => @panic("TODO"), |
| 288 | 289 | } |
| 289 | 290 | if (mod.main.len > 0 and !std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) { |
| 290 | 291 | try w.print(" .name = \"{s}\",\n", .{mod.name}); |
| 291 | | try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath), mod.main }); |
| 292 | try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath, options), mod.main }); |
| 292 | 293 | |
| 293 | 294 | if (mod.deps.len != 0) { |
| 294 | 295 | try w.writeAll(" .deps = &[_]*Package{"); |