Browse Source

build: ensure the exercise links libc, when needed

When running, as an example, `zig build -Dhealed -Dn=93 test`, the build
fails, because the `test` step use the standard CompileStep, instead of
ZiglingStep.

Ensure that exercises using libc are correctly built.

Closes #229
Manlio Perillo 2 years ago
parent
commit
67f369484c
1 changed files with 3 additions and 0 deletions
  1. 3 0
      build.zig

+ 3 - 0
build.zig

@@ -560,6 +560,9 @@ pub fn build(b: *Build) !void {
         }) catch unreachable;
         }) catch unreachable;
 
 
         const build_step = b.addExecutable(.{ .name = base_name, .root_source_file = .{ .path = file_path } });
         const build_step = b.addExecutable(.{ .name = base_name, .root_source_file = .{ .path = file_path } });
+        if (ex.C) {
+            build_step.linkLibC();
+        }
         build_step.install();
         build_step.install();
 
 
         const run_step = build_step.run();
         const run_step = build_step.run();