fn create_wasm(b: *Build, mode: std.builtin.OptimizeMode, name: []const u8, source: []const u8) !void {
const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
const exe = b.addExecutable(.{
.name = name,
.optimize = mode,
.target = target,
.root_source_file = b.path(source),
});
exe.rdynamic = true;
b.dest_dir = "bin/";
// modules
{
const moduleDawn = b.addModule("dawn", .{ .root_source_file = b.path("src/dawn/dawn.zig") });
const moduleRT = b.addModule("rt", .{ .root_source_file = b.path("src/rt/rt.zig"), });
moduleDawn.addImport("rt", moduleRT);
exe.root_module.addImport("rt", moduleRT);
exe.root_module.addImport("dawn", moduleDawn);
moduleDawn.addIncludePath( .{ .cwd_relative = "/usr/include" });
moduleDawn.addLibraryPath( .{ .cwd_relative = "/usr/lib" });
}
// c depndencies
exe.addIncludePath(b.path("src/c/nuklear/"));
exe.addIncludePath(b.path("src/c/stb/"));
exe.addCSourceFile(.{ .file = b.path("src/c/nuklear/nuklear.c"), .flags = &.{ "-std=c11", "-Wl,--allow-multiple-definition" } });
const compile_step = b.step(name, b.fmt("Build {s}", .{name}));
compile_step.dependOn(&exe.step);
b.installArtifact(exe);
b.getInstallStep().dependOn(&exe.step);
}
it should go to bin/, why it doesn't work?
$ find . | grep ".wasm"
./.zig-cache/o/bcde2c35f5e134430c659b912db9936e/game-wasm.wasm.o
./.zig-cache/o/bcde2c35f5e134430c659b912db9936e/game-wasm.wasm
./.zig-cache/o/1c86ded577468bd945cdd2a8681075a0/game-wasm.wasm.o
./.zig-cache/o/1c86ded577468bd945cdd2a8681075a0/game-wasm.wasm
./src/dawn/gfx/wasm.zig
./src/main_wasm.zig