authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-08 00:23:09 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-08 00:23:09 -08:00
logcee55e13da2262f794f77e3848b2e564e58130b0
tree51427daed6f1baa8354f2700f95771c0df9282e2
parent827c27ef00d14468fde26506fd4999d96ce7c448

update for zig master 0.11.0-dev.1570+693b12f8e


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 Zig26 - name: Setup Zig
27 uses: goto-bus-stop/setup-zig@v127 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"
3030
31 - run: zig version31 - run: zig version
32 - run: zig env32 - run: zig env
.github/workflows/push.yml+1-1
...@@ -19,7 +19,7 @@ jobs:...@@ -19,7 +19,7 @@ jobs:
19 - name: Setup Zig19 - name: Setup Zig
20 uses: goto-bus-stop/setup-zig@v120 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"
2323
24 - run: zig version24 - run: zig version
25 - run: zig env25 - 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/releases17- https://github.com/nektro/zigmod/releases
1818
19## Built With19## 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)
2222
23### Build from Source23### 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");
6pub fn build(b: *std.build.Builder) void {6pub 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(.{});
99 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 });
1919
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: off1// zig fmt: off
2const std = @import("std");2const std = @import("std");
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const Pkg = std.build.Pkg;4const ModuleDependency = std.build.ModuleDependency;
5const string = []const u8;5const string = []const u8;
66
7pub const GitExactStep = struct {7pub 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,
131132
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};
144147
145fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {148fn 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}
149152
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.
1010
11As 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.11As 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.
1212
13The earliest Zig release this Zigmod was verified to work with is `0.11.0-dev.874+40ed6ae84`.13The earliest Zig release this Zigmod was verified to work with is `0.11.0-dev.1570+693b12f8e`.
1414
15## Download15## Download
16You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source.16You 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");
5const zigmod = @import("zigmod");5const zigmod = @import("zigmod");
6const win32 = @import("win32");6const win32 = @import("win32");
77
8pub const u = @import("./util/index.zig");
9pub const common = @import("./common.zig");
10
11//8//
12//9//
1310
...@@ -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
71const ansi_red = "\x1B[31m";
72const ansi_reset = "\x1B[39m";
73
74pub 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
81pub 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
3main: src/lib.zig3main: src/lib.zig
4license: MIT4license: MIT
5description: A package manager for the Zig programming language.5description: A package manager for the Zig programming language.
6min_zig_version: 0.11.0-dev.874+40ed6ae846min_zig_version: 0.11.0-dev.1570+693b12f8e
7dependencies:7dependencies:
8 - src: git https://gist.github.com/nektro/d468fea84f8217e4c26ee8fbeeea38cc # yaml8 - src: git https://gist.github.com/nektro/d468fea84f8217e4c26ee8fbeeea38cc # yaml
9 - src: git https://github.com/nektro/zig-ansi9 - src: git https://github.com/nektro/zig-ansi