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