Skip to content

Commit a5eb28b

Browse files
authored
Merge pull request #135 from codecrafters-io/andy/upgrade-zig
[http] CC-1935: Upgrade Zig to v0.15
2 parents 1789386 + 1f62a7b commit a5eb28b

File tree

14 files changed

+28
-33
lines changed

14 files changed

+28
-33
lines changed

compiled_starters/zig/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Time to move on to the next stage!
3030

3131
Note: This section is for stages 2 and beyond.
3232

33-
1. Ensure you have `zig (0.14)` installed locally
33+
1. Ensure you have `zig (0.15)` installed locally
3434
1. Run `./your_program.sh` to run your program, which is implemented in
3535
`src/main.zig`.
3636
1. Commit your changes and run `git push origin master` to submit your solution

compiled_starters/zig/build.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const std = @import("std");
44
pub fn build(b: *std.Build) void {
55
const exe = b.addExecutable(.{
66
.name = "main",
7-
.root_source_file = b.path("src/main.zig"),
8-
.target = b.standardTargetOptions(.{}),
9-
.optimize = b.standardOptimizeOption(.{}),
7+
.root_module = b.createModule(.{
8+
.root_source_file = b.path("src/main.zig"),
9+
.target = b.graph.host,
10+
}),
1011
});
1112

1213
// This declares intent for the executable to be installed into the

compiled_starters/zig/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// This field is optional.
1010
// This is currently advisory only; Zig does not yet do anything
1111
// with this value.
12-
.minimum_zig_version = "0.14.0",
12+
.minimum_zig_version = "0.15.1",
1313

1414
// This field is optional.
1515
// Each dependency must either provide a `url` and `hash`, or a `path`.

compiled_starters/zig/src/main.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ const std = @import("std");
22
const net = std.net;
33

44
pub fn main() !void {
5-
const stdout = std.io.getStdOut().writer();
6-
75
// You can use print statements as follows for debugging, they'll be visible when running tests.
8-
try stdout.print("Logs from your program will appear here!\n", .{});
6+
std.debug.print("Logs from your program will appear here!\n", .{});
97

108
// Uncomment this block to pass the first stage
119
// const address = try net.Address.resolveIp("127.0.0.1", 4221);
@@ -15,5 +13,5 @@ pub fn main() !void {
1513
// defer listener.deinit();
1614
//
1715
// _ = try listener.accept();
18-
// try stdout.print("client connected!", .{});
16+
// std.debug.print("client connected!", .{});
1917
}

solutions/zig/01-at4/code/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Time to move on to the next stage!
3030

3131
Note: This section is for stages 2 and beyond.
3232

33-
1. Ensure you have `zig (0.14)` installed locally
33+
1. Ensure you have `zig (0.15)` installed locally
3434
1. Run `./your_program.sh` to run your program, which is implemented in
3535
`src/main.zig`.
3636
1. Commit your changes and run `git push origin master` to submit your solution

solutions/zig/01-at4/code/build.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const std = @import("std");
44
pub fn build(b: *std.Build) void {
55
const exe = b.addExecutable(.{
66
.name = "main",
7-
.root_source_file = b.path("src/main.zig"),
8-
.target = b.standardTargetOptions(.{}),
9-
.optimize = b.standardOptimizeOption(.{}),
7+
.root_module = b.createModule(.{
8+
.root_source_file = b.path("src/main.zig"),
9+
.target = b.graph.host,
10+
}),
1011
});
1112

1213
// This declares intent for the executable to be installed into the

solutions/zig/01-at4/code/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// This field is optional.
1010
// This is currently advisory only; Zig does not yet do anything
1111
// with this value.
12-
.minimum_zig_version = "0.14.0",
12+
.minimum_zig_version = "0.15.1",
1313

1414
// This field is optional.
1515
// Each dependency must either provide a `url` and `hash`, or a `path`.

solutions/zig/01-at4/code/src/main.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ const std = @import("std");
22
const net = std.net;
33

44
pub fn main() !void {
5-
const stdout = std.io.getStdOut().writer();
6-
75
const address = try net.Address.resolveIp("127.0.0.1", 4221);
86
var listener = try address.listen(.{
97
.reuse_address = true,
108
});
119
defer listener.deinit();
1210

1311
_ = try listener.accept();
14-
try stdout.print("client connected!", .{});
12+
std.debug.print("client connected!", .{});
1513
}

solutions/zig/01-at4/diff/src/main.zig.diff

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
@@ -1,19 +1,15 @@
1+
@@ -1,17 +1,13 @@
22
const std = @import("std");
33
const net = std.net;
44

55
pub fn main() !void {
6-
const stdout = std.io.getStdOut().writer();
7-
86
- // You can use print statements as follows for debugging, they'll be visible when running tests.
9-
- try stdout.print("Logs from your program will appear here!\n", .{});
7+
- std.debug.print("Logs from your program will appear here!\n", .{});
108
+ const address = try net.Address.resolveIp("127.0.0.1", 4221);
119
+ var listener = try address.listen(.{
1210
+ .reuse_address = true,
@@ -21,7 +19,7 @@
2119
- // defer listener.deinit();
2220
- //
2321
- // _ = try listener.accept();
24-
- // try stdout.print("client connected!", .{});
22+
- // std.debug.print("client connected!", .{});
2523
+ _ = try listener.accept();
26-
+ try stdout.print("client connected!", .{});
24+
+ std.debug.print("client connected!", .{});
2725
}

solutions/zig/01-at4/explanation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var listener = try address.listen(.{
1111
defer listener.deinit();
1212
1313
_ = try listener.accept();
14-
try stdout.print("client connected!", .{});
14+
std.debug.print("client connected!", .{});
1515
```
1616

1717
Push your changes to pass the first stage:

0 commit comments

Comments
 (0)