diff options
author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2023-02-15 22:55:44 +0100 |
---|---|---|
committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2023-02-15 22:55:44 +0100 |
commit | 4cf3bd63a22bd2f88c1f04cddac31aa19bc78a9d (patch) | |
tree | 49101dd8b9e9aa171ea3b9ba5f45c3c31d2237f6 /build.zig | |
parent | 0f42850f7e17463e9d8ccc21da0516d288eed6d7 (diff) |
added the first C exercise
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -31,6 +31,10 @@ const Exercise = struct { /// We need to keep track of this, so we compile without the self hosted compiler @"async": bool = false, + /// This exercise makes use of C functions + /// We need to keep track of this, so we compile with libc + C: bool = false, + /// Returns the name of the main file with .zig stripped. pub fn baseName(self: Exercise) []const u8 { assert(std.mem.endsWith(u8, self.main_file, ".zig")); @@ -462,6 +466,11 @@ const exercises = [_]Exercise{ // .@"async" = true, // }, .{ + .main_file = "093_hello_c.zig", + .output = "Hello C from Zig! - C result ist 17 chars", + .C = true, + }, + .{ .main_file = "999_the_end.zig", .output = "\nThis is the end for now!\nWe hope you had fun and were able to learn a lot, so visit us again when the next exercises are available.", }, @@ -725,6 +734,11 @@ const ZiglingStep = struct { // zig_args.append("-fstage1") catch unreachable; // } + // Enable C support for exercises that use C functions + if (self.exercise.C) { + zig_args.append("-lc") catch unreachable; + } + if (builder.color != .auto) { zig_args.append("--color") catch unreachable; zig_args.append(@tagName(builder.color)) catch unreachable; |