| author | |
| committer | |
| log | cee55e13da2262f794f77e3848b2e564e58130b0 |
| tree | 51427daed6f1baa8354f2700f95771c0df9282e2 |
| parent | 827c27ef00d14468fde26506fd4999d96ce7c448 |
8 files changed, 41 insertions(+), 23 deletions(-)
.github/workflows/nightly.yml+1-1| ... | @@ -26,7 +26,7 @@ jobs: | ... | @@ -26,7 +26,7 @@ jobs: |
| 26 | - name: Setup Zig | 26 | - name: Setup Zig |
| 27 | uses: goto-bus-stop/setup-zig@v1 | 27 | uses: goto-bus-stop/setup-zig@v1 |
| 28 | with: | 28 | with: |
| 29 | version: "0.11.0-dev.874+40ed6ae84" | 29 | version: "0.11.0-dev.1570+693b12f8e" |
| 30 | 30 | ||
| 31 | - run: zig version | 31 | - run: zig version |
| 32 | - run: zig env | 32 | - run: zig env |
.github/workflows/push.yml+1-1| ... | @@ -19,7 +19,7 @@ jobs: | ... | @@ -19,7 +19,7 @@ jobs: |
| 19 | - name: Setup Zig | 19 | - name: Setup Zig |
| 20 | uses: goto-bus-stop/setup-zig@v1 | 20 | uses: goto-bus-stop/setup-zig@v1 |
| 21 | with: | 21 | with: |
| 22 | version: "0.11.0-dev.874+40ed6ae84" | 22 | version: "0.11.0-dev.1570+693b12f8e" |
| 23 | 23 | ||
| 24 | - run: zig version | 24 | - run: zig version |
| 25 | - run: zig env | 25 | - run: zig env |
README.md+1-1| ... | @@ -17,7 +17,7 @@ A package manager for the Zig programming language. | ... | @@ -17,7 +17,7 @@ A package manager for the Zig programming language. |
| 17 | - https://github.com/nektro/zigmod/releases | 17 | - https://github.com/nektro/zigmod/releases |
| 18 | 18 | ||
| 19 | ## Built With | 19 | ## Built With |
| 20 | - Zig master (at least `0.11.0-dev.874+40ed6ae84`) | 20 | - Zig master (at least `0.11.0-dev.1570+693b12f8e`) |
| 21 | - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) | 21 | - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) |
| 22 | 22 | ||
| 23 | ### Build from Source | 23 | ### Build from Source |
build.zig+7-7| ... | @@ -6,16 +6,16 @@ const deps = @import("./deps.zig"); | ... | @@ -6,16 +6,16 @@ const deps = @import("./deps.zig"); |
| 6 | pub fn build(b: *std.build.Builder) void { | 6 | pub fn build(b: *std.build.Builder) void { |
| 7 | b.prominent_compile_errors = true; | 7 | b.prominent_compile_errors = true; |
| 8 | const target = b.standardTargetOptions(.{}); | 8 | const target = b.standardTargetOptions(.{}); |
| 9 | 9 | const optimize = b.standardOptimizeOption(.{}); | |
| 10 | b.setPreferredReleaseMode(.ReleaseSafe); | ||
| 11 | const mode = b.standardReleaseOptions(); | ||
| 12 | |||
| 13 | const use_full_name = b.option(bool, "use-full-name", "") orelse false; | 10 | const use_full_name = b.option(bool, "use-full-name", "") orelse false; |
| 14 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) }); | 11 | const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) }); |
| 15 | const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); | 12 | const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); |
| 16 | const exe = b.addExecutable(exe_name, "src/main.zig"); | 13 | const exe = b.addExecutable(.{ |
| 17 | exe.setTarget(target); | 14 | .name = exe_name, |
| 18 | exe.setBuildMode(mode); | 15 | .root_source_file = .{ .path = "src/main.zig" }, |
| 16 | .target = target, | ||
| 17 | .optimize = optimize, | ||
| 18 | }); | ||
| 19 | 19 | ||
| 20 | const exe_options = b.addOptions(); | 20 | const exe_options = b.addOptions(); |
| 21 | exe.addOptions("build_options", exe_options); | 21 | exe.addOptions("build_options", exe_options); |
deps.zig+10-7| ... | @@ -1,7 +1,7 @@ | ... | @@ -1,7 +1,7 @@ |
| 1 | // zig fmt: off | 1 | // zig fmt: off |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const Pkg = std.build.Pkg; | 4 | const ModuleDependency = std.build.ModuleDependency; |
| 5 | const string = []const u8; | 5 | const string = []const u8; |
| 6 | 6 | ||
| 7 | pub const GitExactStep = struct { | 7 | pub const GitExactStep = struct { |
| ... | @@ -87,7 +87,8 @@ pub fn addAllTo(exe: *std.build.LibExeObjStep) void { | ... | @@ -87,7 +87,8 @@ pub fn addAllTo(exe: *std.build.LibExeObjStep) void { |
| 87 | const b = exe.builder; | 87 | const b = exe.builder; |
| 88 | @setEvalBranchQuota(1_000_000); | 88 | @setEvalBranchQuota(1_000_000); |
| 89 | for (packages) |pkg| { | 89 | for (packages) |pkg| { |
| 90 | exe.addPackage(pkg.zp(b)); | 90 | const moddep = pkg.zp(b); |
| 91 | exe.addModule(moddep.name, moddep.module); | ||
| 91 | } | 92 | } |
| 92 | var llc = false; | 93 | var llc = false; |
| 93 | var vcpkg = false; | 94 | var vcpkg = false; |
| ... | @@ -129,21 +130,23 @@ pub const Package = struct { | ... | @@ -129,21 +130,23 @@ pub const Package = struct { |
| 129 | frameworks: []const string = &.{}, | 130 | frameworks: []const string = &.{}, |
| 130 | vcpkg: bool = false, | 131 | vcpkg: bool = false, |
| 131 | 132 | ||
| 132 | pub fn zp(self: *const Package, b: *std.build.Builder) Pkg { | 133 | pub fn zp(self: *const Package, b: *std.build.Builder) ModuleDependency { |
| 133 | var temp: [100]Pkg = undefined; | 134 | var temp: [100]ModuleDependency = undefined; |
| 134 | for (self.deps) |item, i| { | 135 | for (self.deps) |item, i| { |
| 135 | temp[i] = item.zp(b); | 136 | temp[i] = item.zp(b); |
| 136 | } | 137 | } |
| 137 | return .{ | 138 | return .{ |
| 138 | .name = self.name, | 139 | .name = self.name, |
| 139 | .source = .{ .path = self.entry.? }, | 140 | .module = b.createModule(.{ |
| 140 | .dependencies = b.allocator.dupe(Pkg, temp[0..self.deps.len]) catch @panic("oom"), | 141 | .source_file = .{ .path = self.entry.? }, |
| 142 | .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"), | ||
| 143 | }), | ||
| 141 | }; | 144 | }; |
| 142 | } | 145 | } |
| 143 | }; | 146 | }; |
| 144 | 147 | ||
| 145 | fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void { | 148 | fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void { |
| 146 | const min = std.SemanticVersion.parse("0.11.0-dev.874+40ed6ae84") catch return; | 149 | const min = std.SemanticVersion.parse("0.11.0-dev.1570+693b12f8e") catch return; |
| 147 | if (current.order(min).compare(.lt)) @panic(exe.builder.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min})); | 150 | if (current.order(min).compare(.lt)) @panic(exe.builder.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min})); |
| 148 | } | 151 | } |
| 149 | 152 |
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.11.0-dev.874+40ed6ae84`. | 13 | The earliest Zig release this Zigmod was verified to work with is `0.11.0-dev.1570+693b12f8e`. |
| 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. |
src/main.zig+19-4| ... | @@ -5,9 +5,6 @@ pub const build_options = @import("build_options"); | ... | @@ -5,9 +5,6 @@ pub const build_options = @import("build_options"); |
| 5 | const zigmod = @import("zigmod"); | 5 | const zigmod = @import("zigmod"); |
| 6 | const win32 = @import("win32"); | 6 | const win32 = @import("win32"); |
| 7 | 7 | ||
| 8 | pub const u = @import("./util/index.zig"); | ||
| 9 | pub const common = @import("./common.zig"); | ||
| 10 | |||
| 11 | // | 8 | // |
| 12 | // | 9 | // |
| 13 | 10 | ||
| ... | @@ -61,9 +58,27 @@ pub fn main() !void { | ... | @@ -61,9 +58,27 @@ pub fn main() !void { |
| 61 | const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { | 58 | const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { |
| 62 | else => |ee| return ee, | 59 | else => |ee| return ee, |
| 63 | error.FileNotFound => { | 60 | error.FileNotFound => { |
| 64 | u.fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); | 61 | fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); |
| 65 | }, | 62 | }, |
| 66 | }; | 63 | }; |
| 67 | try std.io.getStdOut().writeAll(result.stdout); | 64 | try std.io.getStdOut().writeAll(result.stdout); |
| 68 | try std.io.getStdErr().writeAll(result.stderr); | 65 | try std.io.getStdErr().writeAll(result.stderr); |
| 69 | } | 66 | } |
| 67 | |||
| 68 | // | ||
| 69 | // | ||
| 70 | |||
| 71 | const ansi_red = "\x1B[31m"; | ||
| 72 | const ansi_reset = "\x1B[39m"; | ||
| 73 | |||
| 74 | pub fn assert(ok: bool, comptime fmt: string, args: anytype) void { | ||
| 75 | if (!ok) { | ||
| 76 | std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args); | ||
| 77 | std.os.exit(1); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | pub fn fail(comptime fmt: string, args: anytype) noreturn { | ||
| 82 | assert(false, fmt, args); | ||
| 83 | unreachable; | ||
| 84 | } |
zig.mod+1-1| ... | @@ -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.11.0-dev.874+40ed6ae84 | 6 | min_zig_version: 0.11.0-dev.1570+693b12f8e |
| 7 | dependencies: | 7 | dependencies: |
| 8 | - src: git https://gist.github.com/nektro/d468fea84f8217e4c26ee8fbeeea38cc # yaml | 8 | - src: git https://gist.github.com/nektro/d468fea84f8217e4c26ee8fbeeea38cc # yaml |
| 9 | - src: git https://github.com/nektro/zig-ansi | 9 | - src: git https://github.com/nektro/zig-ansi |