master
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const test_step = b.step("test", "Test it");
5 b.default_step = test_step;
6
7 add(b, test_step, .Debug);
8}
9
10fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
11 const exe = b.addExecutable(.{
12 .name = "extern",
13 .root_module = b.createModule(.{
14 .root_source_file = b.path("main.zig"),
15 .optimize = optimize,
16 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi }),
17 }),
18 });
19 exe.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
20 exe.use_llvm = false;
21 exe.use_lld = false;
22
23 const run = b.addRunArtifact(exe);
24 run.skip_foreign_checks = true;
25 run.expectStdOutEqual("Result: 30");
26
27 test_step.dependOn(&run.step);
28}