Skip to content

Commit eb1adcb

Browse files
committed
0.12.0
1 parent 33718d0 commit eb1adcb

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ zshim is the [`shim`](https://github.com/71/scoop-better-shimexe/).
66

77
Requirements:
88

9-
- [Zig 0.11.0-dev.1568+c9b957c93](https://ziglang.org/)
9+
- [Zig 0.12.0](https://ziglang.org/)
1010
- git
1111

1212
Once you have those, then it's as easy as:

build.zig

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
const Builder = @import("std").build.Builder;
1+
const std = @import("std");
22

3-
pub fn build(b: *Builder) void {
3+
pub fn build(b: *std.Build) void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
66

77
const exe = b.addExecutable(.{
88
.name = "shim",
9-
.root_source_file = .{ .path = "src/main.zig" },
9+
.root_source_file = b.path("src/main.zig"),
1010
.target = target,
1111
.optimize = optimize,
12+
.link_libc = true,
13+
.single_threaded = true,
14+
.strip = optimize != .Debug,
1215
});
13-
exe.linkLibC();
1416
b.installArtifact(exe);
1517

16-
exe.single_threaded = true;
17-
18-
if (optimize != .Debug) {
19-
exe.strip = true;
20-
}
21-
2218
const run_cmd = b.addRunArtifact(exe);
2319
run_cmd.step.dependOn(b.getInstallStep());
2420
if (b.args) |args| {
@@ -29,7 +25,7 @@ pub fn build(b: *Builder) void {
2925
run_step.dependOn(&run_cmd.step);
3026

3127
const unit_tests = b.addTest(.{
32-
.root_source_file = .{ .path = "src/main.zig" },
28+
.root_source_file = b.path("src/main.zig"),
3329
.target = target,
3430
.optimize = optimize,
3531
});

src/main.zig

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test "pathWithExtension" {
4343
try std.testing.expectEqualStrings("mem.exe", example);
4444
}
4545

46-
pub fn main() anyerror!void {
46+
pub fn main() !void {
4747
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
4848
defer arena.deinit();
4949
const allocator = arena.allocator();
@@ -67,7 +67,7 @@ pub fn main() anyerror!void {
6767
var buffered_reader = std.io.bufferedReader(shim_file.reader());
6868
const reader = buffered_reader.reader();
6969

70-
try readShim(reader, &cfg);
70+
try readShim(reader.any(), &cfg);
7171
}
7272

7373
// Arguments sent to the child process
@@ -109,7 +109,7 @@ const whitespace_with_quotes = std.ascii.whitespace ++ .{'"'};
109109
///
110110
/// The file is (usually) multiple key-value pairs separated by a single '=', and
111111
/// must contain at least a "path", although this is up to the caller to uphold.
112-
fn readShim(reader: anytype, into: *std.BufMap) !void {
112+
fn readShim(reader: std.io.AnyReader, into: *std.BufMap) !void {
113113
// Go through the shim file and collect key-value pairs
114114
var line_buf: [1024]u8 = undefined;
115115
while (try reader.readUntilDelimiterOrEof(&line_buf, '\n')) |line| {
@@ -131,7 +131,7 @@ test "parsing valid shim" {
131131
var cfg = std.BufMap.init(std.testing.allocator);
132132
defer cfg.deinit();
133133

134-
_ = try readShim(reader, &cfg);
134+
_ = try readShim(reader.any(), &cfg);
135135

136136
try std.testing.expectEqualStrings("C:/Program Files/Git/cmd/git.exe", cfg.get("path") orelse "");
137137
try std.testing.expectEqualStrings("status", cfg.get("args") orelse "");
@@ -147,7 +147,7 @@ test "parsing valid shim (new style)" {
147147
var cfg = std.BufMap.init(std.testing.allocator);
148148
defer cfg.deinit();
149149

150-
_ = try readShim(reader, &cfg);
150+
_ = try readShim(reader.any(), &cfg);
151151

152152
try std.testing.expectEqualStrings("C:\\Program Files\\Git\\cmd\\git.exe", cfg.get("path") orelse "");
153153
try std.testing.expectEqualStrings("status", cfg.get("args") orelse "");

0 commit comments

Comments
 (0)