Jonathan Marler 1 年之前
父節點
當前提交
962c153c8b
共有 6 個文件被更改,包括 148 次插入92 次删除
  1. 2 2
      build.zig
  2. 4 5
      build2.zig
  3. 2 2
      fixdeletetree.zig
  4. 113 58
      test.zig
  5. 6 6
      win32exelink.zig
  6. 21 19
      zigup.zig

+ 2 - 2
build.zig

@@ -46,11 +46,11 @@ fn buildOrFail(b: *Builder) anyerror {
 }
 
 // TODO: remove the following if https://github.com/ziglang/zig/pull/9987 is integrated
-fn getBuildArgs(self: *Builder) ! []const [:0]const u8 {
+fn getBuildArgs(self: *Builder) ![]const [:0]const u8 {
     const args = try std.process.argsAlloc(self.allocator);
     return args[5..];
 }
-pub fn addBuild(self: *Builder, build_file: std.build.FileSource, _: struct { }) *std.build.RunStep {
+pub fn addBuild(self: *Builder, build_file: std.build.FileSource, _: struct {}) *std.build.RunStep {
     const run_step = std.build.RunStep.create(
         self,
         self.fmt("zig build {s}", .{build_file.getDisplayName()}),

+ 4 - 5
build2.zig

@@ -103,7 +103,7 @@ fn addZigupExe(
     target: std.zig.CrossTarget,
     optimize: std.builtin.Mode,
     win32exelink_mod: ?*std.build.Module,
-    ssl_backend: ?SslBackend
+    ssl_backend: ?SslBackend,
 ) !*std.build.LibExeObjStep {
     const require_ssl_backend = b.allocator.create(RequireSslBackendStep) catch unreachable;
     require_ssl_backend.* = RequireSslBackendStep.init(b, "the zigup exe", ssl_backend);
@@ -157,7 +157,7 @@ const SslBackendFailedStep = struct {
     }
     fn make(step: *std.build.Step) !void {
         const self = @fieldParentPtr(RequireSslBackendStep, "step", step);
-        std.debug.print("error: the {s} failed to add the {s} SSL backend\n", .{self.context, self.backend});
+        std.debug.print("error: the {s} failed to add the {s} SSL backend\n", .{ self.context, self.backend });
         std.os.exit(1);
     }
 };
@@ -181,7 +181,7 @@ const RequireSslBackendStep = struct {
     fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void {
         _ = prog_node;
         const self = @fieldParentPtr(RequireSslBackendStep, "step", step);
-        if (self.backend) |_| { } else {
+        if (self.backend) |_| {} else {
             std.debug.print("error: {s} requires an SSL backend:\n", .{self.context});
             inline for (zigetbuild.ssl_backends) |field| {
                 std.debug.print("    -D{s}\n", .{field.name});
@@ -192,14 +192,13 @@ const RequireSslBackendStep = struct {
 };
 
 fn addGithubReleaseExe(b: *Builder, github_release_step: *std.build.Step, ziget_repo: []const u8, comptime target_triple: []const u8, comptime ssl_backend: SslBackend) !void {
-
     const small_release = true;
 
     const target = try std.zig.CrossTarget.parse(.{ .arch_os_abi = target_triple });
     const mode = if (small_release) .ReleaseSafe else .Debug;
     const exe = try addZigupExe(b, ziget_repo, target, mode, ssl_backend);
     if (small_release) {
-       exe.strip = true;
+        exe.strip = true;
     }
     exe.setOutputDir("github-release" ++ std.fs.path.sep_str ++ target_triple ++ std.fs.path.sep_str ++ @tagName(ssl_backend));
     github_release_step.dependOn(&exe.step);

+ 2 - 2
fixdeletetree.zig

@@ -8,7 +8,7 @@ pub fn deleteTree(dir: std.fs.Dir, sub_path: []const u8) !void {
     if (builtin.os.tag != .windows) {
         return dir.deleteTree(sub_path);
     }
-    
+
     // workaround issue on windows where it just doesn't delete things
     const MAX_ATTEMPTS = 10;
     var attempt: u8 = 0;
@@ -19,7 +19,7 @@ pub fn deleteTree(dir: std.fs.Dir, sub_path: []const u8) !void {
             if (attempt == MAX_ATTEMPTS) return err;
             switch (err) {
                 error.FileBusy => {
-                    std.log.warn("path '{s}' is busy (attempt {}), will retry", .{sub_path, attempt});
+                    std.log.warn("path '{s}' is busy (attempt {}), will retry", .{ sub_path, attempt });
                     std.time.sleep(std.time.ns_per_ms * 100); // sleep for 100 ms
                 },
                 else => |e| return e,

+ 113 - 58
test.zig

@@ -35,9 +35,8 @@ pub fn main() !u8 {
         .{},
     );
 
-    const zigup_args = &[_][]const u8 { zigup } ++ (
-        if (builtin.os.tag == .windows) &[_][]const u8 { } else &[_][]const u8 { "--install-dir", install_dir }
-    );
+    const install_args = if (builtin.os.tag == .windows) [_][]const u8{} else [_][]const u8{ "--install-dir", install_dir };
+    const zigup_args = &[_][]const u8{zigup} ++ install_args;
 
     var allocator_store = std.heap.ArenaAllocator.init(std.heap.page_allocator);
     defer allocator_store.deinit();
@@ -58,39 +57,57 @@ pub fn main() !u8 {
     {
         const scratch_bin_path = try std.fs.path.join(allocator, &.{ cwd, bin_dir });
         defer allocator.free(scratch_bin_path);
-        setPathEnv(try std.mem.concat(allocator, u8, &.{ scratch_bin_path, path_env_sep, original_path_env}));
+        setPathEnv(try std.mem.concat(allocator, u8, &.{ scratch_bin_path, path_env_sep, original_path_env }));
     }
 
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default", "master"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "default", "master" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "master has not been fetched"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"-h"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"-h"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "Usage"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"--help"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"--help"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "Usage"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"default"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.eql(u8, result.stdout, "<no-default>\n"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"fetch-index"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"fetch-index"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.containsAtLeast(u8, result.stdout, 1, "master"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default", "0.7.0"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "default", "0.7.0" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         dumpExecResult(result);
         switch (result.term) {
             .Exited => |code| try testing.expectEqual(@as(u8, 1), code),
@@ -98,25 +115,34 @@ pub fn main() !u8 {
         }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "error: compiler '0.7.0' is not installed\n"));
     }
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"0.7.0"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"0.7.0"});
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"default"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         dumpExecResult(result);
         try testing.expect(std.mem.eql(u8, result.stdout, "0.7.0\n"));
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"fetch", "0.7.0"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "fetch", "0.7.0" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "already installed"));
     }
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"master"});
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"0.8.0"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"master"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"0.8.0"});
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"default"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         dumpExecResult(result);
         try testing.expect(std.mem.eql(u8, result.stdout, "0.8.0\n"));
@@ -125,44 +151,59 @@ pub fn main() !u8 {
         const save_path_env = path_env_ptr.*;
         defer setPathEnv(save_path_env);
         setPathEnv("");
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default", "master"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "default", "master" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, " is not in PATH"));
     }
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"default", "master"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{ "default", "master" });
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"list"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"list"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.containsAtLeast(u8, result.stdout, 1, "0.7.0"));
         try testing.expect(std.mem.containsAtLeast(u8, result.stdout, 1, "0.8.0"));
     }
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"default", "0.7.0"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{ "default", "0.7.0" });
     try testing.expectEqual(@as(u32, 3), try getCompilerCount(install_dir));
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"run", "0.8.0", "version"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "run", "0.8.0", "version" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expectEqualSlices(u8, "0.8.0\n", result.stdout);
     }
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"run", "doesnotexist", "version"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "run", "doesnotexist", "version" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expectEqualSlices(u8, "error: compiler 'doesnotexist' does not exist, fetch it first with: zigup fetch doesnotexist\n", result.stderr);
     }
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"keep", "0.8.0"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{ "keep", "0.8.0" });
     // doesn't delete anything because we have keepfile and master doens't get deleted
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"clean"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"clean"});
     try testing.expectEqual(@as(u32, 3), try getCompilerCount(install_dir));
 
     // Just make a directory to trick zigup into thinking there is another compiler so we don't have to wait for it to download/install
     try std.fs.cwd().makeDir(install_dir ++ sep ++ "0.9.0");
     try testing.expectEqual(@as(u32, 4), try getCompilerCount(install_dir));
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"clean"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"clean"});
     try testing.expectEqual(@as(u32, 3), try getCompilerCount(install_dir));
 
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"clean", "0.8.0"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "clean", "0.8.0" });
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "deleting "));
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "0.8.0"));
@@ -170,19 +211,25 @@ pub fn main() !u8 {
     try testing.expectEqual(@as(u32, 2), try getCompilerCount(install_dir));
 
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"clean"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"clean"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try passOrDumpAndThrow(result);
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "it is master"));
     }
     try testing.expectEqual(@as(u32, 2), try getCompilerCount(install_dir));
 
-    try runNoCapture(zigup_args ++ &[_][]const u8 {"master"});
+    try runNoCapture(zigup_args ++ &[_][]const u8{"master"});
     try testing.expectEqual(@as(u32, 2), try getCompilerCount(install_dir));
 
     {
-        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"DOESNOTEXST"});
-        defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+        const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{"DOESNOTEXST"});
+        defer {
+            allocator.free(result.stdout);
+            allocator.free(result.stderr);
+        }
         try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "HTTP request failed"));
     }
     try testing.expectEqual(@as(u32, 2), try getCompilerCount(install_dir));
@@ -202,15 +249,18 @@ pub fn main() !u8 {
             try file.writer().writeAll("a fake executable");
         }
 
-        setPathEnv(try std.mem.concat(allocator, u8, &.{ scratch_bin2_path, path_env_sep, previous_path}));
+        setPathEnv(try std.mem.concat(allocator, u8, &.{ scratch_bin2_path, path_env_sep, previous_path }));
         defer setPathEnv(previous_path);
 
         // verify zig isn't currently on 0.7.0 before we set it as the default
         try checkZigVersion(allocator, path_link, expected_zig_version_0_7_0, .not_equal);
 
         {
-            const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8 {"default", "0.7.0"});
-            defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+            const result = try runCaptureOuts(allocator, zigup_args ++ &[_][]const u8{ "default", "0.7.0" });
+            defer {
+                allocator.free(result.stdout);
+                allocator.free(result.stderr);
+            }
             std.log.info("output: {s}", .{result.stderr});
             try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "error: zig compiler '"));
             try testing.expect(std.mem.containsAtLeast(u8, result.stderr, 1, "' is higher priority in PATH than the path-link '"));
@@ -225,23 +275,29 @@ pub fn main() !u8 {
     // NOTE: this test will eventually break when these builds are cleaned up,
     //       we should support downloading from bazel and use that instead since
     //       it should be more permanent
-    try runNoCapture(zigup_args ++ &[_][]const u8 { "0.11.0-dev.4263+f821543e4" });
+    try runNoCapture(zigup_args ++ &[_][]const u8{"0.11.0-dev.4263+f821543e4"});
 
     std.log.info("Success", .{});
     return 0;
 }
 
 fn checkZigVersion(allocator: std.mem.Allocator, zig: []const u8, compare: []const u8, want_equal: enum { not_equal, equal }) !void {
-    const result = try runCaptureOuts(allocator, &[_][]const u8 {zig, "version" });
-    defer { allocator.free(result.stdout); allocator.free(result.stderr); }
+    const result = try runCaptureOuts(allocator, &[_][]const u8{ zig, "version" });
+    defer {
+        allocator.free(result.stdout);
+        allocator.free(result.stderr);
+    }
     try passOrDumpAndThrow(result);
 
     const actual_version = std.mem.trimRight(u8, result.stdout, "\r\n");
     const actual_equal = std.mem.eql(u8, compare, actual_version);
-    const expected_equal = switch (want_equal) { .not_equal => false, .equal => true };
+    const expected_equal = switch (want_equal) {
+        .not_equal => false,
+        .equal => true,
+    };
     if (expected_equal != actual_equal) {
         const prefix: []const u8 = if (expected_equal) "" else " NOT";
-        std.log.info("expected zig version to{s} be '{s}', but is '{s}'", .{prefix, compare, actual_version});
+        std.log.info("expected zig version to{s} be '{s}', but is '{s}'", .{ prefix, compare, actual_version });
         return error.TestUnexpectedResult;
     }
 }
@@ -265,17 +321,16 @@ fn getCompilerCount(install_dir: []const u8) !u32 {
     return count;
 }
 
-
 fn trailNl(s: []const u8) []const u8 {
-    return if (s.len == 0 or s[s.len-1] != '\n') "\n" else "";
+    return if (s.len == 0 or s[s.len - 1] != '\n') "\n" else "";
 }
 
 fn dumpExecResult(result: std.ChildProcess.ExecResult) void {
     if (result.stdout.len > 0) {
-        std.debug.print("--- STDOUT ---\n{s}{s}--------------\n", .{result.stdout, trailNl(result.stdout)});
+        std.debug.print("--- STDOUT ---\n{s}{s}--------------\n", .{ result.stdout, trailNl(result.stdout) });
     }
     if (result.stderr.len > 0) {
-        std.debug.print("--- STDERR ---\n{s}{s}--------------\n", .{result.stderr, trailNl(result.stderr)});
+        std.debug.print("--- STDERR ---\n{s}{s}--------------\n", .{ result.stderr, trailNl(result.stderr) });
     }
 }
 
@@ -292,7 +347,7 @@ fn runCaptureOuts(allocator: std.mem.Allocator, argv: []const []const u8) !std.C
         defer allocator.free(cmd);
         std.log.info("RUN: {s}", .{cmd});
     }
-    return try std.ChildProcess.exec(.{.allocator = allocator, .argv = argv, .env_map = &child_env_map});
+    return try std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv, .env_map = &child_env_map });
 }
 fn passOrThrow(term: std.ChildProcess.Term) error{ChildProcessFailed}!void {
     if (!execResultPassed(term)) {

+ 6 - 6
win32exelink.zig

@@ -10,7 +10,7 @@ const exe_marker_len = 42;
 // I'm exporting this and making it mutable to make sure the compiler keeps it around
 // and prevent it from evaluting its contents at comptime
 export var zig_exe_string: [exe_marker_len + std.fs.MAX_PATH_BYTES + 1]u8 =
-    ("!!!THIS MARKS THE zig_exe_string MEMORY!!#" ++ ([1]u8 {0} ** (std.fs.MAX_PATH_BYTES + 1))).*;
+    ("!!!THIS MARKS THE zig_exe_string MEMORY!!#" ++ ([1]u8{0} ** (std.fs.MAX_PATH_BYTES + 1))).*;
 
 const global = struct {
     var child: std.ChildProcess = undefined;
@@ -53,7 +53,7 @@ pub fn main() !u8 {
     try global.child.spawn();
     return switch (try global.child.wait()) {
         .Exited => |e| e,
-        .Signal =>  0xff,
+        .Signal => 0xff,
         .Stopped => 0xff,
         .Unknown => 0xff,
     };
@@ -72,13 +72,13 @@ fn consoleCtrlHandler(ctrl_type: u32) callconv(@import("std").os.windows.WINAPI)
         else => "Unknown",
     };
     // TODO: should we stop the process on a break event?
-    log.info("caught ctrl signal {d} ({s}), stopping process...", .{ctrl_type, name});
+    log.info("caught ctrl signal {d} ({s}), stopping process...", .{ ctrl_type, name });
     const exit_code = switch (global.child.kill() catch |err| {
         log.err("failed to kill process, error={s}", .{@errorName(err)});
         std.os.exit(0xff);
     }) {
         .Exited => |e| e,
-        .Signal =>  0xff,
+        .Signal => 0xff,
         .Stopped => 0xff,
         .Unknown => 0xff,
     };
@@ -95,10 +95,10 @@ const win32 = struct {
     pub const CTRL_SHUTDOWN_EVENT = @as(u32, 6);
     pub const GetLastError = std.os.windows.kernel32.GetLastError;
     pub const PHANDLER_ROUTINE = switch (builtin.zig_backend) {
-        .stage1 => fn(
+        .stage1 => fn (
             CtrlType: u32,
         ) callconv(@import("std").os.windows.WINAPI) BOOL,
-        else => *const fn(
+        else => *const fn (
             CtrlType: u32,
         ) callconv(@import("std").os.windows.WINAPI) BOOL,
     };

+ 21 - 19
zigup.zig

@@ -10,13 +10,13 @@ const zarc = @import("zarc");
 
 const fixdeletetree = @import("fixdeletetree.zig");
 
-const arch = switch(builtin.cpu.arch) {
+const arch = switch (builtin.cpu.arch) {
     .x86_64 => "x86_64",
     .aarch64 => "aarch64",
     .riscv64 => "riscv64",
     else => @compileError("Unsupported CPU Architecture"),
 };
-const os = switch(builtin.os.tag) {
+const os = switch (builtin.os.tag) {
     .windows => "windows",
     .linux => "linux",
     .macos => "macos",
@@ -68,7 +68,9 @@ fn downloadToString(allocator: Allocator, url: []const u8) ![]u8 {
     return response_array_list.toOwnedSlice();
 }
 
-fn ignoreHttpCallback(request: []const u8) void { _ = request; }
+fn ignoreHttpCallback(request: []const u8) void {
+    _ = request;
+}
 
 fn getHomeDir() ![]const u8 {
     return std.os.getenv("HOME") orelse {
@@ -210,7 +212,7 @@ pub fn main2() !u8 {
                 return 0;
             } else {
                 if (newlen == 0 and std.mem.eql(u8, "run", arg)) {
-                    return try runCompiler(allocator, args[i+1..]);
+                    return try runCompiler(allocator, args[i + 1 ..]);
                 }
                 args[newlen] = args[i];
                 newlen += 1;
@@ -489,7 +491,7 @@ fn listCompilers(allocator: Allocator) !void {
     const install_dir_string = try getInstallDir(allocator, .{ .create = false });
     defer allocator.free(install_dir_string);
 
-    var install_dir = std.fs.openIterableDirAbsolute(install_dir_string, .{ }) catch |e| switch (e) {
+    var install_dir = std.fs.openIterableDirAbsolute(install_dir_string, .{}) catch |e| switch (e) {
         error.FileNotFound => return,
         else => return e,
     };
@@ -512,7 +514,7 @@ fn keepCompiler(allocator: Allocator, compiler_version: []const u8) !void {
     const install_dir_string = try getInstallDir(allocator, .{ .create = true });
     defer allocator.free(install_dir_string);
 
-    var install_dir = try std.fs.openIterableDirAbsolute(install_dir_string, .{ });
+    var install_dir = try std.fs.openIterableDirAbsolute(install_dir_string, .{});
     defer install_dir.close();
 
     var compiler_dir = install_dir.dir.openDir(compiler_version, .{}) catch |e| switch (e) {
@@ -594,7 +596,7 @@ fn readDefaultCompiler(allocator: Allocator, buffer: *[std.fs.MAX_PATH_BYTES + 1
         return try allocator.dupe(u8, targetPathToVersion(target_exe));
     }
 
-    const target_path = std.fs.readLinkAbsolute(path_link, buffer[0 .. std.fs.MAX_PATH_BYTES]) catch |e| switch (e) {
+    const target_path = std.fs.readLinkAbsolute(path_link, buffer[0..std.fs.MAX_PATH_BYTES]) catch |e| switch (e) {
         error.FileNotFound => return null,
         else => return e,
     };
@@ -688,7 +690,7 @@ fn verifyPathLink(allocator: Allocator, path_link: []const u8) !void {
 
     const path_link_dir_id = blk: {
         var dir = std.fs.openDirAbsolute(path_link_dir, .{}) catch |err| {
-            std.log.err("unable to open the path-link directory '{s}': {s}", .{path_link_dir, @errorName(err)});
+            std.log.err("unable to open the path-link directory '{s}': {s}", .{ path_link_dir, @errorName(err) });
             return error.AlreadyReported;
         };
         defer dir.close();
@@ -732,10 +734,10 @@ fn verifyPathLink(allocator: Allocator, path_link: []const u8) !void {
             var ext_it = std.mem.tokenize(u8, pathext_env, ";");
             while (ext_it.next()) |ext| {
                 if (ext.len == 0) continue;
-                const basename = try std.mem.concat(allocator, u8, &.{"zig", ext});
+                const basename = try std.mem.concat(allocator, u8, &.{ "zig", ext });
                 defer allocator.free(basename);
 
-                const exe = try std.fs.path.join(allocator, &.{path, basename});
+                const exe = try std.fs.path.join(allocator, &.{ path, basename });
                 defer allocator.free(exe);
 
                 try enforceNoZig(path_link, exe);
@@ -776,7 +778,7 @@ fn enforceNoZig(path_link: []const u8, exe: []const u8) !void {
     defer file.close();
 
     // todo: on posix systems ignore the file if it is not executable
-    std.log.err("zig compiler '{s}' is higher priority in PATH than the path-link '{s}'", .{exe, path_link});
+    std.log.err("zig compiler '{s}' is higher priority in PATH than the path-link '{s}'", .{ exe, path_link });
 }
 
 const FileId = struct {
@@ -793,7 +795,7 @@ const FileId = struct {
         if (builtin.os.tag == .windows) {
             var info: win32.BY_HANDLE_FILE_INFORMATION = undefined;
             if (0 == win32.GetFileInformationByHandle(file.handle, &info)) {
-                std.log.err("GetFileInformationByHandle on '{s}' failed, error={}", .{filename_for_error, std.os.windows.kernel32.GetLastError()});
+                std.log.err("GetFileInformationByHandle on '{s}' failed, error={}", .{ filename_for_error, std.os.windows.kernel32.GetLastError() });
                 return error.AlreadyReported;
             }
             return FileId{
@@ -810,9 +812,9 @@ const FileId = struct {
 
     pub fn initFromDir(dir: std.fs.Dir, name_for_error: []const u8) !FileId {
         if (builtin.os.tag == .windows) {
-            return initFromFile(std.fs.File { .handle = dir.fd}, name_for_error);
+            return initFromFile(std.fs.File{ .handle = dir.fd }, name_for_error);
         }
-        return initFromFile(std.fs.File { .handle = dir.fd }, name_for_error);
+        return initFromFile(std.fs.File{ .handle = dir.fd }, name_for_error);
     }
 
     pub fn eql(self: FileId, other: FileId) bool {
@@ -845,7 +847,7 @@ const win32 = struct {
 };
 
 const win32exelink = struct {
-    const content =  @embedFile("win32exelink");
+    const content = @embedFile("win32exelink");
     const exe_offset: usize = if (builtin.os.tag != .windows) 0 else blk: {
         @setEvalBranchQuota(content.len * 2);
         const marker = "!!!THIS MARKS THE zig_exe_string MEMORY!!#";
@@ -860,12 +862,12 @@ const win32exelink = struct {
 };
 fn createExeLink(link_target: []const u8, path_link: []const u8) !void {
     if (path_link.len > std.fs.MAX_PATH_BYTES) {
-        std.debug.print("Error: path_link (size {}) is too large (max {})\n", .{path_link.len, std.fs.MAX_PATH_BYTES});
+        std.debug.print("Error: path_link (size {}) is too large (max {})\n", .{ path_link.len, std.fs.MAX_PATH_BYTES });
         return error.AlreadyReported;
     }
     const file = try std.fs.cwd().createFile(path_link, .{});
     defer file.close();
-    try file.writer().writeAll(win32exelink.content[0 .. win32exelink.exe_offset]);
+    try file.writer().writeAll(win32exelink.content[0..win32exelink.exe_offset]);
     try file.writer().writeAll(link_target);
     try file.writer().writeAll(win32exelink.content[win32exelink.exe_offset + link_target.len ..]);
 }
@@ -877,8 +879,8 @@ fn determineVersionKind(version: []const u8) VersionKind {
 
 fn getDefaultUrl(allocator: Allocator, compiler_version: []const u8) ![]const u8 {
     return switch (determineVersionKind(compiler_version)) {
-        .dev => try std.fmt.allocPrint(allocator, "https://ziglang.org/builds/zig-" ++ url_platform ++ "-{0s}." ++ archive_ext, .{ compiler_version }),
-        .release => try std.fmt.allocPrint(allocator, "https://ziglang.org/download/{s}/zig-" ++ url_platform ++ "-{0s}." ++ archive_ext, .{ compiler_version }),
+        .dev => try std.fmt.allocPrint(allocator, "https://ziglang.org/builds/zig-" ++ url_platform ++ "-{0s}." ++ archive_ext, .{compiler_version}),
+        .release => try std.fmt.allocPrint(allocator, "https://ziglang.org/download/{s}/zig-" ++ url_platform ++ "-{0s}." ++ archive_ext, .{compiler_version}),
     };
 }