diff --git a/compiled_starters/zig/README.md b/compiled_starters/zig/README.md index b59e991..202fce2 100644 --- a/compiled_starters/zig/README.md +++ b/compiled_starters/zig/README.md @@ -30,7 +30,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `zig (0.14)` installed locally +1. Ensure you have `zig (0.15)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `src/main.zig`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/compiled_starters/zig/build.zig b/compiled_starters/zig/build.zig index d211b57..0eccf2a 100644 --- a/compiled_starters/zig/build.zig +++ b/compiled_starters/zig/build.zig @@ -4,9 +4,10 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "main", - .root_source_file = b.path("src/main.zig"), - .target = b.standardTargetOptions(.{}), - .optimize = b.standardOptimizeOption(.{}), + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = b.graph.host, + }), }); // This declares intent for the executable to be installed into the diff --git a/compiled_starters/zig/build.zig.zon b/compiled_starters/zig/build.zig.zon index e424a22..fadb223 100644 --- a/compiled_starters/zig/build.zig.zon +++ b/compiled_starters/zig/build.zig.zon @@ -9,7 +9,7 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.14.0", + .minimum_zig_version = "0.15.1", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/compiled_starters/zig/src/main.zig b/compiled_starters/zig/src/main.zig index 5e420bc..0e9e05c 100644 --- a/compiled_starters/zig/src/main.zig +++ b/compiled_starters/zig/src/main.zig @@ -2,10 +2,8 @@ const std = @import("std"); const net = std.net; pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - // You can use print statements as follows for debugging, they'll be visible when running tests. - try stdout.print("Logs from your program will appear here!\n", .{}); + std.debug.print("Logs from your program will appear here!\n", .{}); // Uncomment this block to pass the first stage // const address = try net.Address.resolveIp("127.0.0.1", 4221); @@ -15,5 +13,5 @@ pub fn main() !void { // defer listener.deinit(); // // _ = try listener.accept(); - // try stdout.print("client connected!", .{}); + // std.debug.print("client connected!", .{}); } diff --git a/solutions/zig/01-at4/code/README.md b/solutions/zig/01-at4/code/README.md index b59e991..202fce2 100644 --- a/solutions/zig/01-at4/code/README.md +++ b/solutions/zig/01-at4/code/README.md @@ -30,7 +30,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `zig (0.14)` installed locally +1. Ensure you have `zig (0.15)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `src/main.zig`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/solutions/zig/01-at4/code/build.zig b/solutions/zig/01-at4/code/build.zig index d211b57..0eccf2a 100644 --- a/solutions/zig/01-at4/code/build.zig +++ b/solutions/zig/01-at4/code/build.zig @@ -4,9 +4,10 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "main", - .root_source_file = b.path("src/main.zig"), - .target = b.standardTargetOptions(.{}), - .optimize = b.standardOptimizeOption(.{}), + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = b.graph.host, + }), }); // This declares intent for the executable to be installed into the diff --git a/solutions/zig/01-at4/code/build.zig.zon b/solutions/zig/01-at4/code/build.zig.zon index e424a22..fadb223 100644 --- a/solutions/zig/01-at4/code/build.zig.zon +++ b/solutions/zig/01-at4/code/build.zig.zon @@ -9,7 +9,7 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.14.0", + .minimum_zig_version = "0.15.1", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/solutions/zig/01-at4/code/src/main.zig b/solutions/zig/01-at4/code/src/main.zig index 9a6af99..ae3159e 100644 --- a/solutions/zig/01-at4/code/src/main.zig +++ b/solutions/zig/01-at4/code/src/main.zig @@ -2,8 +2,6 @@ const std = @import("std"); const net = std.net; pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - const address = try net.Address.resolveIp("127.0.0.1", 4221); var listener = try address.listen(.{ .reuse_address = true, @@ -11,5 +9,5 @@ pub fn main() !void { defer listener.deinit(); _ = try listener.accept(); - try stdout.print("client connected!", .{}); + std.debug.print("client connected!", .{}); } diff --git a/solutions/zig/01-at4/diff/src/main.zig.diff b/solutions/zig/01-at4/diff/src/main.zig.diff index 6b8bfd4..c587eee 100644 --- a/solutions/zig/01-at4/diff/src/main.zig.diff +++ b/solutions/zig/01-at4/diff/src/main.zig.diff @@ -1,12 +1,10 @@ -@@ -1,19 +1,15 @@ +@@ -1,17 +1,13 @@ const std = @import("std"); const net = std.net; pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - - // You can use print statements as follows for debugging, they'll be visible when running tests. -- try stdout.print("Logs from your program will appear here!\n", .{}); +- std.debug.print("Logs from your program will appear here!\n", .{}); + const address = try net.Address.resolveIp("127.0.0.1", 4221); + var listener = try address.listen(.{ + .reuse_address = true, @@ -21,7 +19,7 @@ - // defer listener.deinit(); - // - // _ = try listener.accept(); -- // try stdout.print("client connected!", .{}); +- // std.debug.print("client connected!", .{}); + _ = try listener.accept(); -+ try stdout.print("client connected!", .{}); ++ std.debug.print("client connected!", .{}); } diff --git a/solutions/zig/01-at4/explanation.md b/solutions/zig/01-at4/explanation.md index 1069a40..66477e4 100644 --- a/solutions/zig/01-at4/explanation.md +++ b/solutions/zig/01-at4/explanation.md @@ -11,7 +11,7 @@ var listener = try address.listen(.{ defer listener.deinit(); _ = try listener.accept(); -try stdout.print("client connected!", .{}); +std.debug.print("client connected!", .{}); ``` Push your changes to pass the first stage: diff --git a/starter_templates/zig/code/build.zig b/starter_templates/zig/code/build.zig index d211b57..0eccf2a 100644 --- a/starter_templates/zig/code/build.zig +++ b/starter_templates/zig/code/build.zig @@ -4,9 +4,10 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "main", - .root_source_file = b.path("src/main.zig"), - .target = b.standardTargetOptions(.{}), - .optimize = b.standardOptimizeOption(.{}), + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = b.graph.host, + }), }); // This declares intent for the executable to be installed into the diff --git a/starter_templates/zig/code/build.zig.zon b/starter_templates/zig/code/build.zig.zon index e424a22..fadb223 100644 --- a/starter_templates/zig/code/build.zig.zon +++ b/starter_templates/zig/code/build.zig.zon @@ -9,7 +9,7 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.14.0", + .minimum_zig_version = "0.15.1", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/starter_templates/zig/code/src/main.zig b/starter_templates/zig/code/src/main.zig index 5e420bc..0e9e05c 100644 --- a/starter_templates/zig/code/src/main.zig +++ b/starter_templates/zig/code/src/main.zig @@ -2,10 +2,8 @@ const std = @import("std"); const net = std.net; pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - // You can use print statements as follows for debugging, they'll be visible when running tests. - try stdout.print("Logs from your program will appear here!\n", .{}); + std.debug.print("Logs from your program will appear here!\n", .{}); // Uncomment this block to pass the first stage // const address = try net.Address.resolveIp("127.0.0.1", 4221); @@ -15,5 +13,5 @@ pub fn main() !void { // defer listener.deinit(); // // _ = try listener.accept(); - // try stdout.print("client connected!", .{}); + // std.debug.print("client connected!", .{}); } diff --git a/starter_templates/zig/config.yml b/starter_templates/zig/config.yml index a113b98..fda894a 100644 --- a/starter_templates/zig/config.yml +++ b/starter_templates/zig/config.yml @@ -1,3 +1,3 @@ attributes: - required_executable: zig (0.14) + required_executable: zig (0.15) user_editable_file: src/main.zig