zig/test/c_abi/build_wasm.zig
2022-07-26 14:51:45 -07:00

25 lines
733 B
Zig

const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const rel_opts = b.standardReleaseOptions();
const target: std.zig.CrossTarget = .{ .cpu_arch = .wasm32, .os_tag = .wasi };
b.use_stage1 = false;
const c_obj = b.addObject("cfuncs", null);
c_obj.addCSourceFile("cfuncs.c", &[_][]const u8{"-std=c99"});
c_obj.setBuildMode(rel_opts);
c_obj.linkSystemLibrary("c");
c_obj.setTarget(target);
const main = b.addTest("main.zig");
main.setBuildMode(rel_opts);
main.addObject(c_obj);
main.setTarget(target);
const test_step = b.step("test", "Test the program");
test_step.dependOn(&main.step);
b.default_step.dependOn(test_step);
}