diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cabd31447957d2c85e72235d3e6f6cc3f8f92425..fe2ce09493771eee938696bb990c946aa2ba0265 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Zig uses: goto-bus-stop/setup-zig@v1 with: - version: "0.11.0-dev.874+40ed6ae84" + version: "0.11.0-dev.1570+693b12f8e" - run: zig version - run: zig env diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 451579735fbba8b3537714683ce7d316d70e9c2a..349994a335b3ce1d6d91cf641678c7606e6626d3 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -19,7 +19,7 @@ jobs: - name: Setup Zig uses: goto-bus-stop/setup-zig@v1 with: - version: "0.11.0-dev.874+40ed6ae84" + version: "0.11.0-dev.1570+693b12f8e" - run: zig version - run: zig env diff --git a/README.md b/README.md index d3d837812c151c14a5e36d67ca72aac1d7db3af6..c62d6caa5893069634f945160d63cf0137c1cc38 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A package manager for the Zig programming language. - https://github.com/nektro/zigmod/releases ## Built With -- Zig master (at least `0.11.0-dev.874+40ed6ae84`) +- Zig master (at least `0.11.0-dev.1570+693b12f8e`) - See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock) ### Build from Source diff --git a/build.zig b/build.zig index 30f425c2d38248052408911b307618194bdf0cf5..8ae0d6e074b78bd55cc234562a6b46ec89ac972f 100644 --- a/build.zig +++ b/build.zig @@ -6,16 +6,16 @@ const deps = @import("./deps.zig"); pub fn build(b: *std.build.Builder) void { b.prominent_compile_errors = true; const target = b.standardTargetOptions(.{}); - - b.setPreferredReleaseMode(.ReleaseSafe); - const mode = b.standardReleaseOptions(); - + const optimize = b.standardOptimizeOption(.{}); const use_full_name = b.option(bool, "use-full-name", "") orelse false; const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) }); const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); - const exe = b.addExecutable(exe_name, "src/main.zig"); - exe.setTarget(target); - exe.setBuildMode(mode); + const exe = b.addExecutable(.{ + .name = exe_name, + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); const exe_options = b.addOptions(); exe.addOptions("build_options", exe_options); diff --git a/deps.zig b/deps.zig index 690d48f96fd96d4e544cb2ecf8d1695ac8bfc8e3..37f91dc27a3e1dec014043b706250074571fb1a7 100644 --- a/deps.zig +++ b/deps.zig @@ -1,7 +1,7 @@ // zig fmt: off const std = @import("std"); const builtin = @import("builtin"); -const Pkg = std.build.Pkg; +const ModuleDependency = std.build.ModuleDependency; const string = []const u8; pub const GitExactStep = struct { @@ -87,7 +87,8 @@ pub fn addAllTo(exe: *std.build.LibExeObjStep) void { const b = exe.builder; @setEvalBranchQuota(1_000_000); for (packages) |pkg| { - exe.addPackage(pkg.zp(b)); + const moddep = pkg.zp(b); + exe.addModule(moddep.name, moddep.module); } var llc = false; var vcpkg = false; @@ -129,21 +130,23 @@ pub const Package = struct { frameworks: []const string = &.{}, vcpkg: bool = false, - pub fn zp(self: *const Package, b: *std.build.Builder) Pkg { - var temp: [100]Pkg = undefined; + pub fn zp(self: *const Package, b: *std.build.Builder) ModuleDependency { + var temp: [100]ModuleDependency = undefined; for (self.deps) |item, i| { temp[i] = item.zp(b); } return .{ .name = self.name, - .source = .{ .path = self.entry.? }, - .dependencies = b.allocator.dupe(Pkg, temp[0..self.deps.len]) catch @panic("oom"), + .module = b.createModule(.{ + .source_file = .{ .path = self.entry.? }, + .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"), + }), }; } }; fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void { - const min = std.SemanticVersion.parse("0.11.0-dev.874+40ed6ae84") catch return; + const min = std.SemanticVersion.parse("0.11.0-dev.1570+693b12f8e") catch return; 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})); } diff --git a/docs/README.md b/docs/README.md index 80e767ec292c8c09507609cfce1d5cbc0980f3bb..c1deb6b7b78e32cfce92cc23b2f665f5ca8797c2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed. 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. -The earliest Zig release this Zigmod was verified to work with is `0.11.0-dev.874+40ed6ae84`. +The earliest Zig release this Zigmod was verified to work with is `0.11.0-dev.1570+693b12f8e`. ## Download You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source. diff --git a/src/main.zig b/src/main.zig index 8c60fac9383a611181e473df50ab4e8669f02b47..28c9e6ebd05e02b538c75a0f93de36ea9b7b51d7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5,9 +5,6 @@ pub const build_options = @import("build_options"); const zigmod = @import("zigmod"); const win32 = @import("win32"); -pub const u = @import("./util/index.zig"); -pub const common = @import("./common.zig"); - // // @@ -61,9 +58,27 @@ pub fn main() !void { const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { else => |ee| return ee, error.FileNotFound => { - u.fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); + fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); }, }; try std.io.getStdOut().writeAll(result.stdout); try std.io.getStdErr().writeAll(result.stderr); } + +// +// + +const ansi_red = "\x1B[31m"; +const ansi_reset = "\x1B[39m"; + +pub fn assert(ok: bool, comptime fmt: string, args: anytype) void { + if (!ok) { + std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args); + std.os.exit(1); + } +} + +pub fn fail(comptime fmt: string, args: anytype) noreturn { + assert(false, fmt, args); + unreachable; +} diff --git a/zig.mod b/zig.mod index 122a7e5b0dec100331893698a4d8caee6a85f03a..bfa0ee2e1fe04b012acb4cd0009cbc57dd6eb1c4 100644 --- a/zig.mod +++ b/zig.mod @@ -3,7 +3,7 @@ name: zigmod main: src/lib.zig license: MIT description: A package manager for the Zig programming language. -min_zig_version: 0.11.0-dev.874+40ed6ae84 +min_zig_version: 0.11.0-dev.1570+693b12f8e dependencies: - src: git https://gist.github.com/nektro/d468fea84f8217e4c26ee8fbeeea38cc # yaml - src: git https://github.com/nektro/zig-ansi