| ... | ... | @@ -34,8 +34,7 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO |
| 34 | 34 | var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc); |
| 35 | 35 | defer moduledeps.deinit(); |
| 36 | 36 | if (m.root_files.len > 0) { |
| 37 | | try std.fs.cwd().makePath(".zigmod/deps/files"); |
| 38 | | try moduledeps.append(try add_files_package(options.alloc, "root", mdir, m.root_files)); |
| 37 | try moduledeps.append(try add_files_package(options.alloc, cachepath, "root", mdir, m.root_files)); |
| 39 | 38 | } |
| 40 | 39 | try moduledeps.append(try collect_deps(cachepath, mdir, options)); |
| 41 | 40 | for (m.devdeps) |*d| { |
| ... | ... | @@ -61,8 +60,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption |
| 61 | 60 | var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc); |
| 62 | 61 | defer moduledeps.deinit(); |
| 63 | 62 | if (m.files.len > 0) { |
| 64 | | try std.fs.cwd().makePath(".zigmod/deps/files"); |
| 65 | | try moduledeps.append(try add_files_package(options.alloc, m.id, mdir, m.files)); |
| 63 | try moduledeps.append(try add_files_package(options.alloc, cachepath, m.id, mdir, m.files)); |
| 66 | 64 | } |
| 67 | 65 | for (m.deps) |*d| { |
| 68 | 66 | if (try get_module_from_dep(d, cachepath, options)) |founddep| { |
| ... | ... | @@ -279,8 +277,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 279 | 277 | } |
| 280 | 278 | } |
| 281 | 279 | |
| 282 | | pub fn add_files_package(alloc: *std.mem.Allocator, pkg_name: string, mdir: std.fs.Dir, dirs: []const string) !zigmod.Module { |
| 283 | | const destination = ".zigmod/deps/files"; |
| 280 | pub fn add_files_package(alloc: *std.mem.Allocator, cachepath: string, pkg_name: string, mdir: std.fs.Dir, dirs: []const string) !zigmod.Module { |
| 284 | 281 | const fname = try std.mem.join(alloc, "", &.{ pkg_name, ".zig" }); |
| 285 | 282 | |
| 286 | 283 | const map = &std.StringHashMap(string).init(alloc); |
| ... | ... | @@ -304,7 +301,12 @@ pub fn add_files_package(alloc: *std.mem.Allocator, pkg_name: string, mdir: std. |
| 304 | 301 | var fpath = u.trim_prefix(mpath, cwdpath); |
| 305 | 302 | if (fpath.len == 0) fpath = std.fs.path.sep_str; |
| 306 | 303 | |
| 307 | | const rff = try (try std.fs.cwd().openDir(destination, .{})).createFile(fname, .{}); |
| 304 | var cachedir = try std.fs.cwd().openDir(cachepath, .{}); |
| 305 | defer cachedir.close(); |
| 306 | try cachedir.makePath("files"); |
| 307 | var destdir = try cachedir.openDir("files", .{}); |
| 308 | defer destdir.close(); |
| 309 | const rff = try destdir.createFile(fname, .{}); |
| 308 | 310 | defer rff.close(); |
| 309 | 311 | const w = rff.writer(); |
| 310 | 312 | try w.writeAll( |
| ... | ... | @@ -335,7 +337,8 @@ pub fn add_files_package(alloc: *std.mem.Allocator, pkg_name: string, mdir: std. |
| 335 | 337 | .update = false, |
| 336 | 338 | .alloc = alloc, |
| 337 | 339 | }; |
| 338 | | return (try get_module_from_dep(&d, destination, &options)).?; |
| 340 | const filesdestpath = try std.fs.path.join(alloc, &.{ cachepath, "files" }); |
| 341 | return (try get_module_from_dep(&d, filesdestpath, &options)).?; |
| 339 | 342 | } |
| 340 | 343 | |
| 341 | 344 | pub fn parse_lockfile(alloc: *std.mem.Allocator, dir: std.fs.Dir) ![]const [4]string { |