| author | |
| committer | |
| log | cf28bfe96f0e7c72e242bbbf4bab8231f35bd7e4 |
| tree | acd4c22f3ba7d590d5eb337c52057ceab94c6d91 |
| parent | 9e7b050b9648533cfb04baf316beccf2b02f91f8 |
| signature | Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw |
22 files changed, 654 insertions(+), 81 deletions(-)
.github/workflows/push.yml+1-1| ... | @@ -20,7 +20,7 @@ jobs: | ... | @@ -20,7 +20,7 @@ jobs: |
| 20 | uses: mlugg/setup-zig@v2 | 20 | uses: mlugg/setup-zig@v2 |
| 21 | with: | 21 | with: |
| 22 | mirror: "http://mirrors.nektro.net/s3cgi" | 22 | mirror: "http://mirrors.nektro.net/s3cgi" |
| 23 | version: "0.16.0" | 23 | version: "0.17.0" |
| 24 | 24 | ||
| 25 | - run: zig version | 25 | - run: zig version |
| 26 | - run: zig env | 26 | - run: zig env |
.gitignore+1| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | zig-cache | 1 | zig-cache |
| 2 | .zig-cache | 2 | .zig-cache |
| 3 | zig-out | 3 | zig-out |
| 4 | zig-pkg | ||
| 4 | .zigmod | 5 | .zigmod |
| 5 | bin | 6 | bin |
README.md+1-1| ... | @@ -22,7 +22,7 @@ A package manager for the Zig programming language. | ... | @@ -22,7 +22,7 @@ A package manager for the Zig programming language. |
| 22 | 22 | ||
| 23 | ## Built With | 23 | ## Built With |
| 24 | 24 | ||
| 25 | - Zig `0.16.0` | 25 | - Zig `0.17.0` |
| 26 | - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) | 26 | - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) |
| 27 | 27 | ||
| 28 | ### Build from Source | 28 | ### Build from Source |
build.zig+4-6| ... | @@ -4,10 +4,10 @@ const builtin = @import("builtin"); | ... | @@ -4,10 +4,10 @@ const builtin = @import("builtin"); |
| 4 | const deps = @import("./deps.zig"); | 4 | const deps = @import("./deps.zig"); |
| 5 | 5 | ||
| 6 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 7 | b.reference_trace = 256; | 7 | // b.reference_trace = 255; // https://codeberg.org/ziglang/zig/issues/37136 |
| 8 | 8 | ||
| 9 | const target = b.standardTargetOptions(.{}); | 9 | const target = b.standardTargetOptions(.{}); |
| 10 | const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug; | 10 | const optimize = b.standardOptimizeOption(.{}); |
| 11 | const use_full_name = b.option(bool, "use-full-name", "") orelse false; | 11 | const use_full_name = b.option(bool, "use-full-name", "") orelse false; |
| 12 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) }); | 12 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) }); |
| 13 | const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); | 13 | const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); |
| ... | @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { |
| 16 | .root_module = b.createModule(.{ | 16 | .root_module = b.createModule(.{ |
| 17 | .root_source_file = b.path("src/main.zig"), | 17 | .root_source_file = b.path("src/main.zig"), |
| 18 | .target = target, | 18 | .target = target, |
| 19 | .optimize = mode, | 19 | .optimize = optimize, |
| 20 | }), | 20 | }), |
| 21 | }); | 21 | }); |
| 22 | const tag = b.option(string, "tag", ""); | 22 | const tag = b.option(string, "tag", ""); |
| ... | @@ -37,9 +37,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -37,9 +37,7 @@ pub fn build(b: *std.Build) void { |
| 37 | 37 | ||
| 38 | const run_cmd = b.addRunArtifact(exe); | 38 | const run_cmd = b.addRunArtifact(exe); |
| 39 | run_cmd.step.dependOn(b.getInstallStep()); | 39 | run_cmd.step.dependOn(b.getInstallStep()); |
| 40 | if (b.args) |args| { | 40 | run_cmd.addPassthruArgs(); |
| 41 | run_cmd.addArgs(args); | ||
| 42 | } | ||
| 43 | 41 | ||
| 44 | const run_step = b.step("run", "Run the app"); | 42 | const run_step = b.step("run", "Run the app"); |
| 45 | run_step.dependOn(&run_cmd.step); | 43 | run_step.dependOn(&run_cmd.step); |
build.zig.zon created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | .{ | ||
| 2 | .fingerprint = 0xc11ddfd84b6c7d6b, | ||
| 3 | .name = .zigmod, | ||
| 4 | .version = "0.0.0", | ||
| 5 | .minimum_zig_version = "0.17.0", | ||
| 6 | |||
| 7 | .paths = .{ | ||
| 8 | "build.zig", | ||
| 9 | "build.zig.zon", | ||
| 10 | "src", | ||
| 11 | }, | ||
| 12 | |||
| 13 | .dependencies = .{ | ||
| 14 | .translate_c = .{ | ||
| 15 | .url = "git+https://codeberg.org/ziglang/translate-c?ref=2.0.2#c11030012dc325d446474d17b78c242fd1d622ec", | ||
| 16 | .hash = "translate_c-2.0.2-Q_BUWvBNBwBgPKQJPblip6M7AHNK_IPNPmyv4rSIQMQc", | ||
| 17 | }, | ||
| 18 | }, | ||
| 19 | } | ||
deps.zig+51-24| ... | @@ -2,6 +2,10 @@ | ... | @@ -2,6 +2,10 @@ |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const string = []const u8; | 4 | const string = []const u8; |
| 5 | const any_translate_c = true; | ||
| 6 | const Translator = @import("translate_c").Translator; // need to depend on ziglang/translate-c#2.0.2 | ||
| 7 | |||
| 8 | pub var translate_c: ?*std.Build.Dependency = null; | ||
| 5 | 9 | ||
| 6 | pub const GitExactStep = struct { | 10 | pub const GitExactStep = struct { |
| 7 | step: *std.Build.Step, | 11 | step: *std.Build.Step, |
| ... | @@ -28,30 +32,30 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { | ... | @@ -28,30 +32,30 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { |
| 28 | const b = exe.step.owner; | 32 | const b = exe.step.owner; |
| 29 | const step = b.step("fetch", ""); | 33 | const step = b.step("fetch", ""); |
| 30 | dependOnGit(GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "fb2645891520f3e99931db17a7eba04057e87e89"), step, &@field(package_data, "_o6ogpor87xc2")); | 34 | dependOnGit(GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "fb2645891520f3e99931db17a7eba04057e87e89"), step, &@field(package_data, "_o6ogpor87xc2")); |
| 31 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "d2465c64833590a04bd9b7f50c87363fd03e65bf"), step, &@field(package_data, "_u7sysdckdymi")); | 35 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "2951069265792192bd714980d44ccb4abee4a6e8"), step, &@field(package_data, "_u7sysdckdymi")); |
| 32 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "bebb39ae30d9848a1c212cee582d0b1c102d8b87"), step, &@field(package_data, "_s84v9o48ucb0")); | 36 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "952d0751c359612fc1a7c493453cc6223bbaff5d"), step, &@field(package_data, "_s84v9o48ucb0")); |
| 33 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "6de79b4ff8f7462e26f224f4bed3c81710c8893b"), step, &@field(package_data, "_2ovav391ivak")); | 37 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "2ec231c2ae5274d926851f355f0896e0fcbbb5d0"), step, &@field(package_data, "_2ovav391ivak")); |
| 34 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-extras", "0c90ee9a82d8863e0e142211a587940ee2a09790"), step, &@field(package_data, "_f7dubzb7cyqe")); | 38 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-extras", "fb3aa273de9116bbb7befd448835b854d906f2ee"), step, &@field(package_data, "_f7dubzb7cyqe")); |
| 35 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-git", "88b94a1960be841bb93a0bca65d556cb6385d1fd"), step, &@field(package_data, "_0k64oe2nuzvj")); | 39 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-git", "f4bd29ad59967102db4532bda2d95d1512fbf3fb"), step, &@field(package_data, "_0k64oe2nuzvj")); |
| 36 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "e745b018f87ddc4c8958370332e6cf61625403cc"), step, &@field(package_data, "_c1xirp1ota5p")); | 40 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "6feae6d21ac54cba8e5d4da91868c4db9f82343b"), step, &@field(package_data, "_c1xirp1ota5p")); |
| 37 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "2409be829d989bd03b6d123159880660c6089820"), step, &@field(package_data, "_7l3oxw6nqqws")); | 41 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-intrusive-parser", "6d074187f8c5aa2bdab11ee57c7180df768fca72"), step, &@field(package_data, "_7l3oxw6nqqws")); |
| 38 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-json", "d32454ad6d1a6e6e58a8c12a4f3ee1223be2e316"), step, &@field(package_data, "_ocmr9rtohgcc")); | 42 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-json", "4f6aa411f1dc93cc86a052d8a69804c8ff762e59"), step, &@field(package_data, "_ocmr9rtohgcc")); |
| 39 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-leven", "014971d4b1e327a5c61322c3a6b9369fd1863864"), step, &@field(package_data, "_96h80ezrvj7i")); | 43 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-leven", "d990af4f7706edcb0d928d953d1a56c2830fa036"), step, &@field(package_data, "_96h80ezrvj7i")); |
| 40 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "bc1cd51625c13d6c7df819fd0d85968e617f5c57"), step, &@field(package_data, "_0npcrzfdlrvk")); | 44 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "1fd04fc1b7619ca2ddfd07354a93e6d72334f76f"), step, &@field(package_data, "_0npcrzfdlrvk")); |
| 41 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "a9d067c3c4d6c226a1de5531b66785bc15d869ee"), step, &@field(package_data, "_pt88y5d80m25")); | 45 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "a20d31da306967253b8a46c60d8368c7ac4b7229"), step, &@field(package_data, "_pt88y5d80m25")); |
| 42 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "1a27fe574706f0b91c9f66b22fe7d3fa8f5129d5"), step, &@field(package_data, "_vph9l0hxpeze")); | 46 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nfs", "b32bb30bbdc7e5ad9bb3adb5c477a98897c9cb10"), step, &@field(package_data, "_vph9l0hxpeze")); |
| 43 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nio", "17c4f044b15917efc1d3f018765881d53fa27e48"), step, &@field(package_data, "_kscsl0145t7x")); | 47 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-nio", "b28c8efc86f3baec3737de86ffde5c4b3a5260f6"), step, &@field(package_data, "_kscsl0145t7x")); |
| 44 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "b349aa32b55aae4cf2ae56740003f8aff0394920"), step, &@field(package_data, "_73bukkeci2u6")); | 48 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-darwin", "312638dcf043c3163e260ec5b42610856fc9eeab"), step, &@field(package_data, "_73bukkeci2u6")); |
| 45 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-freebsd", "f97e6c2de30af76818572490735c84ce1015958b"), step, &@field(package_data, "_qfev2g50alvp")); | 49 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-freebsd", "967ac568e385534825e6849bc82a9b51d45c600c"), step, &@field(package_data, "_qfev2g50alvp")); |
| 46 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "6dabe7cce239d882c8fd132ab5cda1d1f9ff3634"), step, &@field(package_data, "_h7tv7ayhffak")); | 50 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-linux", "750d2aa874a9ddb473e7cd0af99f1e722aaab79d"), step, &@field(package_data, "_h7tv7ayhffak")); |
| 47 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-netbsd", "5ad432ca421c59099be3630b9d0dda49e8bef0a7"), step, &@field(package_data, "_uvkgl6xf1azv")); | 51 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-netbsd", "e16386268223744ac3f6036a028cc4359056731b"), step, &@field(package_data, "_uvkgl6xf1azv")); |
| 48 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-openbsd", "164646a5e7c4129eb92ac524a60f1759605c99df"), step, &@field(package_data, "_4rmxgmcykiba")); | 52 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-sys-openbsd", "081e11079887e8f02d8480b6219a13a41afd8d69"), step, &@field(package_data, "_4rmxgmcykiba")); |
| 49 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-time", "1349fb2c8aaaa1503e8730facea6f87c5fe75dc0"), step, &@field(package_data, "_iecwp4b3bsfm")); | 53 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-time", "29f3f902cc8948faa36b853380c38ff587236661"), step, &@field(package_data, "_iecwp4b3bsfm")); |
| 50 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "4ad0602d52a3f40ef74f59f648602c61409f7ba7"), step, &@field(package_data, "_ede2wygpe1iy")); | 54 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "ccf9a6b85a38cc343aba772f2d2aac4df49000e1"), step, &@field(package_data, "_ede2wygpe1iy")); |
| 51 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b"), step, &@field(package_data, "_g982zq6e8wsv")); | 55 | dependOnGit(GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "e4e8dfe78a3a0e39d134382a18e8eb771418e850"), step, &@field(package_data, "_g982zq6e8wsv")); |
| 52 | dependOnGit(GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498"), step, &@field(package_data, "_0e2d06bb494b")); | 56 | dependOnGit(GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498"), step, &@field(package_data, "_0e2d06bb494b")); |
| 53 | dependOnGit(GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6"), step, &@field(package_data, "_8mdbh0zuneb0")); | 57 | dependOnGit(GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6"), step, &@field(package_data, "_8mdbh0zuneb0")); |
| 54 | dependOnGit(GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "207c34a16e4365edc20d92c7892f962b3bed46e8"), step, &@field(package_data, "_2ta738wrqbaq")); | 58 | dependOnGit(GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "6da0d0c41b78b9ed2d34fa364fcb81b5ebece6c4"), step, &@field(package_data, "_2ta738wrqbaq")); |
| 55 | return step; | 59 | return step; |
| 56 | } | 60 | } |
| 57 | 61 | ||
| ... | @@ -76,7 +80,7 @@ pub fn addAllTo(exe: *std.Build.Step.Compile) void { | ... | @@ -76,7 +80,7 @@ pub fn addAllTo(exe: *std.Build.Step.Compile) void { |
| 76 | exe.root_module.addImport(pkg.name, module); | 80 | exe.root_module.addImport(pkg.name, module); |
| 77 | } | 81 | } |
| 78 | // clear module memo cache so addAllTo can be called more than once in the same build.zig | 82 | // clear module memo cache so addAllTo can be called more than once in the same build.zig |
| 79 | inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl.name).module_memo = null; | 83 | inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl).module_memo = null; |
| 80 | } | 84 | } |
| 81 | 85 | ||
| 82 | pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void { | 86 | pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void { |
| ... | @@ -96,6 +100,7 @@ pub const Package = struct { | ... | @@ -96,6 +100,7 @@ pub const Package = struct { |
| 96 | system_libs: []const string = &.{}, | 100 | system_libs: []const string = &.{}, |
| 97 | frameworks: []const string = &.{}, | 101 | frameworks: []const string = &.{}, |
| 98 | module_memo: ?*std.Build.Module = null, | 102 | module_memo: ?*std.Build.Module = null, |
| 103 | translate_c_h: ?string = null, | ||
| 99 | 104 | ||
| 100 | pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module { | 105 | pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module { |
| 101 | if (self.module_memo) |cached| { | 106 | if (self.module_memo) |cached| { |
| ... | @@ -140,6 +145,7 @@ pub const Package = struct { | ... | @@ -140,6 +145,7 @@ pub const Package = struct { |
| 140 | for (self.c_include_dirs) |item| { | 145 | for (self.c_include_dirs) |item| { |
| 141 | result.addIncludePath(self.path.?.path(b, item)); | 146 | result.addIncludePath(self.path.?.path(b, item)); |
| 142 | dummy_library.root_module.addIncludePath(self.path.?.path(b, item)); | 147 | dummy_library.root_module.addIncludePath(self.path.?.path(b, item)); |
| 148 | exe.root_module.addIncludePath(self.path.?.path(b, item)); | ||
| 143 | link_lib_c = true; | 149 | link_lib_c = true; |
| 144 | links += 1; | 150 | links += 1; |
| 145 | } | 151 | } |
| ... | @@ -147,6 +153,20 @@ pub const Package = struct { | ... | @@ -147,6 +153,20 @@ pub const Package = struct { |
| 147 | dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags }); | 153 | dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags }); |
| 148 | links += 1; | 154 | links += 1; |
| 149 | } | 155 | } |
| 156 | if (any_translate_c) if (self.translate_c_h) |h| { | ||
| 157 | if (translate_c == null) translate_c = b.dependency("translate_c", .{}); | ||
| 158 | const t: Translator = .init(translate_c.?, .{ | ||
| 159 | .c_source_file = b.addWriteFile("c.h", b.fmt("// {s}\n#include <{s}>\n", .{ self.name, h })).getDirectory().path(b, "c.h"), | ||
| 160 | .target = exe.root_module.resolved_target.?, | ||
| 161 | .optimize = exe.root_module.optimize.?, | ||
| 162 | }); | ||
| 163 | for (exe.root_module.include_dirs.items) |d| { | ||
| 164 | if (d != .path) continue; | ||
| 165 | t.addIncludePath(d.path); | ||
| 166 | } | ||
| 167 | result.addImport("c", t.mod); | ||
| 168 | link_lib_c = true; | ||
| 169 | }; | ||
| 150 | for (self.system_libs) |item| { | 170 | for (self.system_libs) |item| { |
| 151 | if (std.zig.target.isLibCLibName(&target, item)) continue; | 171 | if (std.zig.target.isLibCLibName(&target, item)) continue; |
| 152 | dummy_library.root_module.linkSystemLibrary(item, .{}); | 172 | dummy_library.root_module.linkSystemLibrary(item, .{}); |
| ... | @@ -170,7 +190,7 @@ pub const Package = struct { | ... | @@ -170,7 +190,7 @@ pub const Package = struct { |
| 170 | }; | 190 | }; |
| 171 | 191 | ||
| 172 | fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void { | 192 | fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void { |
| 173 | const min = std.SemanticVersion.parse("0.16.0") catch return; | 193 | const min = std.SemanticVersion.parse("0.17.0") catch return; |
| 174 | if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{f} does not meet the minimum build requirement of v{f}", .{current, min})); | 194 | if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{f} does not meet the minimum build requirement of v{f}", .{current, min})); |
| 175 | } | 195 | } |
| 176 | 196 | ||
| ... | @@ -195,6 +215,7 @@ pub const package_data = struct { | ... | @@ -195,6 +215,7 @@ pub const package_data = struct { |
| 195 | .name = "inquirer", | 215 | .name = "inquirer", |
| 196 | .main = "src/lib.zig", | 216 | .main = "src/lib.zig", |
| 197 | .deps = &[_]*Package{ &_s84v9o48ucb0 }, | 217 | .deps = &[_]*Package{ &_s84v9o48ucb0 }, |
| 218 | .translate_c_h = "termios.h", | ||
| 198 | }; | 219 | }; |
| 199 | pub var _96h80ezrvj7i = Package{ | 220 | pub var _96h80ezrvj7i = Package{ |
| 200 | .name = "leven", | 221 | .name = "leven", |
| ... | @@ -215,18 +236,22 @@ pub const package_data = struct { | ... | @@ -215,18 +236,22 @@ pub const package_data = struct { |
| 215 | pub var _qfev2g50alvp = Package{ | 236 | pub var _qfev2g50alvp = Package{ |
| 216 | .name = "sys-freebsd", | 237 | .name = "sys-freebsd", |
| 217 | .main = "freebsd.zig", | 238 | .main = "freebsd.zig", |
| 239 | .translate_c_h = "pthread.h", | ||
| 218 | }; | 240 | }; |
| 219 | pub var _h7tv7ayhffak = Package{ | 241 | pub var _h7tv7ayhffak = Package{ |
| 220 | .name = "sys-linux", | 242 | .name = "sys-linux", |
| 221 | .main = "mod.zig", | 243 | .main = "mod.zig", |
| 244 | .translate_c_h = "pthread.h", | ||
| 222 | }; | 245 | }; |
| 223 | pub var _uvkgl6xf1azv = Package{ | 246 | pub var _uvkgl6xf1azv = Package{ |
| 224 | .name = "sys-netbsd", | 247 | .name = "sys-netbsd", |
| 225 | .main = "netbsd.zig", | 248 | .main = "netbsd.zig", |
| 249 | .translate_c_h = "pthread.h", | ||
| 226 | }; | 250 | }; |
| 227 | pub var _4rmxgmcykiba = Package{ | 251 | pub var _4rmxgmcykiba = Package{ |
| 228 | .name = "sys-openbsd", | 252 | .name = "sys-openbsd", |
| 229 | .main = "openbsd.zig", | 253 | .main = "openbsd.zig", |
| 254 | .translate_c_h = "pthread.h", | ||
| 230 | }; | 255 | }; |
| 231 | pub var _kscsl0145t7x = Package{ | 256 | pub var _kscsl0145t7x = Package{ |
| 232 | .name = "nio", | 257 | .name = "nio", |
| ... | @@ -262,6 +287,7 @@ pub const package_data = struct { | ... | @@ -262,6 +287,7 @@ pub const package_data = struct { |
| 262 | .name = "git", | 287 | .name = "git", |
| 263 | .main = "git.zig", | 288 | .main = "git.zig", |
| 264 | .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy, &_vph9l0hxpeze, &_kscsl0145t7x, &_0e2d06bb494b }, | 289 | .deps = &[_]*Package{ &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_ede2wygpe1iy, &_vph9l0hxpeze, &_kscsl0145t7x, &_0e2d06bb494b }, |
| 290 | .translate_c_h = "zlib.h", | ||
| 265 | }; | 291 | }; |
| 266 | pub var _ocmr9rtohgcc = Package{ | 292 | pub var _ocmr9rtohgcc = Package{ |
| 267 | .name = "json", | 293 | .name = "json", |
| ... | @@ -272,6 +298,7 @@ pub const package_data = struct { | ... | @@ -272,6 +298,7 @@ pub const package_data = struct { |
| 272 | .name = "yaml", | 298 | .name = "yaml", |
| 273 | .main = "yaml.zig", | 299 | .main = "yaml.zig", |
| 274 | .deps = &[_]*Package{ &_8mdbh0zuneb0 }, | 300 | .deps = &[_]*Package{ &_8mdbh0zuneb0 }, |
| 301 | .translate_c_h = "yaml.h", | ||
| 275 | }; | 302 | }; |
| 276 | pub var _0e2d06bb494b = Package{ | 303 | pub var _0e2d06bb494b = Package{ |
| 277 | .c_include_dirs = &.{ "" }, | 304 | .c_include_dirs = &.{ "" }, |
docs/README.md+1-1| ... | @@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed. | ... | @@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed. |
| 10 | 10 | ||
| 11 | As Zig is still in development itself, if you plan to contribute to Zigmod you will need a master download of Zig. Those can be obtained from https://ziglang.org/download/#release-master. | 11 | As Zig is still in development itself, if you plan to contribute to Zigmod you will need a master download of Zig. Those can be obtained from https://ziglang.org/download/#release-master. |
| 12 | 12 | ||
| 13 | The earliest Zig release this Zigmod was verified to work with is `0.16.0`. | 13 | The earliest Zig release this Zigmod was verified to work with is `0.17.0`. |
| 14 | 14 | ||
| 15 | ## Download | 15 | ## Download |
| 16 | You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source. | 16 | You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source. |
docs/zig.mod.md+4| ... | @@ -42,6 +42,10 @@ This accepts a list of local directories to embed static assets. These files wil | ... | @@ -42,6 +42,10 @@ This accepts a list of local directories to embed static assets. These files wil |
| 42 | - Type: `[]string` | 42 | - Type: `[]string` |
| 43 | This accepts a list of local directories to embed static assets. These files will be provided through a `files.zig` files in the package root. It generates a list of `@embedFile` calls. | 43 | This accepts a list of local directories to embed static assets. These files will be provided through a `files.zig` files in the package root. It generates a list of `@embedFile` calls. |
| 44 | 44 | ||
| 45 | ### `translate_c_h` | ||
| 46 | - Type: `string` | ||
| 47 | A name a header file eg `foo.h` that will be passed as `#include <foo.h>` to [`translate_c`](https://codeberg.org/ziglang/translate-c) and provided in an `@import("c")` module. | ||
| 48 | |||
| 45 | ### `dependencies` | 49 | ### `dependencies` |
| 46 | - Type: `[]Dep` | 50 | - Type: `[]Dep` |
| 47 | This is a list of `Dep` objects. `Dep` objects are how you include the other people's code in your project. See the `Dep` documentation below to learn more about the attributes available here. | 51 | This is a list of `Dep` objects. `Dep` objects are how you include the other people's code in your project. See the `Dep` documentation below to learn more about the attributes available here. |
src/cmd/fetch.0.16.zig created+463| ... | @@ -0,0 +1,463 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const ansi = @import("ansi"); | ||
| 4 | const extras = @import("extras"); | ||
| 5 | const nfs = @import("nfs"); | ||
| 6 | const nio = @import("nio"); | ||
| 7 | |||
| 8 | const zigmod = @import("../lib.zig"); | ||
| 9 | const u = @import("./../util/funcs.zig"); | ||
| 10 | const common = @import("./../common.zig"); | ||
| 11 | const license = @import("./license.zig"); | ||
| 12 | |||
| 13 | // | ||
| 14 | // | ||
| 15 | |||
| 16 | pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ||
| 17 | _ = self_name; | ||
| 18 | |||
| 19 | const gpa = std.heap.c_allocator; | ||
| 20 | const cachepath = try u.find_cachepath(); | ||
| 21 | const dir = nfs.cwd(); | ||
| 22 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); | ||
| 23 | |||
| 24 | var options = common.CollectOptions{ | ||
| 25 | .log = should_update, | ||
| 26 | .update = should_update, | ||
| 27 | .alloc = gpa, | ||
| 28 | }; | ||
| 29 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); | ||
| 30 | |||
| 31 | var list = std.array_list.Managed(zigmod.Module).init(gpa); | ||
| 32 | try common.collect_pkgs(top_module, &list); | ||
| 33 | |||
| 34 | try create_depszig(gpa, cachepath, dir, top_module, &list); | ||
| 35 | |||
| 36 | try create_lockfile(gpa, &list, cachepath, dir); | ||
| 37 | |||
| 38 | try diff_lockfile(gpa); | ||
| 39 | |||
| 40 | options.update = false; | ||
| 41 | |||
| 42 | var outfile = try dir.createFile("licenses.txt", .{}); | ||
| 43 | defer outfile.close(); | ||
| 44 | |||
| 45 | try license.do(cachepath, dir, &options, outfile); | ||
| 46 | } | ||
| 47 | |||
| 48 | pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, top_module: zigmod.Module, list: *std.array_list.Managed(zigmod.Module)) !void { | ||
| 49 | const f = try dir.createFile("deps.zig", .{}); | ||
| 50 | defer f.close(); | ||
| 51 | |||
| 52 | const w = f; | ||
| 53 | try w.writeAll("// zig fmt: off\n"); | ||
| 54 | try w.writeAll("const std = @import(\"std\");\n"); | ||
| 55 | try w.writeAll("const builtin = @import(\"builtin\");\n"); | ||
| 56 | try w.writeAll("const string = []const u8;\n"); | ||
| 57 | try w.writeAll("\n"); | ||
| 58 | try w.print("pub const cache = \"{}\";\n", .{u.altStringEscape(cachepath)}); | ||
| 59 | try w.writeAll("pub var skip_libc = false;\n"); | ||
| 60 | try w.writeAll("\n"); | ||
| 61 | try w.writeAll( | ||
| 62 | \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { | ||
| 63 | \\ checkMinZig(builtin.zig_version, exe); | ||
| 64 | \\ @setEvalBranchQuota(1_000_000); | ||
| 65 | \\ for (packages) |pkg| { | ||
| 66 | \\ const module = pkg.module(exe); | ||
| 67 | \\ exe.root_module.addImport(pkg.import.?[0], module); | ||
| 68 | \\ } | ||
| 69 | \\ for (package_data._root.system_libs) |libname| { | ||
| 70 | \\ exe.root_module.linkSystemLibrary(libname, .{}); | ||
| 71 | \\ exe.root_module.link_libc = true; | ||
| 72 | \\ } | ||
| 73 | \\ // clear module memo cache so addAllTo can be called more than once in the same build.zig | ||
| 74 | \\ module_memo.clearAndFree(exe.step.owner.allocator); | ||
| 75 | \\} | ||
| 76 | \\ | ||
| 77 | \\var link_lib_c = false; | ||
| 78 | \\var module_memo: std.StringArrayHashMapUnmanaged(*std.Build.Module) = .empty; | ||
| 79 | \\pub const Package = struct { | ||
| 80 | \\ id: string, | ||
| 81 | \\ directory: string, | ||
| 82 | \\ import: ?struct { string, std.Build.LazyPath } = null, | ||
| 83 | \\ dependencies: []const *const Package, | ||
| 84 | \\ c_include_dirs: []const string = &.{}, | ||
| 85 | \\ c_source_files: []const string = &.{}, | ||
| 86 | \\ c_source_flags: []const string = &.{}, | ||
| 87 | \\ system_libs: []const string = &.{}, | ||
| 88 | \\ frameworks: []const string = &.{}, | ||
| 89 | \\ | ||
| 90 | \\ pub fn module(self: *const Package, exe: *std.Build.Step.Compile) *std.Build.Module { | ||
| 91 | \\ if (module_memo.get(self.id)) |cached| { | ||
| 92 | \\ return cached; | ||
| 93 | \\ } | ||
| 94 | \\ const b = exe.step.owner; | ||
| 95 | \\ const result = b.createModule(.{ | ||
| 96 | \\ .target = exe.root_module.resolved_target, | ||
| 97 | \\ }); | ||
| 98 | \\ const target = result.resolved_target.?.result; | ||
| 99 | \\ if (self.import) |capture| { | ||
| 100 | \\ result.root_source_file = capture[1]; | ||
| 101 | \\ } | ||
| 102 | \\ for (self.dependencies) |item| { | ||
| 103 | \\ const module_dep = item.module(exe); | ||
| 104 | \\ if (module_dep.root_source_file != null) { | ||
| 105 | \\ result.addImport(item.import.?[0], module_dep); | ||
| 106 | \\ } | ||
| 107 | \\ for (module_dep.include_dirs.items) |jtem| { | ||
| 108 | \\ switch (jtem) { | ||
| 109 | \\ .path => result.addIncludePath(jtem.path), | ||
| 110 | \\ .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {}, | ||
| 111 | \\ .embed_path => {}, | ||
| 112 | \\ } | ||
| 113 | \\ } | ||
| 114 | \\ } | ||
| 115 | \\ for (self.c_include_dirs) |item| { | ||
| 116 | \\ result.addIncludePath(.{ .cwd_relative = (b.fmt("{s}/{s}", .{ self.directory, item })) }); | ||
| 117 | \\ exe.root_module.addIncludePath(.{ .cwd_relative = (b.fmt("{s}/{s}", .{ self.directory, item })) }); | ||
| 118 | \\ link_lib_c = true; | ||
| 119 | \\ } | ||
| 120 | \\ for (self.c_source_files) |item| { | ||
| 121 | \\ exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = (b.fmt("{s}/{s}", .{ self.directory, item })) }, .flags = self.c_source_flags }); | ||
| 122 | \\ link_lib_c = true; | ||
| 123 | \\ } | ||
| 124 | \\ for (self.system_libs) |item| { | ||
| 125 | \\ if (skip_libc and std.zig.target.isLibCLibName(&target, item)) continue; | ||
| 126 | \\ result.linkSystemLibrary(item, .{}); | ||
| 127 | \\ exe.root_module.linkSystemLibrary(item, .{}); | ||
| 128 | \\ link_lib_c = true; | ||
| 129 | \\ } | ||
| 130 | \\ for (self.frameworks) |item| { | ||
| 131 | \\ result.linkFramework(item, .{}); | ||
| 132 | \\ exe.root_module.linkFramework(item, .{}); | ||
| 133 | \\ link_lib_c = true; | ||
| 134 | \\ } | ||
| 135 | \\ if (link_lib_c and !skip_libc) { | ||
| 136 | \\ result.link_libc = true; | ||
| 137 | \\ exe.root_module.link_libc = true; | ||
| 138 | \\ } | ||
| 139 | \\ module_memo.putNoClobber(b.allocator, self.id, result) catch @panic("OOM"); | ||
| 140 | \\ return result; | ||
| 141 | \\ } | ||
| 142 | \\}; | ||
| 143 | \\ | ||
| 144 | \\ | ||
| 145 | ); | ||
| 146 | |||
| 147 | try w.print( | ||
| 148 | \\fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {{ | ||
| 149 | \\ const min = std.SemanticVersion.parse("{?}") catch return; | ||
| 150 | \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{f}} does not meet the minimum build requirement of v{{f}}", .{{current, min}})); | ||
| 151 | \\}} | ||
| 152 | \\ | ||
| 153 | \\ | ||
| 154 | , .{if (top_module.minZigVersion()) |sv| u.altSemanticVersion(sv) else null}); | ||
| 155 | |||
| 156 | try w.writeAll("pub const dirs = struct {\n"); | ||
| 157 | try print_dirs(w, list.items, alloc); | ||
| 158 | try w.writeAll("};\n\n"); | ||
| 159 | |||
| 160 | try w.writeAll("pub const package_data = struct {\n"); | ||
| 161 | var duped = std.array_list.Managed(zigmod.Module).init(alloc); | ||
| 162 | var done = std.array_list.Managed(zigmod.Module).init(alloc); | ||
| 163 | for (list.items) |mod| { | ||
| 164 | if (mod.type == .system_lib or mod.type == .framework) { | ||
| 165 | continue; | ||
| 166 | } | ||
| 167 | try duped.append(mod); | ||
| 168 | } | ||
| 169 | try print_pkg_data_to(w, &duped, &done); | ||
| 170 | try w.writeAll("};\n\n"); | ||
| 171 | |||
| 172 | try w.writeAll("pub const packages = "); | ||
| 173 | try print_deps(w, top_module); | ||
| 174 | try w.writeAll(";\n\n"); | ||
| 175 | |||
| 176 | try w.writeAll("pub const pkgs = "); | ||
| 177 | try print_pkgs(alloc, w, top_module); | ||
| 178 | try w.writeAll(";\n\n"); | ||
| 179 | |||
| 180 | try w.writeAll("pub const imports = struct {\n"); | ||
| 181 | try print_imports(alloc, w, top_module, cachepath); | ||
| 182 | try w.writeAll("};\n"); | ||
| 183 | } | ||
| 184 | |||
| 185 | fn create_lockfile(alloc: std.mem.Allocator, list: *std.array_list.Managed(zigmod.Module), path: string, dir: nfs.Dir) !void { | ||
| 186 | const fl = try dir.createFile("zigmod.lock", .{}); | ||
| 187 | defer fl.close(); | ||
| 188 | |||
| 189 | std.mem.sort(zigmod.Module, list.items, {}, zigmod.Module.lessThan); | ||
| 190 | |||
| 191 | const wl = fl; | ||
| 192 | try wl.writeAll("2\n"); | ||
| 193 | for (list.items) |m| { | ||
| 194 | if (m.dep) |md| { | ||
| 195 | if (md.type.isLocal()) continue; | ||
| 196 | const mpath = try std.fs.path.joinZ(alloc, &.{ path, m.clean_path }); | ||
| 197 | const version = try md.exact_version(alloc, mpath); | ||
| 198 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 203 | const DiffChange = struct { | ||
| 204 | from: string, | ||
| 205 | to: string, | ||
| 206 | }; | ||
| 207 | |||
| 208 | fn diff_lockfile(alloc: std.mem.Allocator) !void { | ||
| 209 | const max = std.math.maxInt(usize); | ||
| 210 | |||
| 211 | if (try nfs.cwd().existsDir(".git")) { | ||
| 212 | const result = try u.run_cmd_raw(alloc, null, &.{ "git", "diff", "zigmod.lock" }); | ||
| 213 | var stdout = nio.FixedBufferStream([]const u8).init(result.stdout); | ||
| 214 | const r = &stdout; | ||
| 215 | while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| { | ||
| 216 | if (std.mem.startsWith(u8, line, "@@")) break; | ||
| 217 | } | ||
| 218 | |||
| 219 | var rems = std.array_list.Managed(string).init(alloc); | ||
| 220 | var adds = std.array_list.Managed(string).init(alloc); | ||
| 221 | while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line_full| { | ||
| 222 | const line = line_full[0 .. line_full.len - 1]; | ||
| 223 | if (line[0] == ' ') continue; | ||
| 224 | if (line[0] == '-') try rems.append(line[1..]); | ||
| 225 | if (line[0] == '+') if (line[1] == '2') break else try adds.append(line[1..]); | ||
| 226 | } | ||
| 227 | |||
| 228 | var changes = std.StringHashMap(DiffChange).init(alloc); | ||
| 229 | |||
| 230 | var didbreak = false; | ||
| 231 | var i: usize = 0; | ||
| 232 | while (i < rems.items.len) { | ||
| 233 | const it = rems.items[i]; | ||
| 234 | const sni = u.indexOfN(it, ' ', 2).?; | ||
| 235 | |||
| 236 | var j: usize = 0; | ||
| 237 | while (j < adds.items.len) { | ||
| 238 | const jt = adds.items[j]; | ||
| 239 | const snj = u.indexOfN(jt, ' ', 2).?; | ||
| 240 | |||
| 241 | if (std.mem.eql(u8, it[0..sni], jt[0..snj])) { | ||
| 242 | try changes.put(it[0..sni], .{ | ||
| 243 | .from = it[u.indexOfAfter(it, '-', sni).? + 1 .. it.len], | ||
| 244 | .to = jt[u.indexOfAfter(jt, '-', snj).? + 1 .. jt.len], | ||
| 245 | }); | ||
| 246 | _ = rems.orderedRemove(i); | ||
| 247 | _ = adds.orderedRemove(j); | ||
| 248 | didbreak = true; | ||
| 249 | break; | ||
| 250 | } | ||
| 251 | if (!didbreak) j += 1; | ||
| 252 | } | ||
| 253 | if (!didbreak) i += 1; | ||
| 254 | if (didbreak) didbreak = false; | ||
| 255 | } | ||
| 256 | |||
| 257 | if (adds.items.len > 0) { | ||
| 258 | std.debug.print(comptime ansi.color.Faint("Newly added packages:\n"), .{}); | ||
| 259 | defer std.debug.print("\n", .{}); | ||
| 260 | |||
| 261 | for (adds.items) |it| { | ||
| 262 | std.debug.print("- {s}\n", .{it}); | ||
| 263 | } | ||
| 264 | } | ||
| 265 | |||
| 266 | if (rems.items.len > 0) { | ||
| 267 | std.debug.print(comptime ansi.color.Faint("Removed packages:\n"), .{}); | ||
| 268 | defer std.debug.print("\n", .{}); | ||
| 269 | |||
| 270 | for (rems.items) |it| { | ||
| 271 | std.debug.print("- {s}\n", .{it}); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | if (changes.unmanaged.size > 0) std.debug.print(comptime ansi.color.Faint("Updated packages:\n"), .{}); | ||
| 276 | var iter = changes.iterator(); | ||
| 277 | while (iter.next()) |it| { | ||
| 278 | if (diff_printchange("git https://github.com", "- {s}/compare/{s}...{s}\n", it)) continue; | ||
| 279 | if (diff_printchange("git https://gitlab.com", "- {s}/-/compare/{s}...{s}\n", it)) continue; | ||
| 280 | if (diff_printchange("git https://gitea.com", "- {s}/compare/{s}...{s}\n", it)) continue; | ||
| 281 | |||
| 282 | std.debug.print("- {s}\n", .{it.key_ptr.*}); | ||
| 283 | std.debug.print(" - {s} ... {s}\n", .{ it.value_ptr.from, it.value_ptr.to }); | ||
| 284 | } | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | fn diff_printchange(comptime testt: string, comptime replacement: string, item: std.StringHashMap(DiffChange).Entry) bool { | ||
| 289 | if (std.mem.startsWith(u8, item.key_ptr.*, testt)) { | ||
| 290 | if (std.mem.eql(u8, item.value_ptr.from, item.value_ptr.to)) return true; | ||
| 291 | std.debug.print(replacement, .{ item.key_ptr.*[4..], item.value_ptr.from, item.value_ptr.to }); | ||
| 292 | return true; | ||
| 293 | } | ||
| 294 | return false; | ||
| 295 | } | ||
| 296 | |||
| 297 | fn print_dirs(w: nfs.File, list: []const zigmod.Module, alloc: std.mem.Allocator) !void { | ||
| 298 | for (list) |mod| { | ||
| 299 | if (mod.type == .system_lib or mod.type == .framework) continue; | ||
| 300 | if (std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) { | ||
| 301 | try w.writeAll(" pub const _root = \"\";\n"); | ||
| 302 | continue; | ||
| 303 | } | ||
| 304 | if (std.mem.eql(u8, mod.clean_path, "../..")) { | ||
| 305 | const cwd_realpath = try nfs.cwd().realpathAlloc(alloc, "."); | ||
| 306 | try w.print(" pub const _{s} = \"{}\";\n", .{ mod.short_id(), u.altStringEscape(cwd_realpath) }); | ||
| 307 | continue; | ||
| 308 | } | ||
| 309 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), u.altStringEscape(mod.clean_path) }); | ||
| 310 | } | ||
| 311 | } | ||
| 312 | |||
| 313 | fn print_deps(w: nfs.File, m: zigmod.Module) !void { | ||
| 314 | try w.writeAll("&[_]*const Package{\n"); | ||
| 315 | for (m.deps) |d| { | ||
| 316 | if (d.main.len == 0) { | ||
| 317 | continue; | ||
| 318 | } | ||
| 319 | if (d.for_build) { | ||
| 320 | continue; | ||
| 321 | } | ||
| 322 | try w.print(" &package_data._{s},\n", .{d.id[0..12]}); | ||
| 323 | } | ||
| 324 | try w.writeAll("}"); | ||
| 325 | } | ||
| 326 | |||
| 327 | fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module), done: *std.array_list.Managed(zigmod.Module)) !void { | ||
| 328 | var len: usize = notdone.items.len; | ||
| 329 | while (notdone.items.len > 0) { | ||
| 330 | for (notdone.items, 0..) |mod, i| { | ||
| 331 | if (contains_all(mod.deps, done.items)) { | ||
| 332 | try w.print( | ||
| 333 | \\ pub const _{s} = Package{{ | ||
| 334 | \\ .id = "{s}", | ||
| 335 | \\ .directory = dirs._{s}, | ||
| 336 | \\ | ||
| 337 | , .{ | ||
| 338 | mod.short_id(), | ||
| 339 | mod.short_id(), | ||
| 340 | mod.short_id(), | ||
| 341 | }); | ||
| 342 | if (mod.main.len > 0 and !std.mem.eql(u8, &mod.id, &zigmod.Module.ROOT)) { | ||
| 343 | try w.print( | ||
| 344 | \\ .import = .{{ "{s}", .{{ .cwd_relative = dirs._{s} ++ "/{s}" }} }}, | ||
| 345 | \\ | ||
| 346 | , .{ | ||
| 347 | mod.name, | ||
| 348 | mod.short_id(), | ||
| 349 | mod.main, | ||
| 350 | }); | ||
| 351 | } | ||
| 352 | { | ||
| 353 | try w.writeAll(" .dependencies ="); | ||
| 354 | try w.writeAll(" &.{"); | ||
| 355 | for (mod.deps, 0..) |moddep, j| { | ||
| 356 | if (moddep.type == .system_lib) continue; | ||
| 357 | if (moddep.type == .framework) continue; | ||
| 358 | try w.print(" &_{s}", .{moddep.id[0..12]}); | ||
| 359 | if (j != mod.deps.len - 1) try w.writeAll(","); | ||
| 360 | } | ||
| 361 | try w.writeAll(" },\n"); | ||
| 362 | } | ||
| 363 | if (mod.c_include_dirs.len > 0) { | ||
| 364 | try w.writeAll(" .c_include_dirs = &.{"); | ||
| 365 | for (mod.c_include_dirs, 0..) |item, j| { | ||
| 366 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | ||
| 367 | if (j != mod.c_include_dirs.len - 1) try w.writeAll(","); | ||
| 368 | } | ||
| 369 | try w.writeAll(" },\n"); | ||
| 370 | } | ||
| 371 | if (mod.c_source_files.len > 0) { | ||
| 372 | try w.writeAll(" .c_source_files = &.{"); | ||
| 373 | for (mod.c_source_files, 0..) |item, j| { | ||
| 374 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | ||
| 375 | if (j != mod.c_source_files.len - 1) try w.writeAll(","); | ||
| 376 | } | ||
| 377 | try w.writeAll(" },\n"); | ||
| 378 | } | ||
| 379 | if (mod.c_source_flags.len > 0) { | ||
| 380 | try w.writeAll(" .c_source_flags = &.{"); | ||
| 381 | for (mod.c_source_flags, 0..) |item, j| { | ||
| 382 | try w.print(" \"{}\"", .{u.altStringEscape(item)}); | ||
| 383 | if (j != mod.c_source_flags.len - 1) try w.writeAll(","); | ||
| 384 | } | ||
| 385 | try w.writeAll(" },\n"); | ||
| 386 | } | ||
| 387 | if (mod.has_syslib_deps()) { | ||
| 388 | try w.writeAll(" .system_libs = &.{"); | ||
| 389 | for (mod.deps, 0..) |item, j| { | ||
| 390 | if (!(item.type == .system_lib)) continue; | ||
| 391 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | ||
| 392 | if (j != mod.deps.len - 1) try w.writeAll(","); | ||
| 393 | } | ||
| 394 | try w.writeAll(" },\n"); | ||
| 395 | } | ||
| 396 | if (mod.has_framework_deps()) { | ||
| 397 | try w.writeAll(" .frameworks = &.{"); | ||
| 398 | for (mod.deps, 0..) |item, j| { | ||
| 399 | if (!(item.type == .system_lib)) continue; | ||
| 400 | try w.print(" \"{}\"", .{u.altStringEscape(item.name)}); | ||
| 401 | if (j != mod.deps.len - 1) try w.writeAll(","); | ||
| 402 | } | ||
| 403 | try w.writeAll(" },\n"); | ||
| 404 | } | ||
| 405 | try w.writeAll(" };\n"); | ||
| 406 | |||
| 407 | try done.append(mod); | ||
| 408 | _ = notdone.orderedRemove(i); | ||
| 409 | break; | ||
| 410 | } | ||
| 411 | } | ||
| 412 | if (notdone.items.len == len) { | ||
| 413 | u.fail("notdone still has {d} items", .{len}); | ||
| 414 | } | ||
| 415 | len = notdone.items.len; | ||
| 416 | } | ||
| 417 | } | ||
| 418 | |||
| 419 | /// returns if all of the zig modules in needles are in haystack | ||
| 420 | fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool { | ||
| 421 | for (needles) |item| { | ||
| 422 | if (item.main.len > 0 and !extras.containsAggregate(zigmod.Module, haystack, item)) { | ||
| 423 | return false; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | return true; | ||
| 427 | } | ||
| 428 | |||
| 429 | fn print_pkgs(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module) !void { | ||
| 430 | try w.writeAll("struct {\n"); | ||
| 431 | for (m.deps) |d| { | ||
| 432 | if (d.main.len == 0) { | ||
| 433 | continue; | ||
| 434 | } | ||
| 435 | if (d.for_build) { | ||
| 436 | continue; | ||
| 437 | } | ||
| 438 | const ident = try zig_name_from_pkg_name(alloc, d.name); | ||
| 439 | try w.print(" pub const {s} = &package_data._{s};\n", .{ ident, d.id[0..12] }); | ||
| 440 | } | ||
| 441 | try w.writeAll("}"); | ||
| 442 | } | ||
| 443 | |||
| 444 | fn print_imports(alloc: std.mem.Allocator, w: nfs.File, m: zigmod.Module, path: string) !void { | ||
| 445 | for (m.deps) |d| { | ||
| 446 | if (d.main.len == 0) { | ||
| 447 | continue; | ||
| 448 | } | ||
| 449 | if (!d.for_build) { | ||
| 450 | continue; | ||
| 451 | } | ||
| 452 | const ident = try zig_name_from_pkg_name(alloc, d.name); | ||
| 453 | try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ ident, u.altStringEscape(path), u.altStringEscape(d.clean_path), d.main }); | ||
| 454 | } | ||
| 455 | } | ||
| 456 | |||
| 457 | fn zig_name_from_pkg_name(alloc: std.mem.Allocator, name: string) !string { | ||
| 458 | var legal = name; | ||
| 459 | legal = try std.mem.replaceOwned(u8, alloc, legal, "-", "_"); | ||
| 460 | legal = try std.mem.replaceOwned(u8, alloc, legal, "/", "_"); | ||
| 461 | legal = try std.mem.replaceOwned(u8, alloc, legal, ".", "_"); | ||
| 462 | return legal; | ||
| 463 | } | ||
src/cmd/fetch.zig+21| ... | @@ -54,9 +54,12 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, | ... | @@ -54,9 +54,12 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, |
| 54 | try w.writeAll("const std = @import(\"std\");\n"); | 54 | try w.writeAll("const std = @import(\"std\");\n"); |
| 55 | try w.writeAll("const builtin = @import(\"builtin\");\n"); | 55 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| 56 | try w.writeAll("const string = []const u8;\n"); | 56 | try w.writeAll("const string = []const u8;\n"); |
| 57 | try w.print("const any_translate_c = {};\n", .{top_module.any_translate_c()}); | ||
| 58 | try w.writeAll("const Translator = @import(\"translate_c\").Translator; // need to depend on ziglang/translate-c#2.0.2\n"); | ||
| 57 | try w.writeAll("\n"); | 59 | try w.writeAll("\n"); |
| 58 | try w.print("pub const cache = \"{}\";\n", .{u.altStringEscape(cachepath)}); | 60 | try w.print("pub const cache = \"{}\";\n", .{u.altStringEscape(cachepath)}); |
| 59 | try w.writeAll("pub var skip_libc = false;\n"); | 61 | try w.writeAll("pub var skip_libc = false;\n"); |
| 62 | try w.writeAll("pub var translate_c: ?*std.Build.Dependency = null;\n"); | ||
| 60 | try w.writeAll("\n"); | 63 | try w.writeAll("\n"); |
| 61 | try w.writeAll( | 64 | try w.writeAll( |
| 62 | \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { | 65 | \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { |
| ... | @@ -86,6 +89,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, | ... | @@ -86,6 +89,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, |
| 86 | \\ c_source_flags: []const string = &.{}, | 89 | \\ c_source_flags: []const string = &.{}, |
| 87 | \\ system_libs: []const string = &.{}, | 90 | \\ system_libs: []const string = &.{}, |
| 88 | \\ frameworks: []const string = &.{}, | 91 | \\ frameworks: []const string = &.{}, |
| 92 | \\ translate_c_h: ?string = null, | ||
| 89 | \\ | 93 | \\ |
| 90 | \\ pub fn module(self: *const Package, exe: *std.Build.Step.Compile) *std.Build.Module { | 94 | \\ pub fn module(self: *const Package, exe: *std.Build.Step.Compile) *std.Build.Module { |
| 91 | \\ if (module_memo.get(self.id)) |cached| { | 95 | \\ if (module_memo.get(self.id)) |cached| { |
| ... | @@ -121,6 +125,20 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, | ... | @@ -121,6 +125,20 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: nfs.Dir, |
| 121 | \\ exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = (b.fmt("{s}/{s}", .{ self.directory, item })) }, .flags = self.c_source_flags }); | 125 | \\ exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = (b.fmt("{s}/{s}", .{ self.directory, item })) }, .flags = self.c_source_flags }); |
| 122 | \\ link_lib_c = true; | 126 | \\ link_lib_c = true; |
| 123 | \\ } | 127 | \\ } |
| 128 | \\ if (any_translate_c) if (self.translate_c_h) |h| { | ||
| 129 | \\ if (translate_c == null) translate_c = b.dependency("translate_c", .{}); | ||
| 130 | \\ const t: Translator = .init(translate_c.?, .{ | ||
| 131 | \\ .c_source_file = b.addWriteFile("c.h", b.fmt("// {s}\n#include <{s}>\n", .{ self.id, h })).getDirectory().path(b, "c.h"), | ||
| 132 | \\ .target = exe.root_module.resolved_target.?, | ||
| 133 | \\ .optimize = exe.root_module.optimize.?, | ||
| 134 | \\ }); | ||
| 135 | \\ for (exe.root_module.include_dirs.items) |d| { | ||
| 136 | \\ if (d != .path) continue; | ||
| 137 | \\ t.addIncludePath(d.path); | ||
| 138 | \\ } | ||
| 139 | \\ result.addImport("c", t.mod); | ||
| 140 | \\ link_lib_c = true; | ||
| 141 | \\ }; | ||
| 124 | \\ for (self.system_libs) |item| { | 142 | \\ for (self.system_libs) |item| { |
| 125 | \\ if (skip_libc and std.zig.target.isLibCLibName(&target, item)) continue; | 143 | \\ if (skip_libc and std.zig.target.isLibCLibName(&target, item)) continue; |
| 126 | \\ result.linkSystemLibrary(item, .{}); | 144 | \\ result.linkSystemLibrary(item, .{}); |
| ... | @@ -402,6 +420,9 @@ fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module | ... | @@ -402,6 +420,9 @@ fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module |
| 402 | } | 420 | } |
| 403 | try w.writeAll(" },\n"); | 421 | try w.writeAll(" },\n"); |
| 404 | } | 422 | } |
| 423 | if (mod.translate_c_h) |h| { | ||
| 424 | try w.print(" .translate_c_h = \"{s}\",\n", .{h}); | ||
| 425 | } | ||
| 405 | try w.writeAll(" };\n"); | 426 | try w.writeAll(" };\n"); |
| 406 | 427 | ||
| 407 | try done.append(mod); | 428 | try done.append(mod); |
src/cmd/generate.zig+24-1| ... | @@ -44,6 +44,10 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf | ... | @@ -44,6 +44,10 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf |
| 44 | try w.writeAll("const std = @import(\"std\");\n"); | 44 | try w.writeAll("const std = @import(\"std\");\n"); |
| 45 | try w.writeAll("const builtin = @import(\"builtin\");\n"); | 45 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| 46 | try w.writeAll("const string = []const u8;\n"); | 46 | try w.writeAll("const string = []const u8;\n"); |
| 47 | try w.print("const any_translate_c = {};\n", .{top_module.any_translate_c()}); | ||
| 48 | try w.writeAll("const Translator = @import(\"translate_c\").Translator; // need to depend on ziglang/translate-c#2.0.2\n"); | ||
| 49 | try w.writeAll("\n"); | ||
| 50 | try w.writeAll("pub var translate_c: ?*std.Build.Dependency = null;\n"); | ||
| 47 | try w.writeAll("\n"); | 51 | try w.writeAll("\n"); |
| 48 | try w.writeAll( | 52 | try w.writeAll( |
| 49 | \\pub const GitExactStep = struct { | 53 | \\pub const GitExactStep = struct { |
| ... | @@ -107,7 +111,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf | ... | @@ -107,7 +111,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf |
| 107 | \\ exe.root_module.addImport(pkg.name, module); | 111 | \\ exe.root_module.addImport(pkg.name, module); |
| 108 | \\ } | 112 | \\ } |
| 109 | \\ // clear module memo cache so addAllTo can be called more than once in the same build.zig | 113 | \\ // clear module memo cache so addAllTo can be called more than once in the same build.zig |
| 110 | \\ inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl.name).module_memo = null; | 114 | \\ inline for (comptime std.meta.declarations(package_data)) |decl| @field(package_data, decl).module_memo = null; |
| 111 | \\} | 115 | \\} |
| 112 | \\ | 116 | \\ |
| 113 | \\pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void { | 117 | \\pub fn dependOnGit(ge: GitExactStep, s: *std.Build.Step, p: *Package) void { |
| ... | @@ -127,6 +131,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf | ... | @@ -127,6 +131,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf |
| 127 | \\ system_libs: []const string = &.{}, | 131 | \\ system_libs: []const string = &.{}, |
| 128 | \\ frameworks: []const string = &.{}, | 132 | \\ frameworks: []const string = &.{}, |
| 129 | \\ module_memo: ?*std.Build.Module = null, | 133 | \\ module_memo: ?*std.Build.Module = null, |
| 134 | \\ translate_c_h: ?string = null, | ||
| 130 | \\ | 135 | \\ |
| 131 | \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module { | 136 | \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile, fetch_step: *std.Build.Step) *std.Build.Module { |
| 132 | \\ if (self.module_memo) |cached| { | 137 | \\ if (self.module_memo) |cached| { |
| ... | @@ -171,6 +176,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf | ... | @@ -171,6 +176,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf |
| 171 | \\ for (self.c_include_dirs) |item| { | 176 | \\ for (self.c_include_dirs) |item| { |
| 172 | \\ result.addIncludePath(self.path.?.path(b, item)); | 177 | \\ result.addIncludePath(self.path.?.path(b, item)); |
| 173 | \\ dummy_library.root_module.addIncludePath(self.path.?.path(b, item)); | 178 | \\ dummy_library.root_module.addIncludePath(self.path.?.path(b, item)); |
| 179 | \\ exe.root_module.addIncludePath(self.path.?.path(b, item)); | ||
| 174 | \\ link_lib_c = true; | 180 | \\ link_lib_c = true; |
| 175 | \\ links += 1; | 181 | \\ links += 1; |
| 176 | \\ } | 182 | \\ } |
| ... | @@ -178,6 +184,20 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf | ... | @@ -178,6 +184,20 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: [:0]const u8, dir: nf |
| 178 | \\ dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags }); | 184 | \\ dummy_library.root_module.addCSourceFile(.{ .file = self.path.?.path(b, item), .flags = self.c_source_flags }); |
| 179 | \\ links += 1; | 185 | \\ links += 1; |
| 180 | \\ } | 186 | \\ } |
| 187 | \\ if (any_translate_c) if (self.translate_c_h) |h| { | ||
| 188 | \\ if (translate_c == null) translate_c = b.dependency("translate_c", .{}); | ||
| 189 | \\ const t: Translator = .init(translate_c.?, .{ | ||
| 190 | \\ .c_source_file = b.addWriteFile("c.h", b.fmt("// {s}\n#include <{s}>\n", .{ self.name, h })).getDirectory().path(b, "c.h"), | ||
| 191 | \\ .target = exe.root_module.resolved_target.?, | ||
| 192 | \\ .optimize = exe.root_module.optimize.?, | ||
| 193 | \\ }); | ||
| 194 | \\ for (exe.root_module.include_dirs.items) |d| { | ||
| 195 | \\ if (d != .path) continue; | ||
| 196 | \\ t.addIncludePath(d.path); | ||
| 197 | \\ } | ||
| 198 | \\ result.addImport("c", t.mod); | ||
| 199 | \\ link_lib_c = true; | ||
| 200 | \\ }; | ||
| 181 | \\ for (self.system_libs) |item| { | 201 | \\ for (self.system_libs) |item| { |
| 182 | \\ if (std.zig.target.isLibCLibName(&target, item)) continue; | 202 | \\ if (std.zig.target.isLibCLibName(&target, item)) continue; |
| 183 | \\ dummy_library.root_module.linkSystemLibrary(item, .{}); | 203 | \\ dummy_library.root_module.linkSystemLibrary(item, .{}); |
| ... | @@ -329,6 +349,9 @@ fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module | ... | @@ -329,6 +349,9 @@ fn print_pkg_data_to(w: nfs.File, notdone: *std.array_list.Managed(zigmod.Module |
| 329 | } | 349 | } |
| 330 | try w.writeAll(" },\n"); | 350 | try w.writeAll(" },\n"); |
| 331 | } | 351 | } |
| 352 | if (mod.translate_c_h) |h| { | ||
| 353 | try w.print(" .translate_c_h = \"{s}\",\n", .{h}); | ||
| 354 | } | ||
| 332 | try w.writeAll(" };\n"); | 355 | try w.writeAll(" };\n"); |
| 333 | 356 | ||
| 334 | try done.append(mod); | 357 | try done.append(mod); |
src/cmd/init.zig+6-5| ... | @@ -44,7 +44,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -44,7 +44,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 44 | error.CantFindMain => try std.mem.concat(gpa, u8, &.{ flatname, ".zig" }), | 44 | error.CantFindMain => try std.mem.concat(gpa, u8, &.{ flatname, ".zig" }), |
| 45 | else => |ee| return ee, | 45 | else => |ee| return ee, |
| 46 | }) else null; | 46 | }) else null; |
| 47 | const entry = if (entry_bare) |ent| try gpa.dupeZ(u8, ent) else null; | 47 | const entry = if (entry_bare) |ent| try gpa.dupeSentinel(u8, ent, 0) else null; |
| 48 | 48 | ||
| 49 | const maybe_license_text = try detectlicense.detectInDir(gpa, cwd); | 49 | const maybe_license_text = try detectlicense.detectInDir(gpa, cwd); |
| 50 | const license = try inquirer.forString(stdout, stdin, "license:", gpa, maybe_license_text); | 50 | const license = try inquirer.forString(stdout, stdin, "license:", gpa, maybe_license_text); |
| ... | @@ -153,6 +153,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -153,6 +153,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 153 | } | 153 | } |
| 154 | if (!exists) try w.writeAll(".zig-cache\n"); | 154 | if (!exists) try w.writeAll(".zig-cache\n"); |
| 155 | if (!exists) try w.writeAll("zig-out\n"); | 155 | if (!exists) try w.writeAll("zig-out\n"); |
| 156 | if (!exists) try w.writeAll("zig-pkg\n"); | ||
| 156 | try w.writeAll(".zigmod\n"); | 157 | try w.writeAll(".zigmod\n"); |
| 157 | try w.writeAll("deps.zig\n"); | 158 | try w.writeAll("deps.zig\n"); |
| 158 | try w.writeAll("files.zig\n"); | 159 | try w.writeAll("files.zig\n"); |
| ... | @@ -194,7 +195,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -194,7 +195,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 194 | \\ | 195 | \\ |
| 195 | \\pub fn build(b: *std.Build) void { | 196 | \\pub fn build(b: *std.Build) void { |
| 196 | \\ const target = b.standardTargetOptions(.{}); | 197 | \\ const target = b.standardTargetOptions(.{}); |
| 197 | \\ const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; | 198 | \\ const optimize = b.standardOptimizeOption(.{}); |
| 198 | \\ | 199 | \\ |
| 199 | \\ const exe = b.addExecutable(.{ | 200 | \\ const exe = b.addExecutable(.{ |
| 200 | \\ | 201 | \\ |
| ... | @@ -203,7 +204,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -203,7 +204,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 203 | try w.writeAll( | 204 | try w.writeAll( |
| 204 | \\ .root_source_file = b.path("main.zig"), | 205 | \\ .root_source_file = b.path("main.zig"), |
| 205 | \\ .target = target, | 206 | \\ .target = target, |
| 206 | \\ .optimize = mode, | 207 | \\ .optimize = optimize, |
| 207 | \\ }); | 208 | \\ }); |
| 208 | \\ deps.addAllTo(exe); | 209 | \\ deps.addAllTo(exe); |
| 209 | \\ b.installArtifact(exe); | 210 | \\ b.installArtifact(exe); |
| ... | @@ -224,12 +225,12 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -224,12 +225,12 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 224 | \\ | 225 | \\ |
| 225 | \\pub fn build(b: *std.Build) void { | 226 | \\pub fn build(b: *std.Build) void { |
| 226 | \\ const target = b.standardTargetOptions(.{}); | 227 | \\ const target = b.standardTargetOptions(.{}); |
| 227 | \\ const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; | 228 | \\ const optimize = b.standardOptimizeOption(.{}); |
| 228 | \\ | 229 | \\ |
| 229 | \\ const tests = b.addTest(.{ | 230 | \\ const tests = b.addTest(.{ |
| 230 | \\ .root_source_file = b.path("test.zig"), | 231 | \\ .root_source_file = b.path("test.zig"), |
| 231 | \\ .target = target, | 232 | \\ .target = target, |
| 232 | \\ .optimize = mode, | 233 | \\ .optimize = optimize, |
| 233 | \\ }); | 234 | \\ }); |
| 234 | \\ deps.addAllTo(tests); | 235 | \\ deps.addAllTo(tests); |
| 235 | \\ | 236 | \\ |
src/cmd/install.zig+3-2| ... | @@ -67,7 +67,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -67,7 +67,7 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 67 | 67 | ||
| 68 | const modfile = try zigmod.ModFile.from_dir(gpa, moddir, modpath); | 68 | const modfile = try zigmod.ModFile.from_dir(gpa, moddir, modpath); |
| 69 | const zigversion_sv = modfile.min_zig_version orelse u.fail("zigmod manifest requires min_zig_version field", .{}); | 69 | const zigversion_sv = modfile.min_zig_version orelse u.fail("zigmod manifest requires min_zig_version field", .{}); |
| 70 | const zigversion = try nio.fmt.allocPrint(gpa, "{s}", .{u.altSemanticVersion(zigversion_sv)}); | 70 | const zigversion = try nio.fmt.allocPrint(gpa, "{}", .{u.altSemanticVersion(zigversion_sv)}); |
| 71 | const zigpath = try std.fs.path.joinZ(gpa, &.{ datapath, "zig", zigversion, "zig" }); | 71 | const zigpath = try std.fs.path.joinZ(gpa, &.{ datapath, "zig", zigversion, "zig" }); |
| 72 | 72 | ||
| 73 | // regen deps.zig with the repo's zig version | 73 | // regen deps.zig with the repo's zig version |
| ... | @@ -89,7 +89,8 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -89,7 +89,8 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 89 | 0x0000_000d => try @import("./fetch.0.13.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), | 89 | 0x0000_000d => try @import("./fetch.0.13.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), |
| 90 | 0x0000_000e => try @import("./fetch.0.14.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), | 90 | 0x0000_000e => try @import("./fetch.0.14.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), |
| 91 | 0x0000_000f => try @import("./fetch.0.15.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), | 91 | 0x0000_000f => try @import("./fetch.0.15.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), |
| 92 | 0x0000_0010 => {}, // that's us, zigmod is already 0.16.0 | 92 | 0x0000_0010 => try @import("./fetch.0.16.zig").create_depszig(gpa, cachepath, moddir, fetch_top_module, &fetch_list), |
| 93 | 0x0000_0011 => {}, // that's us, zigmod is already 0.17.0 | ||
| 93 | else => u.fail("zig {d}.{d} unimplemented", .{ version_sct.major, version_sct.minor }), | 94 | else => u.fail("zig {d}.{d} unimplemented", .{ version_sct.major, version_sct.minor }), |
| 94 | } | 95 | } |
| 95 | 96 |
src/cmd/zpm.zig+2-2| ... | @@ -48,8 +48,8 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { | ... | @@ -48,8 +48,8 @@ pub fn execute(self_name: []const u8, args: []const [:0]const u8) !void { |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | inline for (comptime std.meta.declarations(commands)) |decl| { | 50 | inline for (comptime std.meta.declarations(commands)) |decl| { |
| 51 | if (std.mem.eql(u8, args[0], decl.name)) { | 51 | if (std.mem.eql(u8, args[0], decl)) { |
| 52 | const cmd = @field(commands, decl.name); | 52 | const cmd = @field(commands, decl); |
| 53 | try cmd.execute(self_name, args[1..]); | 53 | try cmd.execute(self_name, args[1..]); |
| 54 | return; | 54 | return; |
| 55 | } | 55 | } |
src/common.zig+7-4| ... | @@ -58,6 +58,7 @@ pub fn collect_deps_deep(cachepath: [:0]const u8, mdir: nfs.Dir, options: *Colle | ... | @@ -58,6 +58,7 @@ pub fn collect_deps_deep(cachepath: [:0]const u8, mdir: nfs.Dir, options: *Colle |
| 58 | .yaml = m.yaml, | 58 | .yaml = m.yaml, |
| 59 | .dep = null, | 59 | .dep = null, |
| 60 | .min_zig_version = m.min_zig_version, | 60 | .min_zig_version = m.min_zig_version, |
| 61 | .translate_c_h = m.translate_c_h, | ||
| 61 | }; | 62 | }; |
| 62 | } | 63 | } |
| 63 | 64 | ||
| ... | @@ -88,6 +89,7 @@ pub fn collect_deps(cachepath: [:0]const u8, mdir: nfs.Dir, mdir_path: string, d | ... | @@ -88,6 +89,7 @@ pub fn collect_deps(cachepath: [:0]const u8, mdir: nfs.Dir, mdir_path: string, d |
| 88 | .yaml = m.yaml, | 89 | .yaml = m.yaml, |
| 89 | .dep = null, | 90 | .dep = null, |
| 90 | .min_zig_version = m.min_zig_version, | 91 | .min_zig_version = m.min_zig_version, |
| 92 | .translate_c_h = m.translate_c_h, | ||
| 91 | }; | 93 | }; |
| 92 | } | 94 | } |
| 93 | 95 | ||
| ... | @@ -121,7 +123,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -121,7 +123,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 121 | switch (d.type) { | 123 | switch (d.type) { |
| 122 | .local => { | 124 | .local => { |
| 123 | if (!std.mem.endsWith(u8, d.main, ".zig")) { | 125 | if (!std.mem.endsWith(u8, d.main, ".zig")) { |
| 124 | return gpa.dupeZ(u8, d.main); | 126 | return gpa.dupeSentinel(u8, d.main, 0); |
| 125 | } | 127 | } |
| 126 | return d.path; | 128 | return d.path; |
| 127 | }, | 129 | }, |
| ... | @@ -206,7 +208,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -206,7 +208,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 206 | } | 208 | } |
| 207 | const file_path_s = try std.fs.path.resolve(options.alloc, &.{ p, file_name }); | 209 | const file_path_s = try std.fs.path.resolve(options.alloc, &.{ p, file_name }); |
| 208 | defer gpa.free(file_path_s); | 210 | defer gpa.free(file_path_s); |
| 209 | const file_path = try gpa.dupeZ(u8, file_path_s); | 211 | const file_path = try gpa.dupeSentinel(u8, file_path_s, 0); |
| 210 | try d.type.pull(options.alloc, d.path, p); | 212 | try d.type.pull(options.alloc, d.path, p); |
| 211 | try nfs.cwd().deleteFile(file_path); | 213 | try nfs.cwd().deleteFile(file_path); |
| 212 | return p; | 214 | return p; |
| ... | @@ -219,7 +221,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: [:0]const u8, options: *Co | ... | @@ -219,7 +221,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: [:0]const u8, options: *Co |
| 219 | for (lock) |item| { | 221 | for (lock) |item| { |
| 220 | if (std.mem.eql(u8, item[0], try d.clean_path(options.alloc))) { | 222 | if (std.mem.eql(u8, item[0], try d.clean_path(options.alloc))) { |
| 221 | d.type = std.meta.stringToEnum(zigmod.Dep.Type, item[1]).?; | 223 | d.type = std.meta.stringToEnum(zigmod.Dep.Type, item[1]).?; |
| 222 | d.path = try gpa.dupeZ(u8, item[2]); | 224 | d.path = try gpa.dupeSentinel(u8, item[2], 0); |
| 223 | d.version = item[3]; | 225 | d.version = item[3]; |
| 224 | break; | 226 | break; |
| 225 | } | 227 | } |
| ... | @@ -247,6 +249,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: [:0]const u8, options: *Co | ... | @@ -247,6 +249,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: [:0]const u8, options: *Co |
| 247 | .dep = d.*, | 249 | .dep = d.*, |
| 248 | .for_build = d.for_build, | 250 | .for_build = d.for_build, |
| 249 | .min_zig_version = null, | 251 | .min_zig_version = null, |
| 252 | .translate_c_h = null, | ||
| 250 | }; | 253 | }; |
| 251 | }, | 254 | }, |
| 252 | else => { | 255 | else => { |
| ... | @@ -384,7 +387,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const [4]string | ... | @@ -384,7 +387,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const [4]string |
| 384 | var iter = std.mem.splitScalar(u8, line, ' '); | 387 | var iter = std.mem.splitScalar(u8, line, ' '); |
| 385 | const asdep = zigmod.Dep{ | 388 | const asdep = zigmod.Dep{ |
| 386 | .type = std.meta.stringToEnum(zigmod.Dep.Type, iter.next().?).?, | 389 | .type = std.meta.stringToEnum(zigmod.Dep.Type, iter.next().?).?, |
| 387 | .path = try gpa.dupeZ(u8, iter.next().?), | 390 | .path = try gpa.dupeSentinel(u8, iter.next().?, 0), |
| 388 | .version = iter.next().?, | 391 | .version = iter.next().?, |
| 389 | .id = zigmod.Dep.EMPTY, | 392 | .id = zigmod.Dep.EMPTY, |
| 390 | .name = "", | 393 | .name = "", |
src/main.zig+3-3| ... | @@ -39,7 +39,7 @@ pub fn main(init: std.process.Init.Minimal) !void { | ... | @@ -39,7 +39,7 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 39 | std.debug.print("\n", .{}); | 39 | std.debug.print("\n", .{}); |
| 40 | std.debug.print("The commands available are:\n", .{}); | 40 | std.debug.print("The commands available are:\n", .{}); |
| 41 | inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { | 41 | inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { |
| 42 | std.debug.print(" - {s}\n", .{decl.name}); | 42 | std.debug.print(" - {s}\n", .{decl}); |
| 43 | } | 43 | } |
| 44 | return; | 44 | return; |
| 45 | } | 45 | } |
| ... | @@ -58,8 +58,8 @@ pub fn main(init: std.process.Init.Minimal) !void { | ... | @@ -58,8 +58,8 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 58 | defer zigmod.deinit(); | 58 | defer zigmod.deinit(); |
| 59 | 59 | ||
| 60 | inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { | 60 | inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { |
| 61 | if (std.mem.eql(u8, args[0], decl.name)) { | 61 | if (std.mem.eql(u8, args[0], decl)) { |
| 62 | const cmd = @field(zigmod.commands, decl.name); | 62 | const cmd = @field(zigmod.commands, decl); |
| 63 | try cmd.execute(self_path, args[1..]); | 63 | try cmd.execute(self_path, args[1..]); |
| 64 | return; | 64 | return; |
| 65 | } | 65 | } |
src/util/dep.zig+2-1| ... | @@ -28,8 +28,9 @@ pub const Dep = struct { | ... | @@ -28,8 +28,9 @@ pub const Dep = struct { |
| 28 | deps: []zigmod.Dep, | 28 | deps: []zigmod.Dep, |
| 29 | keep: bool = false, | 29 | keep: bool = false, |
| 30 | for_build: bool = false, | 30 | for_build: bool = false, |
| 31 | translate_c_h: ?string = null, | ||
| 31 | 32 | ||
| 32 | pub const EMPTY = (" " ** 48).*; | 33 | pub const EMPTY: [48]u8 = @splat(' '); |
| 33 | 34 | ||
| 34 | pub const Type = @import("./dep_type.zig").DepType; | 35 | pub const Type = @import("./dep_type.zig").DepType; |
| 35 | 36 |
src/util/funcs.zig+2-2| ... | @@ -56,7 +56,7 @@ pub fn file_list(alloc: std.mem.Allocator, dpath: [:0]const u8) ![]const [:0]con | ... | @@ -56,7 +56,7 @@ pub fn file_list(alloc: std.mem.Allocator, dpath: [:0]const u8) ![]const [:0]con |
| 56 | defer walker.deinit(); | 56 | defer walker.deinit(); |
| 57 | while (try walker.next()) |entry| { | 57 | while (try walker.next()) |entry| { |
| 58 | if (entry.type != .REG) continue; | 58 | if (entry.type != .REG) continue; |
| 59 | try list.append(try alloc.dupeZ(u8, entry.path)); | 59 | try list.append(try alloc.dupeSentinel(u8, entry.path, 0)); |
| 60 | } | 60 | } |
| 61 | return list.toOwnedSlice(); | 61 | return list.toOwnedSlice(); |
| 62 | } | 62 | } |
| ... | @@ -230,7 +230,7 @@ pub fn find_cachepath() ![:0]const u8 { | ... | @@ -230,7 +230,7 @@ pub fn find_cachepath() ![:0]const u8 { |
| 230 | const needle = "/.zigmod/deps"; | 230 | const needle = "/.zigmod/deps"; |
| 231 | 231 | ||
| 232 | if (std.mem.indexOf(u8, haystack, needle)) |index| { | 232 | if (std.mem.indexOf(u8, haystack, needle)) |index| { |
| 233 | return gpa.dupeZ(u8, haystack[0 .. index + needle.len]); | 233 | return gpa.dupeSentinel(u8, haystack[0 .. index + needle.len], 0); |
| 234 | } | 234 | } |
| 235 | return try std.fs.path.joinZ(gpa, &.{ haystack, ".zigmod", "deps" }); | 235 | return try std.fs.path.joinZ(gpa, &.{ haystack, ".zigmod", "deps" }); |
| 236 | } | 236 | } |
src/util/modfile.zig+5-2| ... | @@ -33,6 +33,7 @@ pub const ModFile = struct { | ... | @@ -33,6 +33,7 @@ pub const ModFile = struct { |
| 33 | rootdeps: []zigmod.Dep, | 33 | rootdeps: []zigmod.Dep, |
| 34 | builddeps: []zigmod.Dep, | 34 | builddeps: []zigmod.Dep, |
| 35 | min_zig_version: ?std.SemanticVersion, | 35 | min_zig_version: ?std.SemanticVersion, |
| 36 | translate_c_h: ?string = null, | ||
| 36 | 37 | ||
| 37 | pub fn openFile(dir: nfs.Dir, ops: nfs.Dir.OpenFileFlags) !struct { string, nfs.File } { | 38 | pub fn openFile(dir: nfs.Dir, ops: nfs.Dir.OpenFileFlags) !struct { string, nfs.File } { |
| 38 | return .{ "zig.mod", dir.openFile("zig.mod", ops) catch |err| switch (err) { | 39 | return .{ "zig.mod", dir.openFile("zig.mod", ops) catch |err| switch (err) { |
| ... | @@ -91,6 +92,7 @@ pub const ModFile = struct { | ... | @@ -91,6 +92,7 @@ pub const ModFile = struct { |
| 91 | .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false), | 92 | .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false), |
| 92 | .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true), | 93 | .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true), |
| 93 | .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version") orelse "") catch null, | 94 | .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version") orelse "") catch null, |
| 95 | .translate_c_h = mapping.get_string("translate_c_h"), | ||
| 94 | }; | 96 | }; |
| 95 | } | 97 | } |
| 96 | 98 | ||
| ... | @@ -110,9 +112,9 @@ pub const ModFile = struct { | ... | @@ -110,9 +112,9 @@ pub const ModFile = struct { |
| 110 | if (item.mapping.get("src")) |val| { | 112 | if (item.mapping.get("src")) |val| { |
| 111 | var src_iter = std.mem.tokenizeScalar(u8, val.string, ' '); | 113 | var src_iter = std.mem.tokenizeScalar(u8, val.string, ' '); |
| 112 | dtype = src_iter.next().?; | 114 | dtype = src_iter.next().?; |
| 113 | path = try gpa.dupeZ(u8, src_iter.next().?); | 115 | path = try gpa.dupeSentinel(u8, src_iter.next().?, 0); |
| 114 | if (src_iter.next()) |dver| { | 116 | if (src_iter.next()) |dver| { |
| 115 | version = try gpa.dupeZ(u8, dver); | 117 | version = try gpa.dupeSentinel(u8, dver, 0); |
| 116 | } | 118 | } |
| 117 | } else { | 119 | } else { |
| 118 | dtype = item.mapping.get("type").?.string; | 120 | dtype = item.mapping.get("type").?.string; |
| ... | @@ -151,6 +153,7 @@ pub const ModFile = struct { | ... | @@ -151,6 +153,7 @@ pub const ModFile = struct { |
| 151 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build), | 153 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build), |
| 152 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), | 154 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), |
| 153 | .for_build = for_build, | 155 | .for_build = for_build, |
| 156 | .translate_c_h = item.mapping.get_string("translate_c_h"), | ||
| 154 | }); | 157 | }); |
| 155 | // const d = &dep_list.getLast(); | 158 | // const d = &dep_list.getLast(); |
| 156 | } | 159 | } |
src/util/module.zig+10-2| ... | @@ -29,8 +29,9 @@ pub const Module = struct { | ... | @@ -29,8 +29,9 @@ pub const Module = struct { |
| 29 | dep: ?zigmod.Dep, | 29 | dep: ?zigmod.Dep, |
| 30 | for_build: bool = false, | 30 | for_build: bool = false, |
| 31 | min_zig_version: ?std.SemanticVersion, | 31 | min_zig_version: ?std.SemanticVersion, |
| 32 | translate_c_h: ?string, | ||
| 32 | 33 | ||
| 33 | pub const ROOT: [48]u8 = ("root" ++ (" " ** 44)).*; | 34 | pub const ROOT: [48]u8 = ("root" ++ @as([44]u8, @splat(' '))).*; |
| 34 | 35 | ||
| 35 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: [:0]const u8, options: *common.CollectOptions) !Module { | 36 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: [:0]const u8, options: *common.CollectOptions) !Module { |
| 36 | var moddeps = std.array_list.Managed(Module).init(alloc); | 37 | var moddeps = std.array_list.Managed(Module).init(alloc); |
| ... | @@ -61,6 +62,7 @@ pub const Module = struct { | ... | @@ -61,6 +62,7 @@ pub const Module = struct { |
| 61 | .dep = dep, | 62 | .dep = dep, |
| 62 | .for_build = dep.for_build, | 63 | .for_build = dep.for_build, |
| 63 | .min_zig_version = null, | 64 | .min_zig_version = null, |
| 65 | .translate_c_h = dep.translate_c_h, | ||
| 64 | }; | 66 | }; |
| 65 | } | 67 | } |
| 66 | 68 | ||
| ... | @@ -80,7 +82,7 @@ pub const Module = struct { | ... | @@ -80,7 +82,7 @@ pub const Module = struct { |
| 80 | try file_list_2.append(_b); | 82 | try file_list_2.append(_b); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | std.mem.sort(string, file_list_2.items, void{}, struct { | 85 | std.mem.sort(string, file_list_2.items, {}, struct { |
| 84 | pub fn lt(context: void, lhs: string, rhs: string) bool { | 86 | pub fn lt(context: void, lhs: string, rhs: string) bool { |
| 85 | _ = context; | 87 | _ = context; |
| 86 | return std.mem.lessThan(u8, lhs, rhs); | 88 | return std.mem.lessThan(u8, lhs, rhs); |
| ... | @@ -204,4 +206,10 @@ pub const Module = struct { | ... | @@ -204,4 +206,10 @@ pub const Module = struct { |
| 204 | }, | 206 | }, |
| 205 | }; | 207 | }; |
| 206 | } | 208 | } |
| 209 | |||
| 210 | pub fn any_translate_c(self: *const Module) bool { | ||
| 211 | if (self.translate_c_h) |_| return true; | ||
| 212 | for (self.deps) |d| if (d.any_translate_c()) return true; | ||
| 213 | return false; | ||
| 214 | } | ||
| 207 | }; | 215 | }; |
zig.mod+2-2| ... | @@ -3,7 +3,7 @@ name: zigmod | ... | @@ -3,7 +3,7 @@ name: zigmod |
| 3 | main: src/lib.zig | 3 | main: src/lib.zig |
| 4 | license: MIT | 4 | license: MIT |
| 5 | description: A package manager for the Zig programming language. | 5 | description: A package manager for the Zig programming language. |
| 6 | min_zig_version: 0.16.0 | 6 | min_zig_version: 0.17.0 |
| 7 | min_zigmod_version: r96 | 7 | min_zigmod_version: r96 |
| 8 | dependencies: | 8 | dependencies: |
| 9 | - src: git https://github.com/nektro/zig-yaml | 9 | - src: git https://github.com/nektro/zig-yaml |
| ... | @@ -13,7 +13,7 @@ dependencies: | ... | @@ -13,7 +13,7 @@ dependencies: |
| 13 | name: known-folders | 13 | name: known-folders |
| 14 | main: known-folders.zig | 14 | main: known-folders.zig |
| 15 | license: MIT | 15 | license: MIT |
| 16 | version: commit-207c34a16e4365edc20d92c7892f962b3bed46e8 | 16 | version: commit-6da0d0c41b78b9ed2d34fa364fcb81b5ebece6c4 |
| 17 | - src: git https://github.com/nektro/zig-licenses | 17 | - src: git https://github.com/nektro/zig-licenses |
| 18 | - src: git https://github.com/nektro/zig-detect-license | 18 | - src: git https://github.com/nektro/zig-detect-license |
| 19 | - src: git https://github.com/nektro/zig-inquirer | 19 | - src: git https://github.com/nektro/zig-inquirer |
zigmod.lock+22-22| ... | @@ -1,26 +1,26 @@ | ... | @@ -1,26 +1,26 @@ |
| 1 | 2 | 1 | 2 |
| 2 | git https://github.com/marlersoft/zigwin32 commit-fb2645891520f3e99931db17a7eba04057e87e89 | 2 | git https://github.com/marlersoft/zigwin32 commit-fb2645891520f3e99931db17a7eba04057e87e89 |
| 3 | git https://github.com/nektro/arqv-ini commit-d2465c64833590a04bd9b7f50c87363fd03e65bf | 3 | git https://github.com/nektro/arqv-ini commit-2951069265792192bd714980d44ccb4abee4a6e8 |
| 4 | git https://github.com/nektro/zig-ansi commit-bebb39ae30d9848a1c212cee582d0b1c102d8b87 | 4 | git https://github.com/nektro/zig-ansi commit-952d0751c359612fc1a7c493453cc6223bbaff5d |
| 5 | git https://github.com/nektro/zig-detect-license commit-6de79b4ff8f7462e26f224f4bed3c81710c8893b | 5 | git https://github.com/nektro/zig-detect-license commit-2ec231c2ae5274d926851f355f0896e0fcbbb5d0 |
| 6 | git https://github.com/nektro/zig-extras commit-0c90ee9a82d8863e0e142211a587940ee2a09790 | 6 | git https://github.com/nektro/zig-extras commit-fb3aa273de9116bbb7befd448835b854d906f2ee |
| 7 | git https://github.com/nektro/zig-git commit-88b94a1960be841bb93a0bca65d556cb6385d1fd | 7 | git https://github.com/nektro/zig-git commit-f4bd29ad59967102db4532bda2d95d1512fbf3fb |
| 8 | git https://github.com/nektro/zig-inquirer commit-e745b018f87ddc4c8958370332e6cf61625403cc | 8 | git https://github.com/nektro/zig-inquirer commit-6feae6d21ac54cba8e5d4da91868c4db9f82343b |
| 9 | git https://github.com/nektro/zig-intrusive-parser commit-2409be829d989bd03b6d123159880660c6089820 | 9 | git https://github.com/nektro/zig-intrusive-parser commit-6d074187f8c5aa2bdab11ee57c7180df768fca72 |
| 10 | git https://github.com/nektro/zig-json commit-d32454ad6d1a6e6e58a8c12a4f3ee1223be2e316 | 10 | git https://github.com/nektro/zig-json commit-4f6aa411f1dc93cc86a052d8a69804c8ff762e59 |
| 11 | git https://github.com/nektro/zig-leven commit-014971d4b1e327a5c61322c3a6b9369fd1863864 | 11 | git https://github.com/nektro/zig-leven commit-d990af4f7706edcb0d928d953d1a56c2830fa036 |
| 12 | git https://github.com/nektro/zig-licenses commit-bc1cd51625c13d6c7df819fd0d85968e617f5c57 | 12 | git https://github.com/nektro/zig-licenses commit-1fd04fc1b7619ca2ddfd07354a93e6d72334f76f |
| 13 | git https://github.com/nektro/zig-licenses-text commit-a9d067c3c4d6c226a1de5531b66785bc15d869ee | 13 | git https://github.com/nektro/zig-licenses-text commit-a20d31da306967253b8a46c60d8368c7ac4b7229 |
| 14 | git https://github.com/nektro/zig-nfs commit-1a27fe574706f0b91c9f66b22fe7d3fa8f5129d5 | 14 | git https://github.com/nektro/zig-nfs commit-b32bb30bbdc7e5ad9bb3adb5c477a98897c9cb10 |
| 15 | git https://github.com/nektro/zig-nio commit-17c4f044b15917efc1d3f018765881d53fa27e48 | 15 | git https://github.com/nektro/zig-nio commit-b28c8efc86f3baec3737de86ffde5c4b3a5260f6 |
| 16 | git https://github.com/nektro/zig-sys-darwin commit-b349aa32b55aae4cf2ae56740003f8aff0394920 | 16 | git https://github.com/nektro/zig-sys-darwin commit-312638dcf043c3163e260ec5b42610856fc9eeab |
| 17 | git https://github.com/nektro/zig-sys-freebsd commit-f97e6c2de30af76818572490735c84ce1015958b | 17 | git https://github.com/nektro/zig-sys-freebsd commit-967ac568e385534825e6849bc82a9b51d45c600c |
| 18 | git https://github.com/nektro/zig-sys-linux commit-6dabe7cce239d882c8fd132ab5cda1d1f9ff3634 | 18 | git https://github.com/nektro/zig-sys-linux commit-750d2aa874a9ddb473e7cd0af99f1e722aaab79d |
| 19 | git https://github.com/nektro/zig-sys-netbsd commit-5ad432ca421c59099be3630b9d0dda49e8bef0a7 | 19 | git https://github.com/nektro/zig-sys-netbsd commit-e16386268223744ac3f6036a028cc4359056731b |
| 20 | git https://github.com/nektro/zig-sys-openbsd commit-164646a5e7c4129eb92ac524a60f1759605c99df | 20 | git https://github.com/nektro/zig-sys-openbsd commit-081e11079887e8f02d8480b6219a13a41afd8d69 |
| 21 | git https://github.com/nektro/zig-time commit-1349fb2c8aaaa1503e8730facea6f87c5fe75dc0 | 21 | git https://github.com/nektro/zig-time commit-29f3f902cc8948faa36b853380c38ff587236661 |
| 22 | git https://github.com/nektro/zig-tracer commit-4ad0602d52a3f40ef74f59f648602c61409f7ba7 | 22 | git https://github.com/nektro/zig-tracer commit-ccf9a6b85a38cc343aba772f2d2aac4df49000e1 |
| 23 | git https://github.com/nektro/zig-yaml commit-dff9fd43ebf1046c70090bdccfeb2e4f1c0d584b | 23 | git https://github.com/nektro/zig-yaml commit-e4e8dfe78a3a0e39d134382a18e8eb771418e850 |
| 24 | git https://github.com/madler/zlib tag-v1.3.2 | 24 | git https://github.com/madler/zlib tag-v1.3.2 |
| 25 | git https://github.com/yaml/libyaml tag-0.2.5 | 25 | git https://github.com/yaml/libyaml tag-0.2.5 |
| 26 | git https://github.com/ziglibs/known-folders commit-207c34a16e4365edc20d92c7892f962b3bed46e8 | 26 | git https://github.com/ziglibs/known-folders commit-6da0d0c41b78b9ed2d34fa364fcb81b5ebece6c4 |