| author | |
| committer | |
| log | 773b09ff745c30c0e02b6d4717e0da9cb10b2978 |
| tree | 2d9a771dddfa90375973757f8f32527ee62d002b |
| parent | d5d2b751e297e1ec5e80b2ac29b7c23d746c761b |
| signature |
18 files changed, 245 insertions(+), 186 deletions(-)
deps.zig+15-15| ... | ... | @@ -60,7 +60,7 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { |
| 60 | 60 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "40d141bf7db81f05a83cce5f2edc4b14e41a5c34").step); |
| 61 | 61 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "5f89211a749aef6bf518889c0467ceb24825c055").step); |
| 62 | 62 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "a1a066da88dab50873a56f0349dc12dc76542077").step); |
| 63 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "c2c581aa6a38438dd9ed8da0f59019691c5dd45d").step); | |
| 63 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "b3457b31a1d1ea2c19c5d0b007c903d3e80add40").step); | |
| 64 | 64 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-git", "2b3f83cd341764f979969603e4f77e62f353b6a3").step); |
| 65 | 65 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "4cddefa42744d61067567b0b36b5d2bb376e5ae3").step); |
| 66 | 66 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "a31b480914d15f3d13cdfb586aac950c73beebdd").step); |
| ... | ... | @@ -68,13 +68,13 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { |
| 68 | 68 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "618eddde4ffbc6d34100e4bc6aa654d41161537a").step); |
| 69 | 69 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "16cef5e32b3f8bbcf1064c599615290a720b6547").step); |
| 70 | 70 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "ba0f00dfb23d28c301e4b54d0a278def2c38dc7b").step); |
| 71 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "18b00c5c5d25e230ff4f3ea07fadb2a1d54a773d").step); | |
| 71 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "c855473c8bd15dd24a4e8b6911b7e006062004ba").step); | |
| 72 | 72 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-nio", "c1da2e8a31858880eb3e4cfcf12de0a865617623").step); |
| 73 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "c5c1b35492224b0ed8d2570c8e71702947b1e400").step); | |
| 74 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "9edefde5fcf96894b6aa4ab60241940bba65debf").step); | |
| 73 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "3265d1f06418eb0360d753c12116310a14b97bde").step); | |
| 74 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "f0b155d3627f8c19868be1b2f15d71cda908b575").step); | |
| 75 | 75 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "0f4db4c980146e4a3fc86a9a9070452a25ff9317").step); |
| 76 | 76 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "3a5fdea4ffd387a53ac2a42fb503557cdbe20696").step); |
| 77 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "b1ebd056b9afaaa719cb55359c610455ffe04499").step); | |
| 77 | step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "00e899bec815bc2b49c6e5a72a7cfeeda673e133").step); | |
| 78 | 78 | step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "ab212bd208f0eb54d85861679677c5e3dc9bb543").step); |
| 79 | 79 | step.dependOn(&GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498").step); |
| 80 | 80 | step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step); |
| ... | ... | @@ -210,9 +210,9 @@ pub const package_data = struct { |
| 210 | 210 | .entry = "/git/github.com/nektro/zig-ansi/5f89211a749aef6bf518889c0467ceb24825c055/src/lib.zig", |
| 211 | 211 | }; |
| 212 | 212 | pub var _f7dubzb7cyqe = Package{ |
| 213 | .store = "/git/github.com/nektro/zig-extras/c2c581aa6a38438dd9ed8da0f59019691c5dd45d", | |
| 213 | .store = "/git/github.com/nektro/zig-extras/b3457b31a1d1ea2c19c5d0b007c903d3e80add40", | |
| 214 | 214 | .name = "extras", |
| 215 | .entry = "/git/github.com/nektro/zig-extras/c2c581aa6a38438dd9ed8da0f59019691c5dd45d/src/lib.zig", | |
| 215 | .entry = "/git/github.com/nektro/zig-extras/b3457b31a1d1ea2c19c5d0b007c903d3e80add40/src/lib.zig", | |
| 216 | 216 | }; |
| 217 | 217 | pub var _c1xirp1ota5p = Package{ |
| 218 | 218 | .store = "/git/github.com/nektro/zig-inquirer/4cddefa42744d61067567b0b36b5d2bb376e5ae3", |
| ... | ... | @@ -231,14 +231,14 @@ pub const package_data = struct { |
| 231 | 231 | .entry = "/git/github.com/nektro/zig-licenses/16cef5e32b3f8bbcf1064c599615290a720b6547/src/lib.zig", |
| 232 | 232 | }; |
| 233 | 233 | pub var _73bukkeci2u6 = Package{ |
| 234 | .store = "/git/github.com/nektro/zig-sys-darwin/c5c1b35492224b0ed8d2570c8e71702947b1e400", | |
| 234 | .store = "/git/github.com/nektro/zig-sys-darwin/3265d1f06418eb0360d753c12116310a14b97bde", | |
| 235 | 235 | .name = "sys-darwin", |
| 236 | .entry = "/git/github.com/nektro/zig-sys-darwin/c5c1b35492224b0ed8d2570c8e71702947b1e400/sys_darwin.zig", | |
| 236 | .entry = "/git/github.com/nektro/zig-sys-darwin/3265d1f06418eb0360d753c12116310a14b97bde/sys_darwin.zig", | |
| 237 | 237 | }; |
| 238 | 238 | pub var _h7tv7ayhffak = Package{ |
| 239 | .store = "/git/github.com/nektro/zig-sys-linux/9edefde5fcf96894b6aa4ab60241940bba65debf", | |
| 239 | .store = "/git/github.com/nektro/zig-sys-linux/f0b155d3627f8c19868be1b2f15d71cda908b575", | |
| 240 | 240 | .name = "sys-linux", |
| 241 | .entry = "/git/github.com/nektro/zig-sys-linux/9edefde5fcf96894b6aa4ab60241940bba65debf/mod.zig", | |
| 241 | .entry = "/git/github.com/nektro/zig-sys-linux/f0b155d3627f8c19868be1b2f15d71cda908b575/mod.zig", | |
| 242 | 242 | .deps = &[_]*Package{ }, |
| 243 | 243 | .system_libs = &.{ "c" }, |
| 244 | 244 | }; |
| ... | ... | @@ -261,9 +261,9 @@ pub const package_data = struct { |
| 261 | 261 | .deps = &[_]*Package{ &_f7dubzb7cyqe, &_h7tv7ayhffak, &_73bukkeci2u6 }, |
| 262 | 262 | }; |
| 263 | 263 | pub var _vph9l0hxpeze = Package{ |
| 264 | .store = "/git/github.com/nektro/zig-nfs/18b00c5c5d25e230ff4f3ea07fadb2a1d54a773d", | |
| 264 | .store = "/git/github.com/nektro/zig-nfs/c855473c8bd15dd24a4e8b6911b7e006062004ba", | |
| 265 | 265 | .name = "nfs", |
| 266 | .entry = "/git/github.com/nektro/zig-nfs/18b00c5c5d25e230ff4f3ea07fadb2a1d54a773d/nfs.zig", | |
| 266 | .entry = "/git/github.com/nektro/zig-nfs/c855473c8bd15dd24a4e8b6911b7e006062004ba/nfs.zig", | |
| 267 | 267 | .deps = &[_]*Package{ &_h7tv7ayhffak, &_kscsl0145t7x, &_iecwp4b3bsfm, &_73bukkeci2u6 }, |
| 268 | 268 | }; |
| 269 | 269 | pub var _ede2wygpe1iy = Package{ |
| ... | ... | @@ -297,9 +297,9 @@ pub const package_data = struct { |
| 297 | 297 | .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i }, |
| 298 | 298 | }; |
| 299 | 299 | pub var _g982zq6e8wsv = Package{ |
| 300 | .store = "/git/github.com/nektro/zig-yaml/b1ebd056b9afaaa719cb55359c610455ffe04499", | |
| 300 | .store = "/git/github.com/nektro/zig-yaml/00e899bec815bc2b49c6e5a72a7cfeeda673e133", | |
| 301 | 301 | .name = "yaml", |
| 302 | .entry = "/git/github.com/nektro/zig-yaml/b1ebd056b9afaaa719cb55359c610455ffe04499/yaml.zig", | |
| 302 | .entry = "/git/github.com/nektro/zig-yaml/00e899bec815bc2b49c6e5a72a7cfeeda673e133/yaml.zig", | |
| 303 | 303 | .deps = &[_]*Package{ &_8mdbh0zuneb0 }, |
| 304 | 304 | }; |
| 305 | 305 | pub var _9k24gimke1an = Package{ |
src/cmd/ci.zig+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | const nfs = @import("nfs"); | |
| 3 | 4 | |
| 4 | 5 | const zigmod = @import("../lib.zig"); |
| 5 | 6 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -14,11 +15,11 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 14 | 15 | |
| 15 | 16 | const gpa = std.heap.c_allocator; |
| 16 | 17 | const cachepath = try u.find_cachepath(); |
| 17 | const dir = std.fs.cwd(); | |
| 18 | const dir = nfs.cwd(); | |
| 18 | 19 | try do(gpa, cachepath, dir); |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | pub fn do(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.Dir) !void { | |
| 22 | pub fn do(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nfs.Dir) !void { | |
| 22 | 23 | var options = common.CollectOptions{ |
| 23 | 24 | .log = true, |
| 24 | 25 | .update = false, |
src/cmd/explain.zig+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const extras = @import("extras"); |
| 4 | const nfs = @import("nfs"); | |
| 4 | 5 | |
| 5 | 6 | const zigmod = @import("../lib.zig"); |
| 6 | 7 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -14,7 +15,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 14 | 15 | |
| 15 | 16 | const gpa = std.heap.c_allocator; |
| 16 | 17 | const cachepath = try u.find_cachepath(); |
| 17 | const dir = std.fs.cwd(); | |
| 18 | const dir = nfs.cwd(); | |
| 18 | 19 | const should_lock = args.len >= 1 and std.mem.eql(u8, args[0], "--locked"); |
| 19 | 20 | const format_i: usize = if (should_lock) 1 else 0; |
| 20 | 21 | const Format = enum { |
src/cmd/fetch.zig+23-22| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const ansi = @import("ansi"); |
| 4 | 4 | const extras = @import("extras"); |
| 5 | const nfs = @import("nfs"); | |
| 5 | 6 | |
| 6 | 7 | const zigmod = @import("../lib.zig"); |
| 7 | 8 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -16,7 +17,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 16 | 17 | |
| 17 | 18 | const gpa = std.heap.c_allocator; |
| 18 | 19 | const cachepath = try u.find_cachepath(); |
| 19 | const dir = std.fs.cwd(); | |
| 20 | const dir = nfs.cwd(); | |
| 20 | 21 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); |
| 21 | 22 | |
| 22 | 23 | var options = common.CollectOptions{ |
| ... | ... | @@ -43,17 +44,17 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 43 | 44 | try license.do(cachepath, dir, &options, outfile); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.Dir, top_module: zigmod.Module, list: *std.ArrayList(zigmod.Module)) !void { | |
| 47 | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, top_module: zigmod.Module, list: *std.ArrayList(zigmod.Module)) !void { | |
| 47 | 48 | const f = try dir.createFile("deps.zig", .{}); |
| 48 | 49 | defer f.close(); |
| 49 | 50 | |
| 50 | const w = f.writer(); | |
| 51 | const w = f; | |
| 51 | 52 | try w.writeAll("// zig fmt: off\n"); |
| 52 | 53 | try w.writeAll("const std = @import(\"std\");\n"); |
| 53 | 54 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| 54 | 55 | try w.writeAll("const string = []const u8;\n"); |
| 55 | 56 | try w.writeAll("\n"); |
| 56 | try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)}); | |
| 57 | try w.print("pub const cache = \"{}\";\n", .{u.altStringEscape(cachepath)}); | |
| 57 | 58 | try w.writeAll("pub var skip_libc = false;\n"); |
| 58 | 59 | try w.writeAll("\n"); |
| 59 | 60 | try w.writeAll( |
| ... | ... | @@ -148,7 +149,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 148 | 149 | \\}} |
| 149 | 150 | \\ |
| 150 | 151 | \\ |
| 151 | , .{top_module.minZigVersion()}); | |
| 152 | , .{if (top_module.minZigVersion()) |sv| u.altSemanticVersion(sv) else null}); | |
| 152 | 153 | |
| 153 | 154 | try w.writeAll("pub const dirs = struct {\n"); |
| 154 | 155 | try print_dirs(w, list.items, alloc); |
| ... | ... | @@ -179,18 +180,18 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 179 | 180 | try w.writeAll("};\n"); |
| 180 | 181 | } |
| 181 | 182 | |
| 182 | fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module), path: string, dir: std.fs.Dir) !void { | |
| 183 | fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module), path: string, dir: nfs.Dir) !void { | |
| 183 | 184 | const fl = try dir.createFile("zigmod.lock", .{}); |
| 184 | 185 | defer fl.close(); |
| 185 | 186 | |
| 186 | 187 | std.mem.sort(zigmod.Module, list.items, {}, zigmod.Module.lessThan); |
| 187 | 188 | |
| 188 | const wl = fl.writer(); | |
| 189 | const wl = fl; | |
| 189 | 190 | try wl.writeAll("2\n"); |
| 190 | 191 | for (list.items) |m| { |
| 191 | 192 | if (m.dep) |md| { |
| 192 | 193 | if (md.type.isLocal()) continue; |
| 193 | const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path }); | |
| 194 | const mpath = try std.fs.path.joinZ(alloc, &.{ path, m.clean_path }); | |
| 194 | 195 | const version = try md.exact_version(alloc, mpath); |
| 195 | 196 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); |
| 196 | 197 | } |
| ... | ... | @@ -290,7 +291,7 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item: |
| 290 | 291 | return false; |
| 291 | 292 | } |
| 292 | 293 | |
| 293 | fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module, alloc: std.mem.Allocator) !void { | |
| 294 | fn print_dirs(w: nfs.File, list: []const zigmod.Module, alloc: std.mem.Allocator) !void { | |
| 294 | 295 | for (list) |mod| { |
| 295 | 296 | if (mod.type == .system_lib or mod.type == .framework) continue; |
| 296 | 297 | if (std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) { |
| ... | ... | @@ -298,15 +299,15 @@ fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module, alloc: std.mem |
| 298 | 299 | continue; |
| 299 | 300 | } |
| 300 | 301 | if (std.mem.eql(u8, mod.clean_path, "../..")) { |
| 301 | const cwd_realpath = try std.fs.cwd().realpathAlloc(alloc, "."); | |
| 302 | try w.print(" pub const _{s} = \"{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(cwd_realpath) }); | |
| 302 | const cwd_realpath = try nfs.cwd().realpathAlloc(alloc, "."); | |
| 303 | try w.print(" pub const _{s} = \"{}\";\n", .{ mod.short_id(), u.altStringEscape(cwd_realpath) }); | |
| 303 | 304 | continue; |
| 304 | 305 | } |
| 305 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) }); | |
| 306 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), u.altStringEscape(mod.clean_path) }); | |
| 306 | 307 | } |
| 307 | 308 | } |
| 308 | 309 | |
| 309 | fn print_deps(w: std.fs.File.Writer, m: zigmod.Module) !void { | |
| 310 | fn print_deps(w: nfs.File, m: zigmod.Module) !void { | |
| 310 | 311 | try w.writeAll("&[_]*const Package{\n"); |
| 311 | 312 | for (m.deps) |d| { |
| 312 | 313 | if (d.main.len == 0) { |
| ... | ... | @@ -320,7 +321,7 @@ fn print_deps(w: std.fs.File.Writer, m: zigmod.Module) !void { |
| 320 | 321 | try w.writeAll("}"); |
| 321 | 322 | } |
| 322 | 323 | |
| 323 | fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Module), done: *std.ArrayList(zigmod.Module)) !void { | |
| 324 | fn print_pkg_data_to(w: nfs.File, notdone: *std.ArrayList(zigmod.Module), done: *std.ArrayList(zigmod.Module)) !void { | |
| 324 | 325 | var len: usize = notdone.items.len; |
| 325 | 326 | while (notdone.items.len > 0) { |
| 326 | 327 | for (notdone.items, 0..) |mod, i| { |
| ... | ... | @@ -359,7 +360,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 359 | 360 | if (mod.c_include_dirs.len > 0) { |
| 360 | 361 | try w.writeAll(" .c_include_dirs = &.{"); |
| 361 | 362 | for (mod.c_include_dirs, 0..) |item, j| { |
| 362 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 363 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 363 | 364 | if (j != mod.c_include_dirs.len - 1) try w.writeAll(","); |
| 364 | 365 | } |
| 365 | 366 | try w.writeAll(" },\n"); |
| ... | ... | @@ -367,7 +368,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 367 | 368 | if (mod.c_source_files.len > 0) { |
| 368 | 369 | try w.writeAll(" .c_source_files = &.{"); |
| 369 | 370 | for (mod.c_source_files, 0..) |item, j| { |
| 370 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 371 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 371 | 372 | if (j != mod.c_source_files.len - 1) try w.writeAll(","); |
| 372 | 373 | } |
| 373 | 374 | try w.writeAll(" },\n"); |
| ... | ... | @@ -375,7 +376,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 375 | 376 | if (mod.c_source_flags.len > 0) { |
| 376 | 377 | try w.writeAll(" .c_source_flags = &.{"); |
| 377 | 378 | for (mod.c_source_flags, 0..) |item, j| { |
| 378 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 379 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 379 | 380 | if (j != mod.c_source_flags.len - 1) try w.writeAll(","); |
| 380 | 381 | } |
| 381 | 382 | try w.writeAll(" },\n"); |
| ... | ... | @@ -384,7 +385,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 384 | 385 | try w.writeAll(" .system_libs = &.{"); |
| 385 | 386 | for (mod.deps, 0..) |item, j| { |
| 386 | 387 | if (!(item.type == .system_lib)) continue; |
| 387 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); | |
| 388 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | |
| 388 | 389 | if (j != mod.deps.len - 1) try w.writeAll(","); |
| 389 | 390 | } |
| 390 | 391 | try w.writeAll(" },\n"); |
| ... | ... | @@ -393,7 +394,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 393 | 394 | try w.writeAll(" .frameworks = &.{"); |
| 394 | 395 | for (mod.deps, 0..) |item, j| { |
| 395 | 396 | if (!(item.type == .system_lib)) continue; |
| 396 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); | |
| 397 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | |
| 397 | 398 | if (j != mod.deps.len - 1) try w.writeAll(","); |
| 398 | 399 | } |
| 399 | 400 | try w.writeAll(" },\n"); |
| ... | ... | @@ -422,7 +423,7 @@ fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool |
| 422 | 423 | return true; |
| 423 | 424 | } |
| 424 | 425 | |
| 425 | fn print_pkgs(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module) !void { | |
| 426 | fn print_pkgs(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module) !void { | |
| 426 | 427 | try w.writeAll("struct {\n"); |
| 427 | 428 | for (m.deps) |d| { |
| 428 | 429 | if (d.main.len == 0) { |
| ... | ... | @@ -437,7 +438,7 @@ fn print_pkgs(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module) |
| 437 | 438 | try w.writeAll("}"); |
| 438 | 439 | } |
| 439 | 440 | |
| 440 | fn print_imports(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module, path: string) !void { | |
| 441 | fn print_imports(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module, path: string) !void { | |
| 441 | 442 | for (m.deps) |d| { |
| 442 | 443 | if (d.main.len == 0) { |
| 443 | 444 | continue; |
| ... | ... | @@ -446,7 +447,7 @@ fn print_imports(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Modu |
| 446 | 447 | continue; |
| 447 | 448 | } |
| 448 | 449 | const ident = try zig_name_from_pkg_name(alloc, d.name); |
| 449 | try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ ident, std.zig.fmtEscapes(path), std.zig.fmtEscapes(d.clean_path), d.main }); | |
| 450 | try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ ident, u.altStringEscape(path), u.altStringEscape(d.clean_path), d.main }); | |
| 450 | 451 | } |
| 451 | 452 | } |
| 452 | 453 |
src/cmd/generate.zig+19-18| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const extras = @import("extras"); |
| 4 | const nfs = @import("nfs"); | |
| 4 | 5 | |
| 5 | 6 | const zigmod = @import("../lib.zig"); |
| 6 | 7 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -15,7 +16,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 15 | 16 | // |
| 16 | 17 | const gpa = std.heap.c_allocator; |
| 17 | 18 | const cachepath = try u.find_cachepath(); |
| 18 | const dir = std.fs.cwd(); | |
| 19 | const dir = nfs.cwd(); | |
| 19 | 20 | const should_lock = args.len >= 1 and std.mem.eql(u8, args[0], "--locked"); |
| 20 | 21 | |
| 21 | 22 | var options = common.CollectOptions{ |
| ... | ... | @@ -34,11 +35,11 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 34 | 35 | try create_depszig(gpa, cachepath, dir, top_module, list.items, &options); |
| 35 | 36 | } |
| 36 | 37 | |
| 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 { | |
| 38 | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nfs.Dir, top_module: zigmod.Module, list: []const zigmod.Module, options: *common.CollectOptions) !void { | |
| 38 | 39 | const f = try dir.createFile("deps.zig", .{}); |
| 39 | 40 | defer f.close(); |
| 40 | 41 | |
| 41 | const w = f.writer(); | |
| 42 | const w = f; | |
| 42 | 43 | try w.writeAll("// zig fmt: off\n"); |
| 43 | 44 | try w.writeAll("const std = @import(\"std\");\n"); |
| 44 | 45 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| ... | ... | @@ -225,7 +226,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 225 | 226 | \\}} |
| 226 | 227 | \\ |
| 227 | 228 | \\ |
| 228 | , .{top_module.minZigVersion()}); | |
| 229 | , .{if (top_module.minZigVersion()) |sv| u.altSemanticVersion(sv) else null}); | |
| 229 | 230 | |
| 230 | 231 | try w.writeAll("pub const package_data = struct {\n"); |
| 231 | 232 | var duped = std.ArrayList(zigmod.Module).init(alloc); |
| ... | ... | @@ -252,18 +253,18 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 252 | 253 | try w.writeAll("};\n"); |
| 253 | 254 | } |
| 254 | 255 | |
| 255 | fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void { | |
| 256 | fn print_dirs(w: nfs.File, list: []const zigmod.Module) !void { | |
| 256 | 257 | for (list) |mod| { |
| 257 | 258 | if (mod.type == .system_lib or mod.type == .framework) continue; |
| 258 | 259 | if (std.mem.eql(u8, mod.id, "root")) { |
| 259 | 260 | try w.writeAll(" pub const _root = \"\";\n"); |
| 260 | 261 | continue; |
| 261 | 262 | } |
| 262 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) }); | |
| 263 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), u.altStringEscape(mod.clean_path) }); | |
| 263 | 264 | } |
| 264 | 265 | } |
| 265 | 266 | |
| 266 | fn print_deps(w: std.fs.File.Writer, m: zigmod.Module) !void { | |
| 267 | fn print_deps(w: nfs.File, m: zigmod.Module) !void { | |
| 267 | 268 | try w.writeAll("[_]*Package{\n"); |
| 268 | 269 | for (m.deps) |d| { |
| 269 | 270 | if (d.main.len == 0) { |
| ... | ... | @@ -277,7 +278,7 @@ fn print_deps(w: std.fs.File.Writer, m: zigmod.Module) !void { |
| 277 | 278 | try w.writeAll("}"); |
| 278 | 279 | } |
| 279 | 280 | |
| 280 | 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 { | |
| 281 | fn print_pkg_data_to(w: nfs.File, alloc: std.mem.Allocator, cachepath: [:0]const u8, notdone: *std.ArrayList(zigmod.Module), done: *std.ArrayList(zigmod.Module), options: *common.CollectOptions) !void { | |
| 281 | 282 | var len: usize = notdone.items.len; |
| 282 | 283 | while (notdone.items.len > 0) { |
| 283 | 284 | for (notdone.items, 0..) |mod, i| { |
| ... | ... | @@ -292,13 +293,13 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 292 | 293 | switch (mod.type) { |
| 293 | 294 | .system_lib, .framework => {}, |
| 294 | 295 | .local => {}, |
| 295 | .git => try w.print(" .store = \"/{}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath, options) }), | |
| 296 | .git => try w.print(" .store = \"/{}/{s}\",\n", .{ u.altStringEscape(fixed_path), try mod.pin(alloc, cachepath, options) }), | |
| 296 | 297 | .hg => @panic("TODO"), |
| 297 | 298 | .http => @panic("TODO"), |
| 298 | 299 | } |
| 299 | 300 | if (mod.main.len > 0 and !std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) { |
| 300 | 301 | try w.print(" .name = \"{s}\",\n", .{mod.name}); |
| 301 | try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath, options), mod.main }); | |
| 302 | try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ u.altStringEscape(fixed_path), try mod.pin(alloc, cachepath, options), mod.main }); | |
| 302 | 303 | |
| 303 | 304 | if (mod.deps.len != 0) { |
| 304 | 305 | try w.writeAll(" .deps = &[_]*Package{"); |
| ... | ... | @@ -313,7 +314,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 313 | 314 | if (mod.c_include_dirs.len > 0) { |
| 314 | 315 | try w.writeAll(" .c_include_dirs = &.{"); |
| 315 | 316 | for (mod.c_include_dirs, 0..) |item, j| { |
| 316 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 317 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 317 | 318 | if (j != mod.c_include_dirs.len - 1) try w.writeAll(","); |
| 318 | 319 | } |
| 319 | 320 | try w.writeAll(" },\n"); |
| ... | ... | @@ -321,7 +322,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 321 | 322 | if (mod.c_source_files.len > 0) { |
| 322 | 323 | try w.writeAll(" .c_source_files = &.{"); |
| 323 | 324 | for (mod.c_source_files, 0..) |item, j| { |
| 324 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 325 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 325 | 326 | if (j != mod.c_source_files.len - 1) try w.writeAll(","); |
| 326 | 327 | } |
| 327 | 328 | try w.writeAll(" },\n"); |
| ... | ... | @@ -329,7 +330,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 329 | 330 | if (mod.c_source_flags.len > 0) { |
| 330 | 331 | try w.writeAll(" .c_source_flags = &.{"); |
| 331 | 332 | for (mod.c_source_flags, 0..) |item, j| { |
| 332 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item)}); | |
| 333 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | |
| 333 | 334 | if (j != mod.c_source_flags.len - 1) try w.writeAll(","); |
| 334 | 335 | } |
| 335 | 336 | try w.writeAll(" },\n"); |
| ... | ... | @@ -338,7 +339,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 338 | 339 | try w.writeAll(" .system_libs = &.{"); |
| 339 | 340 | for (mod.deps, 0..) |item, j| { |
| 340 | 341 | if (!(item.type == .system_lib)) continue; |
| 341 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); | |
| 342 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | |
| 342 | 343 | if (j != mod.deps.len - 1) try w.writeAll(","); |
| 343 | 344 | } |
| 344 | 345 | try w.writeAll(" },\n"); |
| ... | ... | @@ -347,7 +348,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 347 | 348 | try w.writeAll(" .frameworks = &.{"); |
| 348 | 349 | for (mod.deps, 0..) |item, j| { |
| 349 | 350 | if (!(item.type == .system_lib)) continue; |
| 350 | try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); | |
| 351 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | |
| 351 | 352 | if (j != mod.deps.len - 1) try w.writeAll(","); |
| 352 | 353 | } |
| 353 | 354 | try w.writeAll(" },\n"); |
| ... | ... | @@ -376,7 +377,7 @@ fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool |
| 376 | 377 | return true; |
| 377 | 378 | } |
| 378 | 379 | |
| 379 | fn print_pkgs(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module) !void { | |
| 380 | fn print_pkgs(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module) !void { | |
| 380 | 381 | try w.writeAll("struct {\n"); |
| 381 | 382 | for (m.deps) |d| { |
| 382 | 383 | if (d.main.len == 0) { |
| ... | ... | @@ -391,7 +392,7 @@ fn print_pkgs(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module) |
| 391 | 392 | try w.writeAll("}"); |
| 392 | 393 | } |
| 393 | 394 | |
| 394 | fn print_imports(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Module, path: string) !void { | |
| 395 | fn print_imports(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module, path: string) !void { | |
| 395 | 396 | for (m.deps) |d| { |
| 396 | 397 | if (d.main.len == 0) { |
| 397 | 398 | continue; |
| ... | ... | @@ -400,7 +401,7 @@ fn print_imports(alloc: std.mem.Allocator, w: std.fs.File.Writer, m: zigmod.Modu |
| 400 | 401 | continue; |
| 401 | 402 | } |
| 402 | 403 | const ident = try zig_name_from_pkg_name(alloc, d.name); |
| 403 | try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ ident, std.zig.fmtEscapes(path), std.zig.fmtEscapes(d.clean_path), d.main }); | |
| 404 | try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ ident, u.altStringEscape(path), u.altStringEscape(d.clean_path), d.main }); | |
| 404 | 405 | } |
| 405 | 406 | } |
| 406 | 407 |
src/cmd/init.zig+21-19| ... | ... | @@ -9,6 +9,7 @@ const ini = @import("ini"); |
| 9 | 9 | const time = @import("time"); |
| 10 | 10 | const extras = @import("extras"); |
| 11 | 11 | const nio = @import("nio"); |
| 12 | const nfs = @import("nfs"); | |
| 12 | 13 | |
| 13 | 14 | const u = @import("./../util/funcs.zig"); |
| 14 | 15 | const common = @import("./../common.zig"); |
| ... | ... | @@ -25,9 +26,9 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 25 | 26 | std.debug.print("Press ^C at any time to quit.\n", .{}); |
| 26 | 27 | std.debug.print("\n", .{}); |
| 27 | 28 | |
| 28 | const stdout = std.io.getStdOut().writer(); | |
| 29 | const stdin = std.io.getStdIn().reader(); | |
| 30 | const cwd = std.fs.cwd(); | |
| 29 | const stdout = nfs.stdout(); | |
| 30 | const stdin = nfs.stdin(); | |
| 31 | const cwd = nfs.cwd(); | |
| 31 | 32 | |
| 32 | 33 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", string, "{s}", &u.random_string(48)); |
| 33 | 34 | |
| ... | ... | @@ -38,12 +39,13 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 38 | 39 | const flatname = try gpa.dupe(u8, name); |
| 39 | 40 | _ = std.mem.replaceScalar(u8, flatname, '-', '_'); |
| 40 | 41 | |
| 41 | const entry = if (ptype == .lib) try inquirer.forString(stdout, stdin, "package entry point:", gpa, u.detct_mainfile(gpa, u.try_index(string, args, 1, ""), null, name) catch |err| switch (err) { | |
| 42 | const entry_bare = if (ptype == .lib) try inquirer.forString(stdout, stdin, "package entry point:", gpa, u.detct_mainfile(gpa, u.try_index(string, args, 1, ""), .cwd(), name) catch |err| switch (err) { | |
| 42 | 43 | error.CantFindMain => try std.mem.concat(gpa, u8, &.{ flatname, ".zig" }), |
| 43 | 44 | else => |ee| return ee, |
| 44 | 45 | }) else null; |
| 46 | const entry = if (entry_bare) |ent| try gpa.dupeZ(u8, ent) else null; | |
| 45 | 47 | |
| 46 | const maybe_license_text = try detectlicense.detectInDir(gpa, cwd); | |
| 48 | const maybe_license_text = try detectlicense.detectInDir(gpa, cwd.to_std()); | |
| 47 | 49 | const license = try inquirer.forString(stdout, stdin, "license:", gpa, maybe_license_text); |
| 48 | 50 | |
| 49 | 51 | const description = try inquirer.forString(stdout, stdin, "description:", gpa, null); |
| ... | ... | @@ -66,7 +68,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 66 | 68 | true => { |
| 67 | 69 | const file = try cwd.createFile("zigmod.yml", .{}); |
| 68 | 70 | defer file.close(); |
| 69 | const w = file.writer(); | |
| 71 | const w = file; | |
| 70 | 72 | switch (ptype) { |
| 71 | 73 | .exe => try writeExeManifest(w, id, name, license, description), |
| 72 | 74 | .lib => try writeLibManifest(w, id, name, license, description, entry.?), |
| ... | ... | @@ -98,7 +100,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 98 | 100 | |
| 99 | 101 | const file = try cwd.createFile("LICENSE", .{}); |
| 100 | 102 | defer file.close(); |
| 101 | const w = file.writer(); | |
| 103 | const w = file; | |
| 102 | 104 | |
| 103 | 105 | // properly format license text to fit within 80 columns |
| 104 | 106 | var start: usize = 0; |
| ... | ... | @@ -140,12 +142,12 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 140 | 142 | const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitignore?", gpa); |
| 141 | 143 | if (do) { |
| 142 | 144 | const exists = try extras.doesFileExist(null, ".gitignore"); |
| 143 | const file: std.fs.File = try (if (exists) cwd.openFile(".gitignore", .{ .mode = .read_write }) else cwd.createFile(".gitignore", .{})); | |
| 145 | const file: nfs.File = try (if (exists) cwd.openFile(".gitignore", .{ .mode = .read_write }) else cwd.createFile(".gitignore", .{})); | |
| 144 | 146 | defer file.close(); |
| 145 | 147 | const len = try file.getEndPos(); |
| 146 | 148 | if (len > 0) try file.seekTo(len - 1); |
| 147 | const w = file.writer(); | |
| 148 | if (len > 0 and (try file.reader().readByte()) != '\n') { | |
| 149 | const w = file; | |
| 150 | if (len > 0 and (try file.readByte()) != '\n') { | |
| 149 | 151 | try w.writeAll("\n"); |
| 150 | 152 | } |
| 151 | 153 | if (!exists) try w.writeAll(".zig-cache\n"); |
| ... | ... | @@ -162,12 +164,12 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 162 | 164 | const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitattributes?", gpa); |
| 163 | 165 | if (do) { |
| 164 | 166 | const exists = try extras.doesFileExist(null, ".gitattributes"); |
| 165 | const file: std.fs.File = try (if (exists) cwd.openFile(".gitattributes", .{ .mode = .read_write }) else cwd.createFile(".gitattributes", .{})); | |
| 167 | const file: nfs.File = try (if (exists) cwd.openFile(".gitattributes", .{ .mode = .read_write }) else cwd.createFile(".gitattributes", .{})); | |
| 166 | 168 | defer file.close(); |
| 167 | 169 | const len = try file.getEndPos(); |
| 168 | 170 | if (len > 0) try file.seekTo(len - 1); |
| 169 | const w = file.writer(); | |
| 170 | if (len > 0 and (try file.reader().readByte()) != '\n') { | |
| 171 | const w = file; | |
| 172 | if (len > 0 and (try file.readByte()) != '\n') { | |
| 171 | 173 | try w.writeAll("\n"); |
| 172 | 174 | } |
| 173 | 175 | if (!exists) try w.writeAll("* text=auto\n"); |
| ... | ... | @@ -182,7 +184,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 182 | 184 | if (do) { |
| 183 | 185 | const file = try cwd.createFile("build.zig", .{}); |
| 184 | 186 | defer file.close(); |
| 185 | const w = file.writer(); | |
| 187 | const w = file; | |
| 186 | 188 | switch (ptype) { |
| 187 | 189 | .exe => { |
| 188 | 190 | try w.writeAll( |
| ... | ... | @@ -249,7 +251,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 249 | 251 | if (do) { |
| 250 | 252 | const file = try cwd.createFile(entry orelse "main.zig", .{}); |
| 251 | 253 | defer file.close(); |
| 252 | const w = file.writer(); | |
| 254 | const w = file; | |
| 253 | 255 | switch (ptype) { |
| 254 | 256 | .exe => { |
| 255 | 257 | try w.print( |
| ... | ... | @@ -283,7 +285,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 283 | 285 | if (do) { |
| 284 | 286 | const file = try cwd.createFile("test.zig", .{}); |
| 285 | 287 | defer file.close(); |
| 286 | const w = file.writer(); | |
| 288 | const w = file; | |
| 287 | 289 | try w.print( |
| 288 | 290 | \\const std = @import("std"); |
| 289 | 291 | \\const {s} = @import("{s}"); |
| ... | ... | @@ -301,7 +303,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 301 | 303 | { |
| 302 | 304 | const alloc = gpa; |
| 303 | 305 | const cachepath = try u.find_cachepath(); |
| 304 | const dir = std.fs.cwd(); | |
| 306 | const dir = nfs.cwd(); | |
| 305 | 307 | |
| 306 | 308 | var options = common.CollectOptions{ |
| 307 | 309 | .log = true, |
| ... | ... | @@ -318,7 +320,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 318 | 320 | } |
| 319 | 321 | } |
| 320 | 322 | |
| 321 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { | |
| 323 | pub fn writeExeManifest(w: nfs.File, id: string, name: string, license: ?string, description: ?string) !void { | |
| 322 | 324 | try w.print("id: {s}\n", .{id}); |
| 323 | 325 | try w.print("name: {s}\n", .{name}); |
| 324 | 326 | if (license) |_| try w.print("license: {s}\n", .{license.?}); |
| ... | ... | @@ -328,7 +330,7 @@ pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license |
| 328 | 330 | try w.writeAll("root_dependencies:\n"); |
| 329 | 331 | } |
| 330 | 332 | |
| 331 | pub fn writeLibManifest(w: std.fs.File.Writer, id: string, name: string, license: string, description: string, entry: string) !void { | |
| 333 | pub fn writeLibManifest(w: nfs.File, id: string, name: string, license: string, description: string, entry: string) !void { | |
| 332 | 334 | try w.print("id: {s}\n", .{id}); |
| 333 | 335 | try w.print("name: {s}\n", .{name}); |
| 334 | 336 | try w.print("main: {s}\n", .{entry}); |
src/cmd/install.zig+7-6| ... | ... | @@ -4,6 +4,7 @@ const gpa = std.heap.c_allocator; |
| 4 | 4 | const knownfolders = @import("known-folders"); |
| 5 | 5 | const extras = @import("extras"); |
| 6 | 6 | const nio = @import("nio"); |
| 7 | const nfs = @import("nfs"); | |
| 7 | 8 | |
| 8 | 9 | const zigmod = @import("./../lib.zig"); |
| 9 | 10 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -48,8 +49,8 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 48 | 49 | .for_build = false, |
| 49 | 50 | }; |
| 50 | 51 | const clean_path = try dep.clean_path(gpa); |
| 51 | const cachepath = try std.fs.path.join(gpa, &.{ cache, "zigmod", "deps" }); | |
| 52 | const modpath = try std.fs.path.join(gpa, &.{ cachepath, clean_path }); | |
| 52 | const cachepath = try std.fs.path.joinZ(gpa, &.{ cache, "zigmod", "deps" }); | |
| 53 | const modpath = try std.fs.path.joinZ(gpa, &.{ cachepath, clean_path }); | |
| 53 | 54 | std.log.debug("modpath: {s}", .{modpath}); |
| 54 | 55 | |
| 55 | 56 | if (!try extras.doesFolderExist(null, modpath)) { |
| ... | ... | @@ -58,14 +59,14 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 58 | 59 | try dep.type.update(gpa, modpath, ""); |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | const moddir = try std.fs.cwd().openDir(modpath, .{}); | |
| 62 | const moddir = try nfs.cwd().openDir(modpath, .{}); | |
| 62 | 63 | const ci = @import("./ci.zig"); |
| 63 | 64 | try ci.do(gpa, cachepath, moddir); |
| 64 | 65 | |
| 65 | 66 | const modfile = try zigmod.ModFile.from_dir(gpa, moddir, modpath); |
| 66 | _ = modfile.min_zig_version orelse u.fail("zigmod manifest requires min_zig_version field", .{}); | |
| 67 | const zigversion = try nio.fmt.allocPrint(gpa, "{s}", .{modfile.yaml.get_string("min_zig_version").?}); | |
| 68 | const zigpath = try std.fs.path.join(gpa, &.{ datapath, "zig", zigversion, "zig" }); | |
| 67 | const zigversion_sv = modfile.min_zig_version orelse u.fail("zigmod manifest requires min_zig_version field", .{}); | |
| 68 | const zigversion = try nio.fmt.allocPrint(gpa, "{s}", .{u.altSemanticVersion(zigversion_sv)}); | |
| 69 | const zigpath = try std.fs.path.joinZ(gpa, &.{ datapath, "zig", zigversion, "zig" }); | |
| 69 | 70 | |
| 70 | 71 | // zig build |
| 71 | 72 | const argv: []const string = &.{ |
src/cmd/license.zig+6-5| ... | ... | @@ -4,6 +4,7 @@ const string = []const u8; |
| 4 | 4 | const style = @import("ansi").style; |
| 5 | 5 | const licenses = @import("licenses"); |
| 6 | 6 | const extras = @import("extras"); |
| 7 | const nfs = @import("nfs"); | |
| 7 | 8 | |
| 8 | 9 | const zigmod = @import("../lib.zig"); |
| 9 | 10 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -20,7 +21,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 20 | 21 | _ = args; |
| 21 | 22 | |
| 22 | 23 | const cachepath = try u.find_cachepath(); |
| 23 | const dir = std.fs.cwd(); | |
| 24 | const dir = nfs.cwd(); | |
| 24 | 25 | |
| 25 | 26 | var options = common.CollectOptions{ |
| 26 | 27 | .log = false, |
| ... | ... | @@ -28,10 +29,10 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 28 | 29 | .alloc = gpa, |
| 29 | 30 | }; |
| 30 | 31 | |
| 31 | try do(cachepath, dir, &options, std.io.getStdOut()); | |
| 32 | try do(cachepath, dir, &options, .stdout()); | |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | pub fn do(cachepath: string, dir: std.fs.Dir, options: *common.CollectOptions, outfile: std.fs.File) !void { | |
| 35 | pub fn do(cachepath: [:0]const u8, dir: nfs.Dir, options: *common.CollectOptions, outfile: nfs.File) !void { | |
| 35 | 36 | const top_module = try common.collect_deps_deep(cachepath, dir, options); |
| 36 | 37 | |
| 37 | 38 | var master_list = List.init(gpa); |
| ... | ... | @@ -71,8 +72,8 @@ pub fn do(cachepath: string, dir: std.fs.Dir, options: *common.CollectOptions, o |
| 71 | 72 | try tracking_list.append(item); |
| 72 | 73 | } |
| 73 | 74 | |
| 74 | const istty = outfile.isTty(); | |
| 75 | const writer = outfile.writer(); | |
| 75 | const istty = outfile.isatty(); | |
| 76 | const writer = outfile; | |
| 76 | 77 | const Bold = if (!istty) "" else style.Bold; |
| 77 | 78 | const Faint = if (!istty) "" else style.Faint; |
| 78 | 79 | const ResetIntensity = if (!istty) "" else style.ResetIntensity; |
src/cmd/sum.zig+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const gpa = std.heap.c_allocator; |
| 3 | const nfs = @import("nfs"); | |
| 3 | 4 | |
| 4 | 5 | const zigmod = @import("../lib.zig"); |
| 5 | 6 | const u = @import("./../util/funcs.zig"); |
| ... | ... | @@ -13,7 +14,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 13 | 14 | _ = args; |
| 14 | 15 | |
| 15 | 16 | const cachepath = try u.find_cachepath(); |
| 16 | const dir = std.fs.cwd(); | |
| 17 | const dir = nfs.cwd(); | |
| 17 | 18 | |
| 18 | 19 | var options = common.CollectOptions{ |
| 19 | 20 | .log = false, |
| ... | ... | @@ -25,7 +26,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 25 | 26 | // |
| 26 | 27 | const f = try dir.createFile("zigmod.sum", .{}); |
| 27 | 28 | defer f.close(); |
| 28 | const w = f.writer(); | |
| 29 | const w = f; | |
| 29 | 30 | |
| 30 | 31 | // |
| 31 | 32 | var module_list = std.ArrayList(zigmod.Module).init(gpa); |
src/cmd/version.zig+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const gpa = std.heap.c_allocator; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | const nfs = @import("nfs"); | |
| 4 | 5 | |
| 5 | 6 | const u = @import("./../util/funcs.zig"); |
| 6 | 7 | |
| ... | ... | @@ -14,7 +15,7 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 14 | 15 | const root = @import("root"); |
| 15 | 16 | const version = root.build_options.version; |
| 16 | 17 | |
| 17 | var gitversion = u.git_rev_HEAD(gpa, std.fs.cwd()) catch ""; | |
| 18 | var gitversion = u.git_rev_HEAD(gpa, nfs.cwd()) catch ""; | |
| 18 | 19 | gitversion = if (gitversion.len > 0) gitversion[0..9] else gitversion; |
| 19 | 20 | |
| 20 | 21 | const stdout = std.io.getStdOut(); |
src/cmd/zpm/add.zig+3-2| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const gpa = std.heap.c_allocator; |
| 3 | 3 | const zfetch = @import("zfetch"); |
| 4 | 4 | const extras = @import("extras"); |
| 5 | const nfs = @import("nfs"); | |
| 5 | 6 | |
| 6 | 7 | const zigmod = @import("../../lib.zig"); |
| 7 | 8 | const u = @import("./../../util/funcs.zig"); |
| ... | ... | @@ -57,11 +58,11 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { |
| 57 | 58 | break :blk @intFromEnum(_req.status) == 200; |
| 58 | 59 | }; |
| 59 | 60 | |
| 60 | _, const file = try zigmod.ModFile.openFile(std.fs.cwd(), .{ .mode = .read_write }); | |
| 61 | _, const file = try zigmod.ModFile.openFile(nfs.cwd(), .{ .mode = .read_write }); | |
| 61 | 62 | defer file.close(); |
| 62 | 63 | try file.seekTo(try file.getEndPos()); |
| 63 | 64 | |
| 64 | const file_w = file.writer(); | |
| 65 | const file_w = file; | |
| 65 | 66 | try file_w.writeAll("\n"); |
| 66 | 67 | try file_w.print(" - src: git {s}\n", .{extras.trimSuffix(found.git, ".git")}); |
| 67 | 68 | if (!(has_zigdotmod or has_zigmodyml)) { |
src/common.zig+49-40| ... | ... | @@ -4,10 +4,13 @@ const builtin = @import("builtin"); |
| 4 | 4 | const ansi = @import("ansi"); |
| 5 | 5 | const extras = @import("extras"); |
| 6 | 6 | const nio = @import("nio"); |
| 7 | const nfs = @import("nfs"); | |
| 7 | 8 | |
| 8 | 9 | const zigmod = @import("./lib.zig"); |
| 9 | 10 | const u = @import("./util/funcs.zig"); |
| 10 | 11 | |
| 12 | const gpa = std.heap.c_allocator; | |
| 13 | ||
| 11 | 14 | // |
| 12 | 15 | // |
| 13 | 16 | |
| ... | ... | @@ -24,8 +27,8 @@ pub const CollectOptions = struct { |
| 24 | 27 | } |
| 25 | 28 | }; |
| 26 | 29 | |
| 27 | pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectOptions) !zigmod.Module { | |
| 28 | try std.fs.cwd().makePath(cachepath); | |
| 30 | pub fn collect_deps_deep(cachepath: [:0]const u8, mdir: nfs.Dir, options: *CollectOptions) !zigmod.Module { | |
| 31 | try nfs.cwd().makePath(cachepath); | |
| 29 | 32 | |
| 30 | 33 | const m = try zigmod.ModFile.from_dir(options.alloc, mdir, "."); |
| 31 | 34 | try options.init(); |
| ... | ... | @@ -58,8 +61,8 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO |
| 58 | 61 | }; |
| 59 | 62 | } |
| 60 | 63 | |
| 61 | pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, mdir_path: string, dtype: zigmod.Dep.Type, options: *CollectOptions) anyerror!zigmod.Module { | |
| 62 | try std.fs.cwd().makePath(cachepath); | |
| 64 | pub fn collect_deps(cachepath: [:0]const u8, mdir: nfs.Dir, mdir_path: string, dtype: zigmod.Dep.Type, options: *CollectOptions) anyerror!zigmod.Module { | |
| 65 | try nfs.cwd().makePath(cachepath); | |
| 63 | 66 | |
| 64 | 67 | const m = try zigmod.ModFile.from_dir(options.alloc, mdir, mdir_path); |
| 65 | 68 | var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc); |
| ... | ... | @@ -98,9 +101,9 @@ pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) any |
| 98 | 101 | } |
| 99 | 102 | } |
| 100 | 103 | |
| 101 | pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !string { | |
| 102 | const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path(options.alloc) }); | |
| 103 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) }); | |
| 104 | pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ![:0]const u8 { | |
| 105 | const p = try std.fs.path.joinZ(options.alloc, &.{ cachepath, try d.clean_path(options.alloc) }); | |
| 106 | const pv = try std.fs.path.joinZ(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) }); | |
| 104 | 107 | |
| 105 | 108 | const nocache = d.type.isLocal(); |
| 106 | 109 | if (!nocache and extras.containsString(options.already_fetched.items, p)) return p; |
| ... | ... | @@ -118,7 +121,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 118 | 121 | switch (d.type) { |
| 119 | 122 | .local => { |
| 120 | 123 | if (!std.mem.endsWith(u8, d.main, ".zig")) { |
| 121 | return d.main; | |
| 124 | return gpa.dupeZ(u8, d.main); | |
| 122 | 125 | } |
| 123 | 126 | return d.path; |
| 124 | 127 | }, |
| ... | ... | @@ -148,11 +151,11 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 148 | 151 | u.fail("fetch: git: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); |
| 149 | 152 | } |
| 150 | 153 | if (builtin.os.tag != .windows and vers.id == .commit) { |
| 151 | var pvd = try std.fs.cwd().openDir(pv, .{}); | |
| 154 | var pvd = try nfs.cwd().openDir(pv, .{}); | |
| 152 | 155 | defer pvd.close(); |
| 153 | 156 | try pvd.deleteTree(".git"); |
| 154 | 157 | } |
| 155 | var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true }); | |
| 158 | var pvd = try nfs.cwd().openDir(pv, .{}); | |
| 156 | 159 | defer pvd.close(); |
| 157 | 160 | try setTreeReadOnly(pvd, options.alloc); |
| 158 | 161 | return pv; |
| ... | ... | @@ -185,36 +188,38 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 185 | 188 | if (try extras.doesFolderExist(null, pv)) { |
| 186 | 189 | return pv; |
| 187 | 190 | } |
| 188 | const file_path = try std.fs.path.join(options.alloc, &.{ pv, file_name }); | |
| 191 | const file_path = try std.fs.path.joinZ(options.alloc, &.{ pv, file_name }); | |
| 189 | 192 | try d.type.pull(options.alloc, d.path, pv); |
| 190 | 193 | if (try u.validate_hash(options.alloc, d.version, file_path)) { |
| 191 | try std.fs.cwd().deleteFile(file_path); | |
| 192 | var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true }); | |
| 194 | try nfs.cwd().deleteFile(file_path); | |
| 195 | var pvd = try nfs.cwd().openDir(pv, .{}); | |
| 193 | 196 | defer pvd.close(); |
| 194 | 197 | try setTreeReadOnly(pvd, options.alloc); |
| 195 | 198 | return pv; |
| 196 | 199 | } |
| 197 | try std.fs.cwd().deleteTree(pv); | |
| 200 | try nfs.cwd().deleteTree(pv); | |
| 198 | 201 | u.fail("{s} does not match hash {s}", .{ d.path, d.version }); |
| 199 | 202 | return p; |
| 200 | 203 | } |
| 201 | 204 | if (try extras.doesFolderExist(null, p)) { |
| 202 | try std.fs.cwd().deleteTree(p); | |
| 205 | try nfs.cwd().deleteTree(p); | |
| 203 | 206 | } |
| 204 | const file_path = try std.fs.path.resolve(options.alloc, &.{ p, file_name }); | |
| 207 | const file_path_s = try std.fs.path.resolve(options.alloc, &.{ p, file_name }); | |
| 208 | defer gpa.free(file_path_s); | |
| 209 | const file_path = try gpa.dupeZ(u8, file_path_s); | |
| 205 | 210 | try d.type.pull(options.alloc, d.path, p); |
| 206 | try std.fs.cwd().deleteFile(file_path); | |
| 211 | try nfs.cwd().deleteFile(file_path); | |
| 207 | 212 | return p; |
| 208 | 213 | }, |
| 209 | 214 | } |
| 210 | 215 | } |
| 211 | 216 | |
| 212 | pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?zigmod.Module { | |
| 217 | pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: [:0]const u8, options: *CollectOptions) anyerror!?zigmod.Module { | |
| 213 | 218 | if (options.lock) |lock| { |
| 214 | 219 | for (lock) |item| { |
| 215 | 220 | if (std.mem.eql(u8, item[0], try d.clean_path(options.alloc))) { |
| 216 | 221 | d.type = std.meta.stringToEnum(zigmod.Dep.Type, item[1]).?; |
| 217 | d.path = item[2]; | |
| 222 | d.path = try gpa.dupeZ(u8, item[2]); | |
| 218 | 223 | d.version = item[3]; |
| 219 | 224 | break; |
| 220 | 225 | } |
| ... | ... | @@ -222,7 +227,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 222 | 227 | } |
| 223 | 228 | if (!d.is_for_this()) return null; |
| 224 | 229 | const modpath = try get_modpath(cachepath, d.*, options); |
| 225 | const moddir = if (modpath.len == 0) try std.fs.cwd().openDir(cachepath, .{}) else try std.fs.cwd().openDir(modpath, .{}); | |
| 230 | const moddir = if (modpath.len == 0) try nfs.cwd().openDir(cachepath, .{}) else try nfs.cwd().openDir(modpath, .{}); | |
| 226 | 231 | |
| 227 | 232 | const nocache = d.type.isLocal(); |
| 228 | 233 | if (!nocache) try options.already_fetched.append(modpath); |
| ... | ... | @@ -249,11 +254,14 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 249 | 254 | error.ManifestNotFound => { |
| 250 | 255 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0 or d.keep) { |
| 251 | 256 | var mod_from = try zigmod.Module.from(options.alloc, d.*, cachepath, options); |
| 252 | if (d.type != .local) mod_from.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 257 | if (d.type != .local) { | |
| 258 | const new_clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 259 | mod_from.clean_path = new_clean_path.ptr[0..new_clean_path.len :0]; | |
| 260 | } | |
| 253 | 261 | if (mod_from.is_for_this()) return mod_from; |
| 254 | 262 | return null; |
| 255 | 263 | } |
| 256 | const moddirO = try std.fs.cwd().openDir(modpath, .{}); | |
| 264 | const moddirO = try nfs.cwd().openDir(modpath, .{}); | |
| 257 | 265 | const tryname = try u.detect_pkgname(options.alloc, d.name, modpath); |
| 258 | 266 | const trymain: ?string = u.detct_mainfile(options.alloc, d.main, moddirO, tryname) catch |err| switch (err) { |
| 259 | 267 | error.CantFindMain => null, |
| ... | ... | @@ -263,7 +271,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 263 | 271 | d.*.name = tryname; |
| 264 | 272 | d.*.main = trymain.?; |
| 265 | 273 | var mod_from = try zigmod.Module.from(options.alloc, d.*, cachepath, options); |
| 266 | if (d.type != .local) mod_from.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 274 | if (d.type != .local) mod_from.clean_path = extras.trimPrefix(modpath, cachepath)[1..][0.. :0]; | |
| 267 | 275 | if (mod_from.is_for_this()) return mod_from; |
| 268 | 276 | return null; |
| 269 | 277 | } |
| ... | ... | @@ -274,7 +282,10 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 274 | 282 | dd.dep = d.*; |
| 275 | 283 | dd.for_build = d.for_build; |
| 276 | 284 | const save = dd; |
| 277 | if (d.type != .local) dd.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 285 | if (d.type != .local) { | |
| 286 | const new_clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 287 | dd.clean_path = new_clean_path.ptr[0..new_clean_path.len :0]; | |
| 288 | } | |
| 278 | 289 | if (std.mem.eql(u8, &dd.id, &zigmod.Dep.EMPTY)) dd.id = u.random_string(48); |
| 279 | 290 | if (d.name.len > 0) dd.name = d.name; |
| 280 | 291 | if (d.main.len > 0) dd.main = d.main; |
| ... | ... | @@ -290,16 +301,16 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 290 | 301 | } |
| 291 | 302 | } |
| 292 | 303 | |
| 293 | pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: std.fs.Dir, dirs: []const string) !void { | |
| 304 | pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: nfs.Dir, dirs: []const string) !void { | |
| 294 | 305 | var map = std.StringHashMap(string).init(alloc); |
| 295 | 306 | defer map.deinit(); |
| 296 | 307 | |
| 297 | 308 | for (dirs) |dir_path| { |
| 298 | const dir = try mdir.openDir(dir_path, .{ .iterate = true }); | |
| 309 | const dir = try mdir.openDirC(dir_path, .{}); | |
| 299 | 310 | var walker = try dir.walk(alloc); |
| 300 | 311 | defer walker.deinit(); |
| 301 | 312 | while (try walker.next()) |p| { |
| 302 | if (p.kind == .directory) { | |
| 313 | if (p.type == .DIR) { | |
| 303 | 314 | continue; |
| 304 | 315 | } |
| 305 | 316 | const path = try alloc.dupe(u8, p.path); |
| ... | ... | @@ -315,21 +326,19 @@ pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: std. |
| 315 | 326 | const destdir = mdir; |
| 316 | 327 | const rff = try destdir.createFile(fname, .{}); |
| 317 | 328 | defer rff.close(); |
| 318 | const w = rff.writer(); | |
| 319 | 329 | var iter = map.iterator(); |
| 320 | 330 | while (iter.next()) |item| { |
| 321 | try w.print("pub const @\"/{}\" = @embedFile(\"{}\");\n", .{ std.zig.fmtEscapes(item.key_ptr.*), std.zig.fmtEscapes(item.value_ptr.*) }); | |
| 331 | try rff.print("pub const @\"/{}\" = @embedFile(\"{}\");\n", .{ u.altStringEscape(item.key_ptr.*), u.altStringEscape(item.value_ptr.*) }); | |
| 322 | 332 | } |
| 323 | 333 | } |
| 324 | 334 | |
| 325 | pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]string { | |
| 335 | pub fn parse_lockfile(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const [4]string { | |
| 326 | 336 | var list = std.ArrayList([4]string).init(alloc); |
| 327 | 337 | const max = std.math.maxInt(usize); |
| 328 | if (!try extras.doesFileExist(dir, "zigmod.lock")) return &[_][4]string{}; | |
| 338 | if (!try extras.doesFileExist(dir.to_std(), "zigmod.lock")) return &[_][4]string{}; | |
| 329 | 339 | var f = try dir.openFile("zigmod.lock", .{}); |
| 330 | 340 | defer f.close(); |
| 331 | var br = std.io.bufferedReader(f.reader()); | |
| 332 | const r = br.reader(); | |
| 341 | var r = nio.BufferedReader(4096, nfs.File).init(f); | |
| 333 | 342 | var i: usize = 0; |
| 334 | 343 | var v: usize = 1; |
| 335 | 344 | while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| : (i += 1) { |
| ... | ... | @@ -351,7 +360,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 351 | 360 | var iter = std.mem.splitScalar(u8, line, ' '); |
| 352 | 361 | const asdep = zigmod.Dep{ |
| 353 | 362 | .type = std.meta.stringToEnum(zigmod.Dep.Type, iter.next().?).?, |
| 354 | .path = iter.next().?, | |
| 363 | .path = try gpa.dupeZ(u8, iter.next().?), | |
| 355 | 364 | .version = iter.next().?, |
| 356 | 365 | .id = zigmod.Dep.EMPTY, |
| 357 | 366 | .name = "", |
| ... | ... | @@ -374,17 +383,17 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 374 | 383 | return list.toOwnedSlice(); |
| 375 | 384 | } |
| 376 | 385 | |
| 377 | fn setTreeReadOnly(dir: std.fs.Dir, alloc: std.mem.Allocator) !void { | |
| 386 | fn setTreeReadOnly(dir: nfs.Dir, alloc: std.mem.Allocator) !void { | |
| 378 | 387 | var walker = try dir.walk(alloc); |
| 379 | 388 | defer walker.deinit(); |
| 380 | 389 | |
| 381 | 390 | while (try walker.next()) |entry| { |
| 382 | if (entry.kind != .file) continue; | |
| 391 | if (entry.type != .REG) continue; | |
| 383 | 392 | var file = try dir.openFile(entry.path, .{}); |
| 384 | 393 | defer file.close(); |
| 385 | var metadata = try file.metadata(); | |
| 386 | var perms = metadata.permissions(); | |
| 387 | perms.setReadOnly(true); | |
| 388 | try file.setPermissions(perms); | |
| 394 | const stat = try file.stat(); | |
| 395 | var mode = stat.mode; | |
| 396 | mode |= ~@as(nfs.File.Mode, 0o222); | |
| 397 | try file.chmod(mode); | |
| 389 | 398 | } |
| 390 | 399 | } |
src/util/dep.zig+6-6| ... | ... | @@ -14,7 +14,7 @@ pub const Dep = struct { |
| 14 | 14 | const Self = @This(); |
| 15 | 15 | |
| 16 | 16 | type: Type, |
| 17 | path: string, | |
| 17 | path: [:0]const u8, | |
| 18 | 18 | id: [48]u8, |
| 19 | 19 | name: string, |
| 20 | 20 | main: string, |
| ... | ... | @@ -33,17 +33,17 @@ pub const Dep = struct { |
| 33 | 33 | |
| 34 | 34 | pub const Type = @import("./dep_type.zig").DepType; |
| 35 | 35 | |
| 36 | pub fn clean_path(self: Dep, alloc: std.mem.Allocator) !string { | |
| 36 | pub fn clean_path(self: Dep, alloc: std.mem.Allocator) ![:0]const u8 { | |
| 37 | 37 | if (self.type == .local) { |
| 38 | 38 | return self.path; |
| 39 | 39 | } |
| 40 | var p = self.path; | |
| 40 | var p: string = self.path; | |
| 41 | 41 | p = extras.trimPrefix(p, "http://"); |
| 42 | 42 | p = extras.trimPrefix(p, "https://"); |
| 43 | 43 | p = extras.trimPrefix(p, "git://"); |
| 44 | 44 | p = extras.trimSuffix(p, ".git"); |
| 45 | p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p }); | |
| 46 | return p; | |
| 45 | const np = try std.mem.joinZ(alloc, "/", &.{ @tagName(self.type), p }); | |
| 46 | return np; | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | pub fn clean_path_v(self: Dep, alloc: std.mem.Allocator) !string { |
| ... | ... | @@ -65,7 +65,7 @@ pub const Dep = struct { |
| 65 | 65 | return true; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | pub fn exact_version(self: Dep, alloc: std.mem.Allocator, dpath: string) !string { | |
| 68 | pub fn exact_version(self: Dep, alloc: std.mem.Allocator, dpath: [:0]const u8) !string { | |
| 69 | 69 | if (self.version.len == 0) { |
| 70 | 70 | return try self.type.exact_version(alloc, dpath); |
| 71 | 71 | } |
src/util/dep_type.zig+5-4| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const nio = @import("nio"); |
| 4 | const nfs = @import("nfs"); | |
| 4 | 5 | |
| 5 | 6 | const u = @import("./funcs.zig"); |
| 6 | 7 | |
| ... | ... | @@ -17,7 +18,7 @@ pub const DepType = enum { |
| 17 | 18 | http, // https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol |
| 18 | 19 | |
| 19 | 20 | // zig fmt: on |
| 20 | pub fn pull(self: DepType, alloc: std.mem.Allocator, rpath: string, dpath: string) !void { | |
| 21 | pub fn pull(self: DepType, alloc: std.mem.Allocator, rpath: [:0]const u8, dpath: [:0]const u8) !void { | |
| 21 | 22 | switch (self) { |
| 22 | 23 | .local => {}, |
| 23 | 24 | .system_lib => {}, |
| ... | ... | @@ -29,7 +30,7 @@ pub const DepType = enum { |
| 29 | 30 | u.assert((try u.run_cmd(alloc, null, &.{ "hg", "clone", rpath, dpath })) == 0, "hg clone {s} failed", .{rpath}); |
| 30 | 31 | }, |
| 31 | 32 | .http => { |
| 32 | try std.fs.cwd().makePath(dpath); | |
| 33 | try nfs.cwd().makePath(dpath); | |
| 33 | 34 | u.assert((try u.run_cmd(alloc, dpath, &.{ "wget", rpath })) == 0, "wget {s} failed", .{rpath}); |
| 34 | 35 | const f = rpath[std.mem.lastIndexOf(u8, rpath, "/").? + 1 ..]; |
| 35 | 36 | if (std.mem.endsWith(u8, f, ".zip")) { |
| ... | ... | @@ -62,8 +63,8 @@ pub const DepType = enum { |
| 62 | 63 | } |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | pub fn exact_version(self: DepType, alloc: std.mem.Allocator, mpath: string) !string { | |
| 66 | var mdir = try std.fs.cwd().openDir(mpath, .{}); | |
| 66 | pub fn exact_version(self: DepType, alloc: std.mem.Allocator, mpath: [:0]const u8) !string { | |
| 67 | var mdir = try nfs.cwd().openDir(mpath, .{}); | |
| 67 | 68 | defer mdir.close(); |
| 68 | 69 | return switch (self) { |
| 69 | 70 | .local => "", |
src/util/funcs.zig+57-22| ... | ... | @@ -44,10 +44,10 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: u8) ![]string { |
| 44 | 44 | return list.toOwnedSlice(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string { | |
| 48 | var dir = try std.fs.cwd().openDir(dpath, .{ .iterate = true }); | |
| 47 | pub fn file_list(alloc: std.mem.Allocator, dpath: [:0]const u8) ![]const string { | |
| 48 | var dir = try nfs.cwd().openDir(dpath, .{}); | |
| 49 | 49 | defer dir.close(); |
| 50 | return try extras.fileList(alloc, dir); | |
| 50 | return try extras.fileList(alloc, dir.to_std()); | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.process.Child.RunResult { |
| ... | ... | @@ -121,11 +121,11 @@ pub const HashFn = enum { |
| 121 | 121 | sha512, |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | pub fn validate_hash(alloc: std.mem.Allocator, input: string, file_path: string) !bool { | |
| 124 | pub fn validate_hash(alloc: std.mem.Allocator, input: string, file_path: [:0]const u8) !bool { | |
| 125 | 125 | const hash = parse_split(HashFn, '-').do(input) catch return false; |
| 126 | const file = try std.fs.cwd().openFile(file_path, .{}); | |
| 126 | const file = try nfs.cwd().openFile(file_path, .{}); | |
| 127 | 127 | defer file.close(); |
| 128 | const data = try file.reader().readAllAlloc(alloc, gb); | |
| 128 | const data = try file.readAllAlloc(alloc, gb); | |
| 129 | 129 | const expected = hash.string; |
| 130 | 130 | const actual = switch (hash.id) { |
| 131 | 131 | .blake3 => &try do_hash(std.crypto.hash.Blake3, data), |
| ... | ... | @@ -144,9 +144,8 @@ pub fn do_hash(comptime algo: type, data: string) ![algo.digest_length * 2]u8 { |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /// Returns the result of running `git rev-parse HEAD` |
| 147 | pub fn git_rev_HEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !string { | |
| 148 | const ndir: nfs.Dir = .{ .fd = @enumFromInt(dir.fd) }; | |
| 149 | var dirg = try ndir.openDir(".git", .{}); | |
| 147 | pub fn git_rev_HEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !string { | |
| 148 | var dirg = try dir.openDir(".git", .{}); | |
| 150 | 149 | defer dirg.close(); |
| 151 | 150 | const commitid = try git.getHEAD(alloc, dirg); |
| 152 | 151 | return if (commitid) |_| commitid.?.id else error.NotAGitRepo; |
| ... | ... | @@ -158,9 +157,9 @@ pub fn slice(comptime T: type, input: []const T, from: usize, to: usize) []const |
| 158 | 157 | return input[f..t]; |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: string) !string { | |
| 160 | pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: [:0]const u8) !string { | |
| 162 | 161 | if (override.len > 0) return override; |
| 163 | const dirO = if (dir.len == 0) std.fs.cwd() else try std.fs.cwd().openDir(dir, .{}); | |
| 162 | const dirO = if (dir.len == 0) nfs.cwd() else try nfs.cwd().openDir(dir, .{}); | |
| 164 | 163 | const dpath = try dirO.realpathAlloc(gpa, "."); |
| 165 | 164 | const splitP = try split(alloc, dpath, std.fs.path.sep); |
| 166 | 165 | var name = splitP[splitP.len - 1]; |
| ... | ... | @@ -169,28 +168,28 @@ pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: string) ! |
| 169 | 168 | return name; |
| 170 | 169 | } |
| 171 | 170 | |
| 172 | pub fn detct_mainfile(alloc: std.mem.Allocator, override: string, dir: ?std.fs.Dir, name: string) !string { | |
| 171 | pub fn detct_mainfile(alloc: std.mem.Allocator, override: string, dir: nfs.Dir, name: string) !string { | |
| 173 | 172 | if (override.len > 0) { |
| 174 | if (try extras.doesFileExist(dir, override)) { | |
| 173 | if (try extras.doesFileExist(dir.to_std(), override)) { | |
| 175 | 174 | if (std.mem.endsWith(u8, override, ".zig")) { |
| 176 | 175 | return override; |
| 177 | 176 | } |
| 178 | 177 | } |
| 179 | 178 | } |
| 180 | 179 | const namedotzig = try std.mem.concat(alloc, u8, &.{ name, ".zig" }); |
| 181 | if (try extras.doesFileExist(dir, namedotzig)) { | |
| 180 | if (try extras.doesFileExist(dir.to_std(), namedotzig)) { | |
| 182 | 181 | return namedotzig; |
| 183 | 182 | } |
| 184 | if (try extras.doesFileExist(dir, "lib.zig")) { | |
| 183 | if (try extras.doesFileExist(dir.to_std(), "lib.zig")) { | |
| 185 | 184 | return "lib.zig"; |
| 186 | 185 | } |
| 187 | if (try extras.doesFileExist(dir, "main.zig")) { | |
| 186 | if (try extras.doesFileExist(dir.to_std(), "main.zig")) { | |
| 188 | 187 | return "main.zig"; |
| 189 | 188 | } |
| 190 | if (try extras.doesFileExist(dir, try std.fs.path.join(alloc, &.{ "src", "lib.zig" }))) { | |
| 189 | if (try extras.doesFileExist(dir.to_std(), try std.fs.path.join(alloc, &.{ "src", "lib.zig" }))) { | |
| 191 | 190 | return "src/lib.zig"; |
| 192 | 191 | } |
| 193 | if (try extras.doesFileExist(dir, try std.fs.path.join(alloc, &.{ "src", "main.zig" }))) { | |
| 192 | if (try extras.doesFileExist(dir.to_std(), try std.fs.path.join(alloc, &.{ "src", "main.zig" }))) { | |
| 194 | 193 | return "src/main.zig"; |
| 195 | 194 | } |
| 196 | 195 | return error.CantFindMain; |
| ... | ... | @@ -214,12 +213,48 @@ pub fn indexOfAfter(haystack: string, needle: u8, after: usize) ?usize { |
| 214 | 213 | return null; |
| 215 | 214 | } |
| 216 | 215 | |
| 217 | pub fn find_cachepath() !string { | |
| 218 | const haystack = try std.fs.cwd().realpathAlloc(gpa, "."); | |
| 216 | pub fn find_cachepath() ![:0]const u8 { | |
| 217 | const haystack = try nfs.cwd().realpathAlloc(gpa, "."); | |
| 219 | 218 | const needle = "/.zigmod/deps"; |
| 220 | 219 | |
| 221 | 220 | if (std.mem.indexOf(u8, haystack, needle)) |index| { |
| 222 | return haystack[0 .. index + needle.len]; | |
| 221 | return gpa.dupeZ(u8, haystack[0 .. index + needle.len]); | |
| 223 | 222 | } |
| 224 | return try std.fs.path.join(gpa, &.{ haystack, ".zigmod", "deps" }); | |
| 223 | return try std.fs.path.joinZ(gpa, &.{ haystack, ".zigmod", "deps" }); | |
| 225 | 224 | } |
| 225 | ||
| 226 | pub fn altStringEscape(data: []const u8) StringEscape { | |
| 227 | return .{ .data = data }; | |
| 228 | } | |
| 229 | const StringEscape = struct { | |
| 230 | data: []const u8, | |
| 231 | ||
| 232 | pub fn nprint(self: StringEscape, writer: anytype) !void { | |
| 233 | for (self.data) |c| switch (c) { | |
| 234 | '\n' => try writer.writeAll("\\n"), | |
| 235 | '\r' => try writer.writeAll("\\r"), | |
| 236 | '\t' => try writer.writeAll("\\t"), | |
| 237 | '\\' => try writer.writeAll("\\\\"), | |
| 238 | '"' => try writer.writeAll("\\\""), | |
| 239 | '\'' => try writer.writeAll(&.{'\''}), | |
| 240 | ' ', '!', '#'...'&', '('...'[', ']'...'~' => try writer.writeAll(&.{c}), | |
| 241 | else => { | |
| 242 | try writer.print("\\x{x:0>2}", .{c}); | |
| 243 | // try writer.printInt(c, 16, .lower, .{ .width = 2, .fill = '0' }); | |
| 244 | }, | |
| 245 | }; | |
| 246 | } | |
| 247 | }; | |
| 248 | ||
| 249 | pub fn altSemanticVersion(data: std.SemanticVersion) SemanticVersion { | |
| 250 | return .{ .data = data }; | |
| 251 | } | |
| 252 | const SemanticVersion = struct { | |
| 253 | data: std.SemanticVersion, | |
| 254 | ||
| 255 | pub fn nprint(self: SemanticVersion, writer: anytype) !void { | |
| 256 | try writer.print("{d}.{d}.{d}", .{ self.data.major, self.data.minor, self.data.patch }); | |
| 257 | if (self.data.pre) |pre| try writer.print("-{s}", .{pre}); | |
| 258 | if (self.data.build) |build| try writer.print("+{s}", .{build}); | |
| 259 | } | |
| 260 | }; |
src/util/modfile.zig+10-8| ... | ... | @@ -4,6 +4,7 @@ const yaml = @import("yaml"); |
| 4 | 4 | const extras = @import("extras"); |
| 5 | 5 | const root = @import("root"); |
| 6 | 6 | const build_options = root.build_options; |
| 7 | const nfs = @import("nfs"); | |
| 7 | 8 | |
| 8 | 9 | const zigmod = @import("../lib.zig"); |
| 9 | 10 | const u = @import("funcs.zig"); |
| ... | ... | @@ -11,6 +12,7 @@ const u = @import("funcs.zig"); |
| 11 | 12 | // |
| 12 | 13 | // |
| 13 | 14 | |
| 15 | const gpa = std.heap.c_allocator; | |
| 14 | 16 | const b = 1; |
| 15 | 17 | const kb = b * 1024; |
| 16 | 18 | const mb = kb * 1024; |
| ... | ... | @@ -32,10 +34,10 @@ pub const ModFile = struct { |
| 32 | 34 | builddeps: []zigmod.Dep, |
| 33 | 35 | min_zig_version: ?std.SemanticVersion, |
| 34 | 36 | |
| 35 | pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !struct { string, std.fs.File } { | |
| 37 | pub fn openFile(dir: nfs.Dir, ops: nfs.Dir.OpenFileFlags) !struct { string, nfs.File } { | |
| 36 | 38 | return .{ "zig.mod", dir.openFile("zig.mod", ops) catch |err| switch (err) { |
| 37 | error.FileNotFound => return .{ "zigmod.yml", dir.openFile("zigmod.yml", ops) catch |err2| switch (err2) { | |
| 38 | error.FileNotFound => return error.ManifestNotFound, | |
| 39 | error.ENOENT => return .{ "zigmod.yml", dir.openFile("zigmod.yml", ops) catch |err2| switch (err2) { | |
| 40 | error.ENOENT => return error.ManifestNotFound, | |
| 39 | 41 | else => |e2| return e2, |
| 40 | 42 | } }, |
| 41 | 43 | else => |e| return e, |
| ... | ... | @@ -43,13 +45,13 @@ pub const ModFile = struct { |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | pub fn init(alloc: std.mem.Allocator) !Self { |
| 46 | return try from_dir(alloc, std.fs.cwd(), "."); | |
| 48 | return try from_dir(alloc, nfs.cwd(), "."); | |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | pub fn from_dir(alloc: std.mem.Allocator, dir: std.fs.Dir, dir_path: string) !Self { | |
| 51 | pub fn from_dir(alloc: std.mem.Allocator, dir: nfs.Dir, dir_path: string) !Self { | |
| 50 | 52 | const file_path, const file = try openFile(dir, .{}); |
| 51 | 53 | defer file.close(); |
| 52 | const input = try file.reader().readAllAlloc(alloc, mb); | |
| 54 | const input = try file.readAllAlloc(alloc, mb); | |
| 53 | 55 | const doc = try yaml.parse(alloc, input); |
| 54 | 56 | return from_mapping(alloc, doc.mapping, dir_path, file_path); |
| 55 | 57 | } |
| ... | ... | @@ -101,14 +103,14 @@ pub const ModFile = struct { |
| 101 | 103 | if (dep_seq != .sequence) continue; |
| 102 | 104 | for (dep_seq.sequence) |item| { |
| 103 | 105 | var dtype: string = undefined; |
| 104 | var path: string = undefined; | |
| 106 | var path: [:0]const u8 = undefined; | |
| 105 | 107 | var version: ?string = null; |
| 106 | 108 | var main = item.mapping.get_string("main") orelse ""; |
| 107 | 109 | |
| 108 | 110 | if (item.mapping.get("src")) |val| { |
| 109 | 111 | var src_iter = std.mem.tokenizeScalar(u8, val.string, ' '); |
| 110 | 112 | dtype = src_iter.next().?; |
| 111 | path = src_iter.next().?; | |
| 113 | path = try gpa.dupeZ(u8, src_iter.next().?); | |
| 112 | 114 | if (src_iter.next()) |dver| { |
| 113 | 115 | version = dver; |
| 114 | 116 | } |
src/util/module.zig+9-8| ... | ... | @@ -4,6 +4,7 @@ const builtin = @import("builtin"); |
| 4 | 4 | const yaml = @import("yaml"); |
| 5 | 5 | const extras = @import("extras"); |
| 6 | 6 | const nio = @import("nio"); |
| 7 | const nfs = @import("nfs"); | |
| 7 | 8 | |
| 8 | 9 | const zigmod = @import("../lib.zig"); |
| 9 | 10 | const u = @import("funcs.zig"); |
| ... | ... | @@ -24,14 +25,14 @@ pub const Module = struct { |
| 24 | 25 | except_os: []const string = &.{}, |
| 25 | 26 | yaml: ?yaml.Mapping, |
| 26 | 27 | deps: []Module, |
| 27 | clean_path: string, | |
| 28 | clean_path: [:0]const u8, | |
| 28 | 29 | dep: ?zigmod.Dep, |
| 29 | 30 | for_build: bool = false, |
| 30 | 31 | min_zig_version: ?std.SemanticVersion, |
| 31 | 32 | |
| 32 | 33 | pub const ROOT: [48]u8 = ("root" ++ (" " ** 44)).*; |
| 33 | 34 | |
| 34 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: string, options: *common.CollectOptions) !Module { | |
| 35 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: [:0]const u8, options: *common.CollectOptions) !Module { | |
| 35 | 36 | var moddeps = std.ArrayList(Module).init(alloc); |
| 36 | 37 | errdefer moddeps.deinit(); |
| 37 | 38 | |
| ... | ... | @@ -68,7 +69,7 @@ pub const Module = struct { |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | pub fn get_hash(self: Module, alloc: std.mem.Allocator, cdpath: string) !string { |
| 71 | const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path })); | |
| 72 | const file_list_1 = try u.file_list(alloc, try std.mem.concatWithSentinel(alloc, u8, &.{ cdpath, "/", self.clean_path }, 0)); | |
| 72 | 73 | |
| 73 | 74 | var file_list_2 = std.ArrayList(string).init(alloc); |
| 74 | 75 | errdefer file_list_2.deinit(); |
| ... | ... | @@ -88,10 +89,10 @@ pub const Module = struct { |
| 88 | 89 | |
| 89 | 90 | var h = std.crypto.hash.Blake3.init(.{}); |
| 90 | 91 | for (file_list_2.items) |item| { |
| 91 | const abs_path = try std.fs.path.join(alloc, &.{ cdpath, self.clean_path, item }); | |
| 92 | const file = try std.fs.cwd().openFile(abs_path, .{}); | |
| 92 | const abs_path = try std.fs.path.joinZ(alloc, &.{ cdpath, self.clean_path, item }); | |
| 93 | const file = try nfs.cwd().openFile(abs_path, .{}); | |
| 93 | 94 | defer file.close(); |
| 94 | const input = try file.reader().readAllAlloc(alloc, u.mb * 100); | |
| 95 | const input = try file.readAllAlloc(alloc, u.mb * 100); | |
| 95 | 96 | h.update(input); |
| 96 | 97 | } |
| 97 | 98 | var out: [32]u8 = undefined; |
| ... | ... | @@ -164,13 +165,13 @@ pub const Module = struct { |
| 164 | 165 | return false; |
| 165 | 166 | } |
| 166 | 167 | |
| 167 | pub fn pin(self: Module, alloc: std.mem.Allocator, cachepath: string, options: *common.CollectOptions) !string { | |
| 168 | pub fn pin(self: Module, alloc: std.mem.Allocator, cachepath: [:0]const u8, options: *common.CollectOptions) !string { | |
| 168 | 169 | return switch (self.type) { |
| 169 | 170 | .local => "", |
| 170 | 171 | .system_lib => "", |
| 171 | 172 | .framework => "", |
| 172 | 173 | else => |sub| { |
| 173 | var cdir = try std.fs.cwd().openDir(cachepath, .{}); | |
| 174 | var cdir = try nfs.cwd().openDir(cachepath, .{}); | |
| 174 | 175 | defer cdir.close(); |
| 175 | 176 | var mdir = try cdir.openDir(self.clean_path, .{}); |
| 176 | 177 | defer mdir.close(); |
zigmod.lock+5-5| ... | ... | @@ -5,7 +5,7 @@ git https://github.com/nektro/iguanaTLS commit-3450aaf3ca47986540e2b0258c2affc45 |
| 5 | 5 | git https://github.com/nektro/zfetch commit-40d141bf7db81f05a83cce5f2edc4b14e41a5c34 |
| 6 | 6 | git https://github.com/nektro/zig-ansi commit-5f89211a749aef6bf518889c0467ceb24825c055 |
| 7 | 7 | git https://github.com/nektro/zig-detect-license commit-a1a066da88dab50873a56f0349dc12dc76542077 |
| 8 | git https://github.com/nektro/zig-extras commit-c2c581aa6a38438dd9ed8da0f59019691c5dd45d | |
| 8 | git https://github.com/nektro/zig-extras commit-b3457b31a1d1ea2c19c5d0b007c903d3e80add40 | |
| 9 | 9 | git https://github.com/nektro/zig-git commit-2b3f83cd341764f979969603e4f77e62f353b6a3 |
| 10 | 10 | git https://github.com/nektro/zig-inquirer commit-4cddefa42744d61067567b0b36b5d2bb376e5ae3 |
| 11 | 11 | git https://github.com/nektro/zig-intrusive-parser commit-a31b480914d15f3d13cdfb586aac950c73beebdd |
| ... | ... | @@ -13,13 +13,13 @@ git https://github.com/nektro/zig-json commit-428aa8a29e370fdb2e6739d5676b1de415 |
| 13 | 13 | git https://github.com/nektro/zig-leven commit-618eddde4ffbc6d34100e4bc6aa654d41161537a |
| 14 | 14 | git https://github.com/nektro/zig-licenses commit-16cef5e32b3f8bbcf1064c599615290a720b6547 |
| 15 | 15 | git https://github.com/nektro/zig-licenses-text commit-ba0f00dfb23d28c301e4b54d0a278def2c38dc7b |
| 16 | git https://github.com/nektro/zig-nfs commit-18b00c5c5d25e230ff4f3ea07fadb2a1d54a773d | |
| 16 | git https://github.com/nektro/zig-nfs commit-c855473c8bd15dd24a4e8b6911b7e006062004ba | |
| 17 | 17 | git https://github.com/nektro/zig-nio commit-c1da2e8a31858880eb3e4cfcf12de0a865617623 |
| 18 | git https://github.com/nektro/zig-sys-darwin commit-c5c1b35492224b0ed8d2570c8e71702947b1e400 | |
| 19 | git https://github.com/nektro/zig-sys-linux commit-9edefde5fcf96894b6aa4ab60241940bba65debf | |
| 18 | git https://github.com/nektro/zig-sys-darwin commit-3265d1f06418eb0360d753c12116310a14b97bde | |
| 19 | git https://github.com/nektro/zig-sys-linux commit-f0b155d3627f8c19868be1b2f15d71cda908b575 | |
| 20 | 20 | git https://github.com/nektro/zig-time commit-0f4db4c980146e4a3fc86a9a9070452a25ff9317 |
| 21 | 21 | git https://github.com/nektro/zig-tracer commit-3a5fdea4ffd387a53ac2a42fb503557cdbe20696 |
| 22 | git https://github.com/nektro/zig-yaml commit-b1ebd056b9afaaa719cb55359c610455ffe04499 | |
| 22 | git https://github.com/nektro/zig-yaml commit-00e899bec815bc2b49c6e5a72a7cfeeda673e133 | |
| 23 | 23 | git https://github.com/truemedian/hzzp commit-ab212bd208f0eb54d85861679677c5e3dc9bb543 |
| 24 | 24 | git https://github.com/madler/zlib tag-v1.3.2 |
| 25 | 25 | git https://github.com/yaml/libyaml tag-0.2.5 |