| author | |
| committer | |
| log | 21683f9329aa22ed8a2d0e3cdff48a398521b65c |
| tree | 89f8b0910f0be90c8f0dd16132aea8c1a6d7d5bd |
| parent | 53130967cc11bb69e4eee56844ae6a6e8fbcdd74 |
18 files changed, 286 insertions(+), 308 deletions(-)
.github/workflows/nightly.yml+1-1| ... | ... | @@ -26,7 +26,7 @@ jobs: |
| 26 | 26 | - name: Setup Zig |
| 27 | 27 | uses: goto-bus-stop/setup-zig@v2 |
| 28 | 28 | with: |
| 29 | version: "0.11.0" | |
| 29 | version: "0.12.0" | |
| 30 | 30 | |
| 31 | 31 | - run: zig version |
| 32 | 32 | - run: zig env |
.github/workflows/push.yml+1-1| ... | ... | @@ -19,7 +19,7 @@ jobs: |
| 19 | 19 | - name: Setup Zig |
| 20 | 20 | uses: goto-bus-stop/setup-zig@v2 |
| 21 | 21 | with: |
| 22 | version: "0.11.0" | |
| 22 | version: "0.12.0" | |
| 23 | 23 | |
| 24 | 24 | - run: zig version |
| 25 | 25 | - run: zig env |
README.md+1-1| ... | ... | @@ -16,7 +16,7 @@ A package manager for the Zig programming language. |
| 16 | 16 | - https://github.com/nektro/zigmod/releases |
| 17 | 17 | |
| 18 | 18 | ## Built With |
| 19 | - Zig master (at least `0.11.0`) | |
| 19 | - Zig master (at least `0.12.0`) | |
| 20 | 20 | - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) |
| 21 | 21 | |
| 22 | 22 | ### Build from Source |
build.zig+10-5| ... | ... | @@ -3,22 +3,27 @@ const string = []const u8; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | const deps = @import("./deps.zig"); |
| 5 | 5 | |
| 6 | pub fn build(b: *std.build.Builder) void { | |
| 6 | pub fn build(b: *std.Build) void { | |
| 7 | 7 | const target = b.standardTargetOptions(.{}); |
| 8 | 8 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; |
| 9 | 9 | const use_full_name = b.option(bool, "use-full-name", "") orelse false; |
| 10 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) }); | |
| 10 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) }); | |
| 11 | 11 | const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); |
| 12 | const exe = b.addExecutable(.{ .name = exe_name, .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = mode }); | |
| 12 | const exe = b.addExecutable(.{ | |
| 13 | .name = exe_name, | |
| 14 | .root_source_file = .{ .path = "src/main.zig" }, | |
| 15 | .target = target, | |
| 16 | .optimize = mode, | |
| 17 | }); | |
| 13 | 18 | const tag = b.option(string, "tag", "") orelse "dev"; |
| 14 | 19 | const strip = b.option(bool, "strip", "Build without debug info.") orelse false; |
| 15 | 20 | |
| 16 | 21 | const exe_options = b.addOptions(); |
| 17 | exe.addOptions("build_options", exe_options); | |
| 22 | exe.root_module.addImport("build_options", exe_options.createModule()); | |
| 18 | 23 | exe_options.addOption(string, "version", tag); |
| 19 | 24 | |
| 20 | 25 | deps.addAllTo(exe); |
| 21 | exe.strip = strip; | |
| 26 | exe.root_module.strip = strip; | |
| 22 | 27 | b.installArtifact(exe); |
| 23 | 28 | |
| 24 | 29 | const run_cmd = b.addRunArtifact(exe); |
deps.zig+106-105| ... | ... | @@ -1,19 +1,18 @@ |
| 1 | 1 | // zig fmt: off |
| 2 | 2 | const std = @import("std"); |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | const ModuleDependency = std.build.ModuleDependency; | |
| 5 | 4 | const string = []const u8; |
| 6 | 5 | |
| 7 | 6 | pub const GitExactStep = struct { |
| 8 | step: std.build.Step, | |
| 9 | builder: *std.build.Builder, | |
| 7 | step: std.Build.Step, | |
| 8 | builder: *std.Build, | |
| 10 | 9 | url: string, |
| 11 | 10 | commit: string, |
| 12 | 11 | |
| 13 | pub fn create(b: *std.build.Builder, url: string, commit: string) *GitExactStep { | |
| 12 | pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep { | |
| 14 | 13 | var result = b.allocator.create(GitExactStep) catch @panic("memory"); |
| 15 | 14 | result.* = GitExactStep{ |
| 16 | .step = std.build.Step.init(.{ | |
| 15 | .step = std.Build.Step.init(.{ | |
| 17 | 16 | .id = .custom, |
| 18 | 17 | .name = b.fmt("git clone {s} @ {s}", .{ url, commit }), |
| 19 | 18 | .owner = b, |
| ... | ... | @@ -30,11 +29,11 @@ pub const GitExactStep = struct { |
| 30 | 29 | const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit }); |
| 31 | 30 | flip(std.fs.cwd().access(repopath, .{})) catch return result; |
| 32 | 31 | |
| 33 | var clonestep = std.build.RunStep.create(b, "clone"); | |
| 32 | var clonestep = std.Build.Step.Run.create(b, "clone"); | |
| 34 | 33 | clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath }); |
| 35 | 34 | result.step.dependOn(&clonestep.step); |
| 36 | 35 | |
| 37 | var checkoutstep = std.build.RunStep.create(b, "checkout"); | |
| 36 | var checkoutstep = std.Build.Step.Run.create(b, "checkout"); | |
| 38 | 37 | checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit }); |
| 39 | 38 | result.step.dependOn(&checkoutstep.step); |
| 40 | 39 | checkoutstep.step.dependOn(&clonestep.step); |
| ... | ... | @@ -42,35 +41,35 @@ pub const GitExactStep = struct { |
| 42 | 41 | return result; |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void { | |
| 44 | fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void { | |
| 46 | 45 | _ = step; |
| 47 | 46 | _ = prog_node; |
| 48 | 47 | } |
| 49 | 48 | }; |
| 50 | 49 | |
| 51 | pub fn fetch(exe: *std.build.LibExeObjStep) void { | |
| 50 | pub fn fetch(exe: *std.Build.Step.Compile) void { | |
| 52 | 51 | const b = exe.step.owner; |
| 53 | 52 | inline for (comptime std.meta.declarations(package_data)) |decl| { |
| 54 | const path = &@field(package_data, decl.name).entry; | |
| 55 | const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else "."; | |
| 56 | if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? }); | |
| 53 | const path = &@field(package_data, decl.name).entry; | |
| 54 | const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else "."; | |
| 55 | if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? }); | |
| 57 | 56 | } |
| 58 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "6777f1db221d0cb50322842f558f03e3c3a4099f").step); | |
| 59 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "ddbe89bb0d9085e939bcbc713caeb2b7cf852bae").step); | |
| 60 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40").step); | |
| 61 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "f51277414a2309f776fb79f3d55f26e37f9a54da").step); | |
| 62 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "ac607e4e7ac36d46cc67c8786262578330543a36").step); | |
| 57 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "c778640d3dc153e900fbe37e2816b5176af3c802").step); | |
| 58 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "38a018ad3a19d5b4663a5364d2d31271f250846b").step); | |
| 59 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "4dc8850883b49e4a452871298788b06b1af9fe24").step); | |
| 60 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "863be236188e5f24d16554f9dcd7df96dd254a13").step); | |
| 61 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "c3e439f86b0484e4428f38c4d8b07b7b5ae1634b").step); | |
| 63 | 62 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step); |
| 64 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "05f0e90a185cb04a09b96f686dffc6375c420e9b").step); | |
| 65 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "5cc2a5565d04fe2c0085f0d6818590e800d9dcf7").step); | |
| 66 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "550cabd5a18ace5e67761bc5b867c10e926f4314").step); | |
| 67 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "c9b8cbf3565675a056ad4e9b57cb4f84020e7680").step); | |
| 68 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "3c07c6e4eb0965dafd0b029c632f823631b3169c").step); | |
| 63 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step); | |
| 64 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "9e1d873db79e9ffa6ae6e06bd372428c9be85d97").step); | |
| 65 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e548b0bcc7b6f34f636c0b6b905928d31254c54d").step); | |
| 66 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step); | |
| 67 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step); | |
| 69 | 68 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step); |
| 70 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "12fad367a5282827aad7e12f0e9cd36f672c4010").step); | |
| 69 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "ba546bbf2e8438c9b2325f36f392c9d95b432e8e").step); | |
| 71 | 70 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step); |
| 72 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "92e6072d8a385d8b08fdcae3ae2021fe5293528f").step); | |
| 73 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "855473062efac722624737f1adc56f9c0dd92017").step); | |
| 71 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "a7f03a1e652abe8c89b376d090cec50acb0d2a1a").step); | |
| 72 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "0ad514dcfb7525e32ae349b9acc0a53976f3a9fa").step); | |
| 74 | 73 | exe.step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step); |
| 75 | 74 | } |
| 76 | 75 | |
| ... | ... | @@ -86,48 +85,17 @@ fn flip(foo: anytype) !void { |
| 86 | 85 | return error.ExpectedError; |
| 87 | 86 | } |
| 88 | 87 | |
| 89 | pub fn addAllTo(exe: *std.build.LibExeObjStep) void { | |
| 88 | pub fn addAllTo(exe: *std.Build.Step.Compile) void { | |
| 90 | 89 | checkMinZig(builtin.zig_version, exe); |
| 91 | 90 | fetch(exe); |
| 92 | const b = exe.step.owner; | |
| 93 | 91 | @setEvalBranchQuota(1_000_000); |
| 94 | 92 | for (packages) |pkg| { |
| 95 | const moddep = pkg.zp(b); | |
| 96 | exe.addModule(moddep.name, moddep.module); | |
| 97 | } | |
| 98 | addAllLibrariesTo(exe); | |
| 99 | } | |
| 100 | ||
| 101 | pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void { | |
| 102 | const b = exe.step.owner; | |
| 103 | var llc = false; | |
| 104 | var vcpkg = false; | |
| 105 | inline for (comptime std.meta.declarations(package_data)) |decl| { | |
| 106 | const pkg = @as(Package, @field(package_data, decl.name)); | |
| 107 | const root = if (pkg.store) |st| b.fmt("{s}/zigmod/deps/{s}", .{ b.cache_root.path.?, st }) else "."; | |
| 108 | for (pkg.system_libs) |item| { | |
| 109 | exe.linkSystemLibrary(item); | |
| 110 | llc = true; | |
| 111 | } | |
| 112 | for (pkg.frameworks) |item| { | |
| 113 | if (!builtin.target.isDarwin()) @panic(exe.step.owner.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item})); | |
| 114 | exe.linkFramework(item); | |
| 115 | llc = true; | |
| 116 | } | |
| 117 | for (pkg.c_include_dirs) |item| { | |
| 118 | exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ root, item })}); | |
| 119 | llc = true; | |
| 120 | } | |
| 121 | for (pkg.c_source_files) |item| { | |
| 122 | exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ root, item }) }, .flags = pkg.c_source_flags }); | |
| 123 | llc = true; | |
| 124 | } | |
| 125 | vcpkg = vcpkg or pkg.vcpkg; | |
| 93 | const module = pkg.module(exe); | |
| 94 | exe.root_module.addImport(pkg.name, module); | |
| 126 | 95 | } |
| 127 | if (llc) exe.linkLibC(); | |
| 128 | if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err)); | |
| 129 | 96 | } |
| 130 | 97 | |
| 98 | var link_lib_c = false; | |
| 131 | 99 | pub const Package = struct { |
| 132 | 100 | name: string = "", |
| 133 | 101 | entry: ?string = null, |
| ... | ... | @@ -138,69 +106,102 @@ pub const Package = struct { |
| 138 | 106 | c_source_flags: []const string = &.{}, |
| 139 | 107 | system_libs: []const string = &.{}, |
| 140 | 108 | frameworks: []const string = &.{}, |
| 141 | vcpkg: bool = false, | |
| 142 | module: ?ModuleDependency = null, | |
| 109 | module_memo: ?*std.Build.Module = null, | |
| 143 | 110 | |
| 144 | pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency { | |
| 145 | var temp: [100]ModuleDependency = undefined; | |
| 146 | for (self.deps, 0..) |item, i| { | |
| 147 | temp[i] = item.zp(b); | |
| 111 | pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module { | |
| 112 | if (self.module_memo) |cached| { | |
| 113 | return cached; | |
| 148 | 114 | } |
| 149 | if (self.module) |mod| { | |
| 150 | return mod; | |
| 115 | const b = exe.step.owner; | |
| 116 | ||
| 117 | const result = b.createModule(.{}); | |
| 118 | const dummy_library = b.addStaticLibrary(.{ | |
| 119 | .name = "dummy", | |
| 120 | .target = exe.root_module.resolved_target orelse b.host, | |
| 121 | .optimize = exe.root_module.optimize.?, | |
| 122 | }); | |
| 123 | if (self.entry) |capture| { | |
| 124 | result.root_source_file = .{ .path = capture }; | |
| 125 | } | |
| 126 | for (self.deps) |item| { | |
| 127 | const module_dep = item.module(exe); | |
| 128 | if (module_dep.root_source_file != null) { | |
| 129 | result.addImport(item.name, module_dep); | |
| 130 | } | |
| 131 | for (module_dep.include_dirs.items) |jtem| { | |
| 132 | switch (jtem) { | |
| 133 | .path => result.addIncludePath(jtem.path), | |
| 134 | .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {}, | |
| 135 | } | |
| 136 | } | |
| 137 | } | |
| 138 | for (self.c_include_dirs) |item| { | |
| 139 | result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }); | |
| 140 | dummy_library.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }); | |
| 141 | link_lib_c = true; | |
| 142 | } | |
| 143 | for (self.c_source_files) |item| { | |
| 144 | dummy_library.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags }); | |
| 145 | } | |
| 146 | for (self.system_libs) |item| { | |
| 147 | dummy_library.linkSystemLibrary(item); | |
| 151 | 148 | } |
| 152 | const result = ModuleDependency{ | |
| 153 | .name = self.name, | |
| 154 | .module = b.createModule(.{ | |
| 155 | .source_file = .{ .path = self.entry.? }, | |
| 156 | .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"), | |
| 157 | }), | |
| 158 | }; | |
| 159 | self.module = result; | |
| 149 | for (self.frameworks) |item| { | |
| 150 | dummy_library.linkFramework(item); | |
| 151 | } | |
| 152 | if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) { | |
| 153 | dummy_library.linkLibC(); | |
| 154 | exe.root_module.linkLibrary(dummy_library); | |
| 155 | link_lib_c = true; | |
| 156 | } | |
| 157 | if (link_lib_c) { | |
| 158 | result.link_libc = true; | |
| 159 | } | |
| 160 | self.module_memo = result; | |
| 160 | 161 | return result; |
| 161 | 162 | } |
| 162 | 163 | }; |
| 163 | 164 | |
| 164 | fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void { | |
| 165 | const min = std.SemanticVersion.parse("0.11.0") catch return; | |
| 165 | fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void { | |
| 166 | const min = std.SemanticVersion.parse("0.12.0") catch return; | |
| 166 | 167 | if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min})); |
| 167 | 168 | } |
| 168 | 169 | |
| 169 | 170 | pub const package_data = struct { |
| 170 | 171 | pub var _o6ogpor87xc2 = Package{ |
| 171 | .store = "/git/github.com/marlersoft/zigwin32/6777f1db221d0cb50322842f558f03e3c3a4099f", | |
| 172 | .store = "/git/github.com/marlersoft/zigwin32/c778640d3dc153e900fbe37e2816b5176af3c802", | |
| 172 | 173 | .name = "win32", |
| 173 | .entry = "/git/github.com/marlersoft/zigwin32/6777f1db221d0cb50322842f558f03e3c3a4099f/win32.zig", | |
| 174 | .entry = "/git/github.com/marlersoft/zigwin32/c778640d3dc153e900fbe37e2816b5176af3c802/win32.zig", | |
| 174 | 175 | }; |
| 175 | 176 | pub var _u7sysdckdymi = Package{ |
| 176 | .store = "/git/github.com/nektro/arqv-ini/ddbe89bb0d9085e939bcbc713caeb2b7cf852bae", | |
| 177 | .store = "/git/github.com/nektro/arqv-ini/38a018ad3a19d5b4663a5364d2d31271f250846b", | |
| 177 | 178 | .name = "ini", |
| 178 | .entry = "/git/github.com/nektro/arqv-ini/ddbe89bb0d9085e939bcbc713caeb2b7cf852bae/src/ini.zig", | |
| 179 | .entry = "/git/github.com/nektro/arqv-ini/38a018ad3a19d5b4663a5364d2d31271f250846b/src/ini.zig", | |
| 179 | 180 | }; |
| 180 | 181 | pub var _csbnipaad8n7 = Package{ |
| 181 | .store = "/git/github.com/nektro/iguanaTLS/f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40", | |
| 182 | .store = "/git/github.com/nektro/iguanaTLS/4dc8850883b49e4a452871298788b06b1af9fe24", | |
| 182 | 183 | .name = "iguanaTLS", |
| 183 | .entry = "/git/github.com/nektro/iguanaTLS/f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40/src/main.zig", | |
| 184 | .entry = "/git/github.com/nektro/iguanaTLS/4dc8850883b49e4a452871298788b06b1af9fe24/src/main.zig", | |
| 184 | 185 | }; |
| 185 | 186 | pub var _s84v9o48ucb0 = Package{ |
| 186 | .store = "/git/github.com/nektro/zig-ansi/ac607e4e7ac36d46cc67c8786262578330543a36", | |
| 187 | .store = "/git/github.com/nektro/zig-ansi/c3e439f86b0484e4428f38c4d8b07b7b5ae1634b", | |
| 187 | 188 | .name = "ansi", |
| 188 | .entry = "/git/github.com/nektro/zig-ansi/ac607e4e7ac36d46cc67c8786262578330543a36/src/lib.zig", | |
| 189 | .entry = "/git/github.com/nektro/zig-ansi/c3e439f86b0484e4428f38c4d8b07b7b5ae1634b/src/lib.zig", | |
| 189 | 190 | }; |
| 190 | 191 | pub var _f7dubzb7cyqe = Package{ |
| 191 | .store = "/git/github.com/nektro/zig-extras/05f0e90a185cb04a09b96f686dffc6375c420e9b", | |
| 192 | .store = "/git/github.com/nektro/zig-extras/74f0ddb0a4dfa7921739b88cc381951a6b6e73ce", | |
| 192 | 193 | .name = "extras", |
| 193 | .entry = "/git/github.com/nektro/zig-extras/05f0e90a185cb04a09b96f686dffc6375c420e9b/src/lib.zig", | |
| 194 | .entry = "/git/github.com/nektro/zig-extras/74f0ddb0a4dfa7921739b88cc381951a6b6e73ce/src/lib.zig", | |
| 194 | 195 | }; |
| 195 | 196 | pub var _0npcrzfdlrvk = Package{ |
| 196 | .store = "/git/github.com/nektro/zig-licenses/c9b8cbf3565675a056ad4e9b57cb4f84020e7680", | |
| 197 | .store = "/git/github.com/nektro/zig-licenses/f46d9f774df929885eef66c733a1e2a46bf16aec", | |
| 197 | 198 | .name = "licenses", |
| 198 | .entry = "/git/github.com/nektro/zig-licenses/c9b8cbf3565675a056ad4e9b57cb4f84020e7680/src/lib.zig", | |
| 199 | .entry = "/git/github.com/nektro/zig-licenses/f46d9f774df929885eef66c733a1e2a46bf16aec/src/lib.zig", | |
| 199 | 200 | }; |
| 200 | 201 | pub var _pt88y5d80m25 = Package{ |
| 201 | .store = "/git/github.com/nektro/zig-licenses-text/3c07c6e4eb0965dafd0b029c632f823631b3169c", | |
| 202 | .store = "/git/github.com/nektro/zig-licenses-text/b01e5a2dffcc564bddd8f514fe64bab9b5c52572", | |
| 202 | 203 | .name = "licenses-text", |
| 203 | .entry = "/git/github.com/nektro/zig-licenses-text/3c07c6e4eb0965dafd0b029c632f823631b3169c/src/lib.zig", | |
| 204 | .entry = "/git/github.com/nektro/zig-licenses-text/b01e5a2dffcc564bddd8f514fe64bab9b5c52572/src/lib.zig", | |
| 204 | 205 | }; |
| 205 | 206 | pub var _tnj3qf44tpeq = Package{ |
| 206 | 207 | .store = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992", |
| ... | ... | @@ -208,15 +209,15 @@ pub const package_data = struct { |
| 208 | 209 | .entry = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992/src/lib.zig", |
| 209 | 210 | }; |
| 210 | 211 | pub var _c1xirp1ota5p = Package{ |
| 211 | .store = "/git/github.com/nektro/zig-inquirer/5cc2a5565d04fe2c0085f0d6818590e800d9dcf7", | |
| 212 | .store = "/git/github.com/nektro/zig-inquirer/9e1d873db79e9ffa6ae6e06bd372428c9be85d97", | |
| 212 | 213 | .name = "inquirer", |
| 213 | .entry = "/git/github.com/nektro/zig-inquirer/5cc2a5565d04fe2c0085f0d6818590e800d9dcf7/src/lib.zig", | |
| 214 | .entry = "/git/github.com/nektro/zig-inquirer/9e1d873db79e9ffa6ae6e06bd372428c9be85d97/src/lib.zig", | |
| 214 | 215 | .deps = &[_]*Package{ &_s84v9o48ucb0, &_tnj3qf44tpeq }, |
| 215 | 216 | }; |
| 216 | 217 | pub var _96h80ezrvj7i = Package{ |
| 217 | .store = "/git/github.com/nektro/zig-leven/550cabd5a18ace5e67761bc5b867c10e926f4314", | |
| 218 | .store = "/git/github.com/nektro/zig-leven/e548b0bcc7b6f34f636c0b6b905928d31254c54d", | |
| 218 | 219 | .name = "leven", |
| 219 | .entry = "/git/github.com/nektro/zig-leven/550cabd5a18ace5e67761bc5b867c10e926f4314/src/lib.zig", | |
| 220 | .entry = "/git/github.com/nektro/zig-leven/e548b0bcc7b6f34f636c0b6b905928d31254c54d/src/lib.zig", | |
| 220 | 221 | .deps = &[_]*Package{ &_tnj3qf44tpeq }, |
| 221 | 222 | }; |
| 222 | 223 | pub var _2ovav391ivak = Package{ |
| ... | ... | @@ -226,32 +227,32 @@ pub const package_data = struct { |
| 226 | 227 | .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i }, |
| 227 | 228 | }; |
| 228 | 229 | pub var _iecwp4b3bsfm = Package{ |
| 229 | .store = "/git/github.com/nektro/zig-time/12fad367a5282827aad7e12f0e9cd36f672c4010", | |
| 230 | .store = "/git/github.com/nektro/zig-time/ba546bbf2e8438c9b2325f36f392c9d95b432e8e", | |
| 230 | 231 | .name = "time", |
| 231 | .entry = "/git/github.com/nektro/zig-time/12fad367a5282827aad7e12f0e9cd36f672c4010/time.zig", | |
| 232 | .entry = "/git/github.com/nektro/zig-time/ba546bbf2e8438c9b2325f36f392c9d95b432e8e/time.zig", | |
| 232 | 233 | .deps = &[_]*Package{ &_f7dubzb7cyqe }, |
| 233 | 234 | }; |
| 234 | 235 | pub var _g982zq6e8wsv = Package{ |
| 235 | 236 | .store = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b", |
| 236 | 237 | .name = "yaml", |
| 237 | 238 | .entry = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b/yaml.zig", |
| 238 | .deps = &[_]*Package{ &_f7dubzb7cyqe }, | |
| 239 | .deps = &[_]*Package{ &_8mdbh0zuneb0, &_f7dubzb7cyqe }, | |
| 239 | 240 | }; |
| 240 | 241 | pub var _9k24gimke1an = Package{ |
| 241 | .store = "/git/github.com/truemedian/hzzp/92e6072d8a385d8b08fdcae3ae2021fe5293528f", | |
| 242 | .store = "/git/github.com/truemedian/hzzp/a7f03a1e652abe8c89b376d090cec50acb0d2a1a", | |
| 242 | 243 | .name = "hzzp", |
| 243 | .entry = "/git/github.com/truemedian/hzzp/92e6072d8a385d8b08fdcae3ae2021fe5293528f/src/main.zig", | |
| 244 | .entry = "/git/github.com/truemedian/hzzp/a7f03a1e652abe8c89b376d090cec50acb0d2a1a/src/main.zig", | |
| 244 | 245 | }; |
| 245 | 246 | pub var _ejw82j2ipa0e = Package{ |
| 246 | .store = "/git/github.com/nektro/zfetch/f51277414a2309f776fb79f3d55f26e37f9a54da", | |
| 247 | .store = "/git/github.com/nektro/zfetch/863be236188e5f24d16554f9dcd7df96dd254a13", | |
| 247 | 248 | .name = "zfetch", |
| 248 | .entry = "/git/github.com/nektro/zfetch/f51277414a2309f776fb79f3d55f26e37f9a54da/src/main.zig", | |
| 249 | .entry = "/git/github.com/nektro/zfetch/863be236188e5f24d16554f9dcd7df96dd254a13/src/main.zig", | |
| 249 | 250 | .deps = &[_]*Package{ &_9k24gimke1an, &_csbnipaad8n7 }, |
| 250 | 251 | }; |
| 251 | 252 | pub var _2ta738wrqbaq = Package{ |
| 252 | .store = "/git/github.com/ziglibs/known-folders/855473062efac722624737f1adc56f9c0dd92017", | |
| 253 | .store = "/git/github.com/ziglibs/known-folders/0ad514dcfb7525e32ae349b9acc0a53976f3a9fa", | |
| 253 | 254 | .name = "known-folders", |
| 254 | .entry = "/git/github.com/ziglibs/known-folders/855473062efac722624737f1adc56f9c0dd92017/known-folders.zig", | |
| 255 | .entry = "/git/github.com/ziglibs/known-folders/0ad514dcfb7525e32ae349b9acc0a53976f3a9fa/known-folders.zig", | |
| 255 | 256 | }; |
| 256 | 257 | pub var _89ujp8gq842x = Package{ |
| 257 | 258 | .name = "zigmod", |
docs/README.md+1-1| ... | ... | @@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed. |
| 10 | 10 | |
| 11 | 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.11.0`. | |
| 13 | The earliest Zig release this Zigmod was verified to work with is `0.12.0`. | |
| 14 | 14 | |
| 15 | 15 | ## Download |
| 16 | 16 | You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source. |
docs/deps.zig.md+1-6| ... | ... | @@ -15,10 +15,6 @@ A helper function to automatically pull in dependencies, purely from the `zig bu |
| 15 | 15 | - Type: `pub fn (exe: *std.build.LibExeObjStep) void` |
| 16 | 16 | A helper function to add all of the packages, C files, and system libraries to the passed exectuable. It will also automatically link libC in the event that any C files are found in the dependency tree. |
| 17 | 17 | |
| 18 | ### `addAllLibrariesTo` | |
| 19 | - Type: `pub fn (exe: *std.build.LibExeObjStep) void` | |
| 20 | A helper function called by `addAllTo` that adds the C files and libraries. | |
| 21 | ||
| 22 | 18 | ### `Package` |
| 23 | 19 | ```zig |
| 24 | 20 | pub const Package = struct { |
| ... | ... | @@ -29,7 +25,6 @@ pub const Package = struct { |
| 29 | 25 | c_source_flags: []const string = &.{}, |
| 30 | 26 | system_libs: []const string = &.{}, |
| 31 | 27 | frameworks: []const string = &.{}, |
| 32 | vcpkg: bool = false, | |
| 33 | 28 | }; |
| 34 | 29 | ``` |
| 35 | 30 | |
| ... | ... | @@ -43,7 +38,7 @@ This is a an array of all of the items in `package_data`, but only contains the |
| 43 | 38 | |
| 44 | 39 | ### `pkgs` |
| 45 | 40 | - Type: `struct<NAME, Package>` |
| 46 | This is a struct that associates the package name to the relavant `Package`. The only packages listed are the dependencies of the root project. | |
| 41 | This is a struct that associates the package name to the relavant `Package`. The only packages listed are the dependencies of the root project. | |
| 47 | 42 | |
| 48 | 43 | ### `imports` |
| 49 | 44 | - Type: `struct<NAME, @import(main)>` |
docs/zig.mod.md-10| ... | ... | @@ -58,11 +58,6 @@ Similar to `dependencies` but will only get added to the project if the current |
| 58 | 58 | - Type: `string` |
| 59 | 59 | Parsed as a `std.SemanticVersion`, this attribute refers to the minimum compatible Zig version for this package/application and will cause `zig build` to panic if violated. |
| 60 | 60 | |
| 61 | #### `vcpkg` | |
| 62 | - Type: `bool` | |
| 63 | - Example: `true`|any | |
| 64 | This attribute is a flag to call `try exe.addVcpkgPaths(.static);` when on Windows. Likely used in conjunction with adding system libraries/C code. `true` is the only value that will enable this flag. | |
| 65 | ||
| 66 | 61 | ---- |
| 67 | 62 | |
| 68 | 63 | ### Dep Object |
| ... | ... | @@ -124,10 +119,5 @@ This attribute specifies a way to filter when the dependency will be generated i |
| 124 | 119 | - Example: `true`|any |
| 125 | 120 | This attribute is a manual override for having an external repo that contains no Zig or C code but other files be managed through Zigmod and `deps.zig`. `true` is the only value that will enable this flag. |
| 126 | 121 | |
| 127 | #### Dep `vcpkg` | |
| 128 | - Type: `string` | |
| 129 | - Example: `true`|any | |
| 130 | This attribute is a flag to call `try exe.addVcpkgPaths(.static);` when on Windows. Likely used in conjunction with adding system libraries/C code. `true` is the only value that will enable this flag. | |
| 131 | ||
| 132 | 122 | #### Dep Overrides |
| 133 | 123 | There are a number of fields you can add to a `Dep` object that will override it's top-level value. This is most useful in the case where a project you want to use does not have a `zigmod.yml` manifest. You can then use overrides to define the values for them. The only top-level value you can not override is `dependencies`. |
src/cmd/fetch.zig+73-77| ... | ... | @@ -52,94 +52,89 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 52 | 52 | try w.writeAll("const std = @import(\"std\");\n"); |
| 53 | 53 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| 54 | 54 | try w.writeAll("const string = []const u8;\n"); |
| 55 | try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n"); | |
| 56 | 55 | try w.writeAll("\n"); |
| 57 | 56 | try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)}); |
| 58 | 57 | try w.writeAll("\n"); |
| 59 | 58 | try w.writeAll( |
| 60 | \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void { | |
| 59 | \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { | |
| 61 | 60 | \\ checkMinZig(builtin.zig_version, exe); |
| 62 | \\ const b = exe.step.owner; | |
| 63 | 61 | \\ @setEvalBranchQuota(1_000_000); |
| 64 | 62 | \\ for (packages) |pkg| { |
| 65 | \\ const moddep = pkg.zp(b); | |
| 66 | \\ exe.addModule(moddep.name, moddep.module); | |
| 63 | \\ const module = pkg.module(exe); | |
| 64 | \\ exe.root_module.addImport(pkg.import.?[0], module); | |
| 67 | 65 | \\ } |
| 68 | \\ addAllLibrariesTo(exe); | |
| 69 | \\} | |
| 70 | \\ | |
| 71 | \\pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void { | |
| 72 | \\ const b = exe.step.owner; | |
| 73 | \\ var llc = false; | |
| 74 | \\ var vcpkg = false; | |
| 75 | \\ inline for (comptime std.meta.declarations(package_data)) |decl| { | |
| 76 | \\ const pkg = @as(Package, @field(package_data, decl.name)); | |
| 77 | \\ for (pkg.system_libs) |item| { | |
| 78 | \\ exe.linkSystemLibrary(item); | |
| 79 | \\ llc = true; | |
| 80 | \\ } | |
| 81 | \\ for (pkg.frameworks) |item| { | |
| 82 | \\ if (!builtin.target.isDarwin()) @panic(b.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item})); | |
| 83 | \\ exe.linkFramework(item); | |
| 84 | \\ llc = true; | |
| 85 | \\ } | |
| 86 | \\ for (pkg.c_include_dirs) |item| { | |
| 87 | \\ exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ @field(dirs, decl.name), item })}); | |
| 88 | \\ llc = true; | |
| 89 | \\ } | |
| 90 | \\ for (pkg.c_source_files) |item| { | |
| 91 | \\ exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ @field(dirs, decl.name), item }) }, .flags = pkg.c_source_flags }); | |
| 92 | \\ llc = true; | |
| 93 | \\ } | |
| 94 | \\ vcpkg = vcpkg or pkg.vcpkg; | |
| 95 | \\ } | |
| 96 | \\ if (llc) exe.linkLibC(); | |
| 97 | \\ if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err)); | |
| 98 | 66 | \\} |
| 99 | 67 | \\ |
| 68 | \\var link_lib_c = false; | |
| 100 | 69 | \\pub const Package = struct { |
| 101 | 70 | \\ directory: string, |
| 102 | \\ pkg: ?Pkg = null, | |
| 71 | \\ import: ?struct { string, std.Build.LazyPath } = null, | |
| 72 | \\ dependencies: []const *Package, | |
| 103 | 73 | \\ c_include_dirs: []const string = &.{}, |
| 104 | 74 | \\ c_source_files: []const string = &.{}, |
| 105 | 75 | \\ c_source_flags: []const string = &.{}, |
| 106 | 76 | \\ system_libs: []const string = &.{}, |
| 107 | 77 | \\ frameworks: []const string = &.{}, |
| 108 | \\ vcpkg: bool = false, | |
| 109 | \\ module: ?ModuleDependency = null, | |
| 78 | \\ module_memo: ?*std.Build.Module = null, | |
| 110 | 79 | \\ |
| 111 | \\ pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency { | |
| 112 | \\ var temp: [100]ModuleDependency = undefined; | |
| 113 | \\ const pkg = self.pkg.?; | |
| 114 | \\ for (pkg.dependencies, 0..) |item, i| { | |
| 115 | \\ temp[i] = item.zp(b); | |
| 80 | \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module { | |
| 81 | \\ if (self.module_memo) |cached| { | |
| 82 | \\ return cached; | |
| 83 | \\ } | |
| 84 | \\ const b = exe.step.owner; | |
| 85 | \\ const result = b.createModule(.{}); | |
| 86 | \\ const dummy_library = b.addStaticLibrary(.{ | |
| 87 | \\ .name = "dummy", | |
| 88 | \\ .target = exe.root_module.resolved_target orelse b.host, | |
| 89 | \\ .optimize = exe.root_module.optimize.?, | |
| 90 | \\ }); | |
| 91 | \\ if (self.import) |capture| { | |
| 92 | \\ result.root_source_file = capture[1]; | |
| 93 | \\ } | |
| 94 | \\ for (self.dependencies) |item| { | |
| 95 | \\ const module_dep = item.module(exe); | |
| 96 | \\ if (module_dep.root_source_file != null) { | |
| 97 | \\ result.addImport(item.import.?[0], module_dep); | |
| 98 | \\ } | |
| 99 | \\ for (module_dep.include_dirs.items) |jtem| { | |
| 100 | \\ switch (jtem) { | |
| 101 | \\ .path => result.addIncludePath(jtem.path), | |
| 102 | \\ .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {}, | |
| 103 | \\ } | |
| 104 | \\ } | |
| 105 | \\ } | |
| 106 | \\ for (self.c_include_dirs) |item| { | |
| 107 | \\ result.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item }))); | |
| 108 | \\ dummy_library.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item }))); | |
| 109 | \\ link_lib_c = true; | |
| 110 | \\ } | |
| 111 | \\ for (self.c_source_files) |item| { | |
| 112 | \\ dummy_library.addCSourceFile(.{ .file = b.path(b.fmt("{s}/{s}", .{ self.directory, item })), .flags = self.c_source_flags }); | |
| 116 | 113 | \\ } |
| 117 | \\ if (self.module) |mod| { | |
| 118 | \\ return mod; | |
| 114 | \\ for (self.system_libs) |item| { | |
| 115 | \\ dummy_library.linkSystemLibrary(item); | |
| 119 | 116 | \\ } |
| 120 | \\ const result = ModuleDependency{ | |
| 121 | \\ .name = pkg.name, | |
| 122 | \\ .module = b.createModule(.{ | |
| 123 | \\ .source_file = pkg.source, | |
| 124 | \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..pkg.dependencies.len]) catch @panic("oom"), | |
| 125 | \\ }), | |
| 126 | \\ }; | |
| 127 | \\ self.module = result; | |
| 117 | \\ for (self.frameworks) |item| { | |
| 118 | \\ dummy_library.linkFramework(item); | |
| 119 | \\ } | |
| 120 | \\ if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) { | |
| 121 | \\ dummy_library.linkLibC(); | |
| 122 | \\ exe.root_module.linkLibrary(dummy_library); | |
| 123 | \\ link_lib_c = true; | |
| 124 | \\ } | |
| 125 | \\ if (link_lib_c) { | |
| 126 | \\ result.link_libc = true; | |
| 127 | \\ } | |
| 128 | \\ self.module_memo = result; | |
| 128 | 129 | \\ return result; |
| 129 | 130 | \\ } |
| 130 | 131 | \\}; |
| 131 | 132 | \\ |
| 132 | \\pub const Pkg = struct { | |
| 133 | \\ name: string, | |
| 134 | \\ source: std.build.FileSource, | |
| 135 | \\ dependencies: []const *Package, | |
| 136 | \\}; | |
| 137 | \\ | |
| 138 | 133 | \\ |
| 139 | 134 | ); |
| 140 | 135 | |
| 141 | 136 | try w.print( |
| 142 | \\fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {{ | |
| 137 | \\fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {{ | |
| 143 | 138 | \\ const min = std.SemanticVersion.parse("{?}") catch return; |
| 144 | 139 | \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}})); |
| 145 | 140 | \\}} |
| ... | ... | @@ -148,7 +143,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 148 | 143 | , .{top_module.minZigVersion()}); |
| 149 | 144 | |
| 150 | 145 | try w.writeAll("pub const dirs = struct {\n"); |
| 151 | try print_dirs(w, list.items); | |
| 146 | try print_dirs(w, list.items, alloc); | |
| 152 | 147 | try w.writeAll("};\n\n"); |
| 153 | 148 | |
| 154 | 149 | try w.writeAll("pub const package_data = struct {\n"); |
| ... | ... | @@ -215,7 +210,7 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void { |
| 215 | 210 | while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| { |
| 216 | 211 | if (line[0] == ' ') continue; |
| 217 | 212 | if (line[0] == '-') try rems.append(line[1..]); |
| 218 | if (line[0] == '+') if (line[1] == '2') continue else try adds.append(line[1..]); | |
| 213 | if (line[0] == '+') if (line[1] == '2') break else try adds.append(line[1..]); | |
| 219 | 214 | } |
| 220 | 215 | |
| 221 | 216 | var changes = std.StringHashMap(DiffChange).init(alloc); |
| ... | ... | @@ -287,13 +282,18 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item: |
| 287 | 282 | return false; |
| 288 | 283 | } |
| 289 | 284 | |
| 290 | fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void { | |
| 285 | fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module, alloc: std.mem.Allocator) !void { | |
| 291 | 286 | for (list) |mod| { |
| 292 | 287 | if (mod.type == .system_lib or mod.type == .framework) continue; |
| 293 | 288 | if (std.mem.eql(u8, mod.id, "root")) { |
| 294 | 289 | try w.writeAll(" pub const _root = \"\";\n"); |
| 295 | 290 | continue; |
| 296 | 291 | } |
| 292 | if (std.mem.eql(u8, mod.clean_path, "../..")) { | |
| 293 | const cwd_realpath = try std.fs.cwd().realpathAlloc(alloc, "."); | |
| 294 | try w.print(" pub const _{s} = \"{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(cwd_realpath) }); | |
| 295 | continue; | |
| 296 | } | |
| 297 | 297 | try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) }); |
| 298 | 298 | } |
| 299 | 299 | } |
| ... | ... | @@ -327,23 +327,22 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 327 | 327 | }); |
| 328 | 328 | if (mod.main.len > 0 and !std.mem.eql(u8, mod.id, "root")) { |
| 329 | 329 | try w.print( |
| 330 | \\ .pkg = Pkg{{ .name = "{s}", .source = .{{ .path = dirs._{s} ++ "/{s}" }}, .dependencies = | |
| 330 | \\ .import = .{{ "{s}", .{{ .path = dirs._{s} ++ "/{s}" }} }}, | |
| 331 | \\ | |
| 331 | 332 | , .{ |
| 332 | 333 | mod.name, |
| 333 | 334 | mod.short_id(), |
| 334 | 335 | mod.main, |
| 335 | 336 | }); |
| 336 | if (mod.has_no_zig_deps()) { | |
| 337 | try w.writeAll(" &.{} },\n"); | |
| 338 | } else { | |
| 339 | try w.writeAll(" &.{"); | |
| 340 | for (mod.deps, 0..) |moddep, j| { | |
| 341 | if (moddep.main.len == 0) continue; | |
| 342 | try w.print(" &_{s}", .{moddep.id[0..12]}); | |
| 343 | if (j != mod.deps.len - 1) try w.writeAll(","); | |
| 344 | } | |
| 345 | try w.writeAll(" } },\n"); | |
| 337 | } | |
| 338 | { | |
| 339 | try w.writeAll(" .dependencies ="); | |
| 340 | try w.writeAll(" &.{"); | |
| 341 | for (mod.deps, 0..) |moddep, j| { | |
| 342 | try w.print(" &_{s}", .{moddep.id[0..12]}); | |
| 343 | if (j != mod.deps.len - 1) try w.writeAll(","); | |
| 346 | 344 | } |
| 345 | try w.writeAll(" },\n"); | |
| 347 | 346 | } |
| 348 | 347 | if (mod.c_include_dirs.len > 0) { |
| 349 | 348 | try w.writeAll(" .c_include_dirs = &.{"); |
| ... | ... | @@ -387,9 +386,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 387 | 386 | } |
| 388 | 387 | try w.writeAll(" },\n"); |
| 389 | 388 | } |
| 390 | if (mod.vcpkg) { | |
| 391 | try w.writeAll(" .vcpkg = true,\n"); | |
| 392 | } | |
| 393 | 389 | try w.writeAll(" };\n"); |
| 394 | 390 | |
| 395 | 391 | try done.append(mod); |
src/cmd/generate.zig+67-70| ... | ... | @@ -41,20 +41,19 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 41 | 41 | try w.writeAll("// zig fmt: off\n"); |
| 42 | 42 | try w.writeAll("const std = @import(\"std\");\n"); |
| 43 | 43 | try w.writeAll("const builtin = @import(\"builtin\");\n"); |
| 44 | try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n"); | |
| 45 | 44 | try w.writeAll("const string = []const u8;\n"); |
| 46 | 45 | try w.writeAll("\n"); |
| 47 | 46 | try w.writeAll( |
| 48 | 47 | \\pub const GitExactStep = struct { |
| 49 | \\ step: std.build.Step, | |
| 50 | \\ builder: *std.build.Builder, | |
| 48 | \\ step: std.Build.Step, | |
| 49 | \\ builder: *std.Build, | |
| 51 | 50 | \\ url: string, |
| 52 | 51 | \\ commit: string, |
| 53 | 52 | \\ |
| 54 | \\ pub fn create(b: *std.build.Builder, url: string, commit: string) *GitExactStep { | |
| 53 | \\ pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep { | |
| 55 | 54 | \\ var result = b.allocator.create(GitExactStep) catch @panic("memory"); |
| 56 | 55 | \\ result.* = GitExactStep{ |
| 57 | \\ .step = std.build.Step.init(.{ | |
| 56 | \\ .step = std.Build.Step.init(.{ | |
| 58 | 57 | \\ .id = .custom, |
| 59 | 58 | \\ .name = b.fmt("git clone {s} @ {s}", .{ url, commit }), |
| 60 | 59 | \\ .owner = b, |
| ... | ... | @@ -71,11 +70,11 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 71 | 70 | \\ const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit }); |
| 72 | 71 | \\ flip(std.fs.cwd().access(repopath, .{})) catch return result; |
| 73 | 72 | \\ |
| 74 | \\ var clonestep = std.build.RunStep.create(b, "clone"); | |
| 73 | \\ var clonestep = std.Build.Step.Run.create(b, "clone"); | |
| 75 | 74 | \\ clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath }); |
| 76 | 75 | \\ result.step.dependOn(&clonestep.step); |
| 77 | 76 | \\ |
| 78 | \\ var checkoutstep = std.build.RunStep.create(b, "checkout"); | |
| 77 | \\ var checkoutstep = std.Build.Step.Run.create(b, "checkout"); | |
| 79 | 78 | \\ checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit }); |
| 80 | 79 | \\ result.step.dependOn(&checkoutstep.step); |
| 81 | 80 | \\ checkoutstep.step.dependOn(&clonestep.step); |
| ... | ... | @@ -85,18 +84,18 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 85 | 84 | \\ return result; |
| 86 | 85 | \\ } |
| 87 | 86 | \\ |
| 88 | \\ fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void { | |
| 87 | \\ fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void { | |
| 89 | 88 | \\ _ = step; |
| 90 | 89 | \\ _ = prog_node; |
| 91 | 90 | \\ } |
| 92 | 91 | \\}; |
| 93 | 92 | \\ |
| 94 | \\pub fn fetch(exe: *std.build.LibExeObjStep) void { | |
| 93 | \\pub fn fetch(exe: *std.Build.Step.Compile) void { | |
| 95 | 94 | \\ const b = exe.step.owner; |
| 96 | 95 | \\ inline for (comptime std.meta.declarations(package_data)) |decl| { |
| 97 | \\ const path = &@field(package_data, decl.name).entry; | |
| 98 | \\ const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else "."; | |
| 99 | \\ if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? }); | |
| 96 | \\ const path = &@field(package_data, decl.name).entry; | |
| 97 | \\ const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else "."; | |
| 98 | \\ if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? }); | |
| 100 | 99 | \\ } |
| 101 | 100 | \\ |
| 102 | 101 | ); |
| ... | ... | @@ -125,48 +124,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 125 | 124 | \\ return error.ExpectedError; |
| 126 | 125 | \\} |
| 127 | 126 | \\ |
| 128 | \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void { | |
| 127 | \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { | |
| 129 | 128 | \\ checkMinZig(builtin.zig_version, exe); |
| 130 | 129 | \\ fetch(exe); |
| 131 | \\ const b = exe.step.owner; | |
| 132 | 130 | \\ @setEvalBranchQuota(1_000_000); |
| 133 | 131 | \\ for (packages) |pkg| { |
| 134 | \\ const moddep = pkg.zp(b); | |
| 135 | \\ exe.addModule(moddep.name, moddep.module); | |
| 136 | \\ } | |
| 137 | \\ addAllLibrariesTo(exe); | |
| 138 | \\} | |
| 139 | \\ | |
| 140 | \\pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void { | |
| 141 | \\ const b = exe.step.owner; | |
| 142 | \\ var llc = false; | |
| 143 | \\ var vcpkg = false; | |
| 144 | \\ inline for (comptime std.meta.declarations(package_data)) |decl| { | |
| 145 | \\ const pkg = @as(Package, @field(package_data, decl.name)); | |
| 146 | \\ const root = if (pkg.store) |st| b.fmt("{s}/zigmod/deps/{s}", .{ b.cache_root.path.?, st }) else "."; | |
| 147 | \\ for (pkg.system_libs) |item| { | |
| 148 | \\ exe.linkSystemLibrary(item); | |
| 149 | \\ llc = true; | |
| 150 | \\ } | |
| 151 | \\ for (pkg.frameworks) |item| { | |
| 152 | \\ if (!builtin.target.isDarwin()) @panic(exe.step.owner.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item})); | |
| 153 | \\ exe.linkFramework(item); | |
| 154 | \\ llc = true; | |
| 155 | \\ } | |
| 156 | \\ for (pkg.c_include_dirs) |item| { | |
| 157 | \\ exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ root, item })}); | |
| 158 | \\ llc = true; | |
| 159 | \\ } | |
| 160 | \\ for (pkg.c_source_files) |item| { | |
| 161 | \\ exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ root, item }) }, .flags = pkg.c_source_flags }); | |
| 162 | \\ llc = true; | |
| 163 | \\ } | |
| 164 | \\ vcpkg = vcpkg or pkg.vcpkg; | |
| 132 | \\ const module = pkg.module(exe); | |
| 133 | \\ exe.root_module.addImport(pkg.name, module); | |
| 165 | 134 | \\ } |
| 166 | \\ if (llc) exe.linkLibC(); | |
| 167 | \\ if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err)); | |
| 168 | 135 | \\} |
| 169 | 136 | \\ |
| 137 | \\var link_lib_c = false; | |
| 170 | 138 | \\pub const Package = struct { |
| 171 | 139 | \\ name: string = "", |
| 172 | 140 | \\ entry: ?string = null, |
| ... | ... | @@ -177,25 +145,58 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 177 | 145 | \\ c_source_flags: []const string = &.{}, |
| 178 | 146 | \\ system_libs: []const string = &.{}, |
| 179 | 147 | \\ frameworks: []const string = &.{}, |
| 180 | \\ vcpkg: bool = false, | |
| 181 | \\ module: ?ModuleDependency = null, | |
| 148 | \\ module_memo: ?*std.Build.Module = null, | |
| 182 | 149 | \\ |
| 183 | \\ pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency { | |
| 184 | \\ var temp: [100]ModuleDependency = undefined; | |
| 185 | \\ for (self.deps, 0..) |item, i| { | |
| 186 | \\ temp[i] = item.zp(b); | |
| 150 | \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module { | |
| 151 | \\ if (self.module_memo) |cached| { | |
| 152 | \\ return cached; | |
| 187 | 153 | \\ } |
| 188 | \\ if (self.module) |mod| { | |
| 189 | \\ return mod; | |
| 154 | \\ const b = exe.step.owner; | |
| 155 | \\ | |
| 156 | \\ const result = b.createModule(.{}); | |
| 157 | \\ const dummy_library = b.addStaticLibrary(.{ | |
| 158 | \\ .name = "dummy", | |
| 159 | \\ .target = exe.root_module.resolved_target orelse b.host, | |
| 160 | \\ .optimize = exe.root_module.optimize.?, | |
| 161 | \\ }); | |
| 162 | \\ if (self.entry) |capture| { | |
| 163 | \\ result.root_source_file = .{ .path = capture }; | |
| 164 | \\ } | |
| 165 | \\ for (self.deps) |item| { | |
| 166 | \\ const module_dep = item.module(exe); | |
| 167 | \\ if (module_dep.root_source_file != null) { | |
| 168 | \\ result.addImport(item.name, module_dep); | |
| 169 | \\ } | |
| 170 | \\ for (module_dep.include_dirs.items) |jtem| { | |
| 171 | \\ switch (jtem) { | |
| 172 | \\ .path => result.addIncludePath(jtem.path), | |
| 173 | \\ .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {}, | |
| 174 | \\ } | |
| 175 | \\ } | |
| 176 | \\ } | |
| 177 | \\ for (self.c_include_dirs) |item| { | |
| 178 | \\ result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }); | |
| 179 | \\ dummy_library.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }); | |
| 180 | \\ link_lib_c = true; | |
| 181 | \\ } | |
| 182 | \\ for (self.c_source_files) |item| { | |
| 183 | \\ dummy_library.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags }); | |
| 184 | \\ } | |
| 185 | \\ for (self.system_libs) |item| { | |
| 186 | \\ dummy_library.linkSystemLibrary(item); | |
| 190 | 187 | \\ } |
| 191 | \\ const result = ModuleDependency{ | |
| 192 | \\ .name = self.name, | |
| 193 | \\ .module = b.createModule(.{ | |
| 194 | \\ .source_file = .{ .path = self.entry.? }, | |
| 195 | \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"), | |
| 196 | \\ }), | |
| 197 | \\ }; | |
| 198 | \\ self.module = result; | |
| 188 | \\ for (self.frameworks) |item| { | |
| 189 | \\ dummy_library.linkFramework(item); | |
| 190 | \\ } | |
| 191 | \\ if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) { | |
| 192 | \\ dummy_library.linkLibC(); | |
| 193 | \\ exe.root_module.linkLibrary(dummy_library); | |
| 194 | \\ link_lib_c = true; | |
| 195 | \\ } | |
| 196 | \\ if (link_lib_c) { | |
| 197 | \\ result.link_libc = true; | |
| 198 | \\ } | |
| 199 | \\ self.module_memo = result; | |
| 199 | 200 | \\ return result; |
| 200 | 201 | \\ } |
| 201 | 202 | \\}; |
| ... | ... | @@ -204,7 +205,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D |
| 204 | 205 | ); |
| 205 | 206 | |
| 206 | 207 | try w.print( |
| 207 | \\fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {{ | |
| 208 | \\fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {{ | |
| 208 | 209 | \\ const min = std.SemanticVersion.parse("{?}") catch return; |
| 209 | 210 | \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}})); |
| 210 | 211 | \\}} |
| ... | ... | @@ -273,7 +274,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 273 | 274 | , .{ |
| 274 | 275 | mod.short_id(), |
| 275 | 276 | }); |
| 276 | var fixed_path = if (std.mem.startsWith(u8, mod.clean_path, "v/")) mod.clean_path[2..std.mem.lastIndexOfScalar(u8, mod.clean_path, '/').?] else mod.clean_path; | |
| 277 | const fixed_path = if (std.mem.startsWith(u8, mod.clean_path, "v/")) mod.clean_path[2..std.mem.lastIndexOfScalar(u8, mod.clean_path, '/').?] else mod.clean_path; | |
| 277 | 278 | switch (mod.type) { |
| 278 | 279 | .system_lib, .framework => {}, |
| 279 | 280 | .local => {}, |
| ... | ... | @@ -285,10 +286,9 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 285 | 286 | try w.print(" .name = \"{s}\",\n", .{mod.name}); |
| 286 | 287 | try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath), mod.main }); |
| 287 | 288 | |
| 288 | if (!mod.has_no_zig_deps()) { | |
| 289 | if (mod.deps.len != 0) { | |
| 289 | 290 | try w.writeAll(" .deps = &[_]*Package{"); |
| 290 | 291 | for (mod.deps, 0..) |moddep, j| { |
| 291 | if (moddep.main.len == 0) continue; | |
| 292 | 292 | try w.print(" &_{s}", .{moddep.id[0..12]}); |
| 293 | 293 | if (j != mod.deps.len - 1) try w.writeAll(","); |
| 294 | 294 | } |
| ... | ... | @@ -337,9 +337,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath: |
| 337 | 337 | } |
| 338 | 338 | try w.writeAll(" },\n"); |
| 339 | 339 | } |
| 340 | if (mod.vcpkg) { | |
| 341 | try w.writeAll(" .vcpkg = true,\n"); | |
| 342 | } | |
| 343 | 340 | try w.writeAll(" };\n"); |
| 344 | 341 | |
| 345 | 342 | try done.append(mod); |
src/common.zig+6-9| ... | ... | @@ -54,7 +54,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO |
| 54 | 54 | .yaml = m.yaml, |
| 55 | 55 | .dep = null, |
| 56 | 56 | .min_zig_version = m.min_zig_version, |
| 57 | .vcpkg = m.vcpkg, | |
| 58 | 57 | }; |
| 59 | 58 | } |
| 60 | 59 | |
| ... | ... | @@ -85,7 +84,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type, |
| 85 | 84 | .yaml = m.yaml, |
| 86 | 85 | .dep = null, |
| 87 | 86 | .min_zig_version = m.min_zig_version, |
| 88 | .vcpkg = m.vcpkg, | |
| 89 | 87 | }; |
| 90 | 88 | } |
| 91 | 89 | |
| ... | ... | @@ -153,7 +151,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 153 | 151 | defer pvd.close(); |
| 154 | 152 | try pvd.deleteTree(".git"); |
| 155 | 153 | } |
| 156 | var pvd = try std.fs.cwd().openIterableDir(pv, .{}); | |
| 154 | var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true }); | |
| 157 | 155 | defer pvd.close(); |
| 158 | 156 | try setTreeReadOnly(pvd, options.alloc); |
| 159 | 157 | return pv; |
| ... | ... | @@ -190,7 +188,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 190 | 188 | try d.type.pull(options.alloc, d.path, pv); |
| 191 | 189 | if (try u.validate_hash(options.alloc, d.version, file_path)) { |
| 192 | 190 | try std.fs.cwd().deleteFile(file_path); |
| 193 | var pvd = try std.fs.cwd().openIterableDir(pv, .{}); | |
| 191 | var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true }); | |
| 194 | 192 | defer pvd.close(); |
| 195 | 193 | try setTreeReadOnly(pvd, options.alloc); |
| 196 | 194 | return pv; |
| ... | ... | @@ -243,7 +241,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 243 | 241 | .dep = d.*, |
| 244 | 242 | .for_build = d.for_build, |
| 245 | 243 | .min_zig_version = null, |
| 246 | .vcpkg = false, | |
| 247 | 244 | }; |
| 248 | 245 | }, |
| 249 | 246 | else => { |
| ... | ... | @@ -297,7 +294,7 @@ pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: std. |
| 297 | 294 | defer map.deinit(); |
| 298 | 295 | |
| 299 | 296 | for (dirs) |dir_path| { |
| 300 | const dir = try mdir.openIterableDir(dir_path, .{}); | |
| 297 | const dir = try mdir.openDir(dir_path, .{ .iterate = true }); | |
| 301 | 298 | var walker = try dir.walk(alloc); |
| 302 | 299 | defer walker.deinit(); |
| 303 | 300 | while (try walker.next()) |p| { |
| ... | ... | @@ -377,13 +374,13 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 377 | 374 | return list.toOwnedSlice(); |
| 378 | 375 | } |
| 379 | 376 | |
| 380 | fn setTreeReadOnly(idir: std.fs.IterableDir, alloc: std.mem.Allocator) !void { | |
| 381 | var walker = try idir.walk(alloc); | |
| 377 | fn setTreeReadOnly(dir: std.fs.Dir, alloc: std.mem.Allocator) !void { | |
| 378 | var walker = try dir.walk(alloc); | |
| 382 | 379 | defer walker.deinit(); |
| 383 | 380 | |
| 384 | 381 | while (try walker.next()) |entry| { |
| 385 | 382 | if (entry.kind != .file) continue; |
| 386 | var file = try idir.dir.openFile(entry.path, .{}); | |
| 383 | var file = try dir.openFile(entry.path, .{}); | |
| 387 | 384 | defer file.close(); |
| 388 | 385 | var metadata = try file.metadata(); |
| 389 | 386 | var perms = metadata.permissions(); |
src/main.zig+2-2| ... | ... | @@ -56,7 +56,7 @@ pub fn main() !void { |
| 56 | 56 | for (args[1..]) |item| { |
| 57 | 57 | try sub_cmd_args.append(item); |
| 58 | 58 | } |
| 59 | const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { | |
| 59 | const result = std.ChildProcess.run(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { | |
| 60 | 60 | else => |ee| return ee, |
| 61 | 61 | error.FileNotFound => { |
| 62 | 62 | fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); |
| ... | ... | @@ -75,7 +75,7 @@ const ansi_reset = "\x1B[39m"; |
| 75 | 75 | pub fn assert(ok: bool, comptime fmt: string, args: anytype) void { |
| 76 | 76 | if (!ok) { |
| 77 | 77 | std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args); |
| 78 | std.os.exit(1); | |
| 78 | std.process.exit(1); | |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 |
src/util/dep.zig-1| ... | ... | @@ -27,7 +27,6 @@ pub const Dep = struct { |
| 27 | 27 | yaml: ?yaml.Mapping, |
| 28 | 28 | deps: []zigmod.Dep, |
| 29 | 29 | keep: bool = false, |
| 30 | vcpkg: bool = false, | |
| 31 | 30 | for_build: bool = false, |
| 32 | 31 | parent_id: string, |
| 33 | 32 |
src/util/funcs.zig+4-4| ... | ... | @@ -19,7 +19,7 @@ const ansi_reset = "\x1B[39m"; |
| 19 | 19 | pub fn assert(ok: bool, comptime fmt: string, args: anytype) void { |
| 20 | 20 | if (!ok) { |
| 21 | 21 | std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args); |
| 22 | std.os.exit(1); | |
| 22 | std.process.exit(1); | |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| ... | ... | @@ -47,13 +47,13 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string { |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string { |
| 50 | var dir = try std.fs.cwd().openIterableDir(dpath, .{}); | |
| 50 | var dir = try std.fs.cwd().openDir(dpath, .{ .iterate = true }); | |
| 51 | 51 | defer dir.close(); |
| 52 | 52 | return try extras.fileList(alloc, dir); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.ExecResult { | |
| 56 | return std.ChildProcess.exec(.{ .allocator = alloc, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) { | |
| 55 | pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.RunResult { | |
| 56 | return std.ChildProcess.run(.{ .allocator = alloc, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) { | |
| 57 | 57 | error.FileNotFound => { |
| 58 | 58 | u.fail("\"{s}\" command not found", .{args[0]}); |
| 59 | 59 | }, |
src/util/modfile.zig-3| ... | ... | @@ -28,7 +28,6 @@ pub const ModFile = struct { |
| 28 | 28 | rootdeps: []zigmod.Dep, |
| 29 | 29 | builddeps: []zigmod.Dep, |
| 30 | 30 | min_zig_version: ?std.SemanticVersion, |
| 31 | vcpkg: bool, | |
| 32 | 31 | |
| 33 | 32 | pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !std.fs.File { |
| 34 | 33 | return dir.openFile("zig.mod", ops) catch |err| switch (err) { |
| ... | ... | @@ -75,7 +74,6 @@ pub const ModFile = struct { |
| 75 | 74 | .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false), |
| 76 | 75 | .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true), |
| 77 | 76 | .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version") orelse "") catch null, |
| 78 | .vcpkg = std.mem.eql(u8, "true", mapping.get_string("vcpkg") orelse ""), | |
| 79 | 77 | }; |
| 80 | 78 | } |
| 81 | 79 | |
| ... | ... | @@ -137,7 +135,6 @@ pub const ModFile = struct { |
| 137 | 135 | .yaml = item.mapping, |
| 138 | 136 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build), |
| 139 | 137 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), |
| 140 | .vcpkg = std.mem.eql(u8, "true", item.mapping.get_string("vcpkg") orelse ""), | |
| 141 | 138 | .for_build = for_build, |
| 142 | 139 | .parent_id = mapping.get_string("id") orelse "", |
| 143 | 140 | }); |
src/util/module.zig-2| ... | ... | @@ -27,7 +27,6 @@ pub const Module = struct { |
| 27 | 27 | dep: ?zigmod.Dep, |
| 28 | 28 | for_build: bool = false, |
| 29 | 29 | min_zig_version: ?std.SemanticVersion, |
| 30 | vcpkg: bool, | |
| 31 | 30 | |
| 32 | 31 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: string, options: *common.CollectOptions) !Module { |
| 33 | 32 | var moddeps = std.ArrayList(Module).init(alloc); |
| ... | ... | @@ -54,7 +53,6 @@ pub const Module = struct { |
| 54 | 53 | .dep = dep, |
| 55 | 54 | .for_build = dep.for_build, |
| 56 | 55 | .min_zig_version = null, |
| 57 | .vcpkg = dep.vcpkg, | |
| 58 | 56 | }; |
| 59 | 57 | } |
| 60 | 58 |
zig.mod+5-2| ... | ... | @@ -3,7 +3,7 @@ name: zigmod |
| 3 | 3 | main: src/lib.zig |
| 4 | 4 | license: MIT |
| 5 | 5 | description: A package manager for the Zig programming language. |
| 6 | min_zig_version: 0.11.0 | |
| 6 | min_zig_version: 0.12.0 | |
| 7 | 7 | dependencies: |
| 8 | 8 | - src: git https://github.com/nektro/zig-yaml |
| 9 | 9 | - src: git https://github.com/nektro/zig-ansi |
| ... | ... | @@ -18,7 +18,10 @@ dependencies: |
| 18 | 18 | |
| 19 | 19 | root_dependencies: |
| 20 | 20 | - src: git https://github.com/marlersoft/zigwin32 |
| 21 | id: zg4wbiyyfn2fdpmia0jjh2d5k0xb7v1l7zn3xcyv | |
| 21 | id: o6ogpor87xc23o863qaqfciqqdnt48nlj0395dk1xt4m9b34 | |
| 22 | 22 | keep: true |
| 23 | name: win32 | |
| 24 | main: win32.zig | |
| 25 | license: MIT | |
| 23 | 26 | - src: git https://github.com/nektro/zig-extras |
| 24 | 27 | - src: git https://github.com/nektro/zig-ansi |
zigmod.lock+8-8| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | 1 | 2 |
| 2 | 2 | git https://github.com/marlersoft/zigwin32 commit-c778640d3dc153e900fbe37e2816b5176af3c802 |
| 3 | git https://github.com/nektro/arqv-ini commit-ddbe89bb0d9085e939bcbc713caeb2b7cf852bae | |
| 4 | git https://github.com/nektro/iguanaTLS commit-f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40 | |
| 5 | git https://github.com/nektro/zfetch commit-478031843703fef875ca347898208c01869c7c9d | |
| 6 | git https://github.com/nektro/zig-ansi commit-407a70207ee818f6920096f40779e3fb52db49b0 | |
| 3 | git https://github.com/nektro/arqv-ini commit-38a018ad3a19d5b4663a5364d2d31271f250846b | |
| 4 | git https://github.com/nektro/iguanaTLS commit-4dc8850883b49e4a452871298788b06b1af9fe24 | |
| 5 | git https://github.com/nektro/zfetch commit-863be236188e5f24d16554f9dcd7df96dd254a13 | |
| 6 | git https://github.com/nektro/zig-ansi commit-c3e439f86b0484e4428f38c4d8b07b7b5ae1634b | |
| 7 | 7 | git https://github.com/nektro/zig-detect-license commit-3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd |
| 8 | git https://github.com/nektro/zig-extras commit-c95c2301565603856ff6fcaecaa63bdcdd689bc1 | |
| 8 | git https://github.com/nektro/zig-extras commit-74f0ddb0a4dfa7921739b88cc381951a6b6e73ce | |
| 9 | 9 | git https://github.com/nektro/zig-inquirer commit-9e1d873db79e9ffa6ae6e06bd372428c9be85d97 |
| 10 | 10 | git https://github.com/nektro/zig-leven commit-e548b0bcc7b6f34f636c0b6b905928d31254c54d |
| 11 | 11 | git https://github.com/nektro/zig-licenses commit-f46d9f774df929885eef66c733a1e2a46bf16aec |
| 12 | 12 | git https://github.com/nektro/zig-licenses-text commit-b01e5a2dffcc564bddd8f514fe64bab9b5c52572 |
| 13 | 13 | git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e0415992 |
| 14 | git https://github.com/nektro/zig-time commit-913d3ff01878326955bb3b265dcb3fdb3607d232 | |
| 14 | git https://github.com/nektro/zig-time commit-ba546bbf2e8438c9b2325f36f392c9d95b432e8e | |
| 15 | 15 | git https://github.com/nektro/zig-yaml commit-0d17fb99cba338aedc1abac12d78d5e5f04f0b6b |
| 16 | git https://github.com/truemedian/hzzp commit-31563ce8173038aff326f83b18d49d84e2737255 | |
| 17 | git https://github.com/ziglibs/known-folders commit-bf79988adcfce166f848e4b11e718c1966365329 | |
| 16 | git https://github.com/truemedian/hzzp commit-a7f03a1e652abe8c89b376d090cec50acb0d2a1a | |
| 17 | git https://github.com/ziglibs/known-folders commit-0ad514dcfb7525e32ae349b9acc0a53976f3a9fa | |
| 18 | 18 | git https://github.com/yaml/libyaml tag-0.2.5 |