-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
35 lines (29 loc) · 1.15 KB
/
build.zig
File metadata and controls
35 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const std = @import("std");
pub fn build(b: *std.Build) void {
// We need to define target
// For the CPU system, we'll use WASM32
// And we need a freestanding binary, which is given in the os_tag
const target = b.standardTargetOptions(.{
.default_target = .{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
},
});
// Big file sizes are unacceptable in Web Development,
// and OptimizeMode = ReleaseSmall just fixes that
// You can try out different optimize modes to see different results
const optimize: std.builtin.OptimizeMode = .ReleaseSmall;
const exe = b.addExecutable(.{
.name = "zig-wasm",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
// rdynamic is used for building all functions that have
// export keyword. For example: export fn add(...
exe.rdynamic = true;
// Not defining entry as disabled gives error on build, I'm not a Zig build system expert :)
// But maybe you can give me the reason, then I'll merge that for sure!
exe.entry = .disabled;
b.installArtifact(exe);
}