-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
64 lines (54 loc) · 2.3 KB
/
build.zig
File metadata and controls
64 lines (54 loc) · 2.3 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const std = @import("std");
const bridge = @import("zig/gain/_bridge.zig");
pub fn build(b: *std.Build) void {
// enable -fwasmtime for running tests
b.enable_wasmtime = true;
const optimize = b.standardOptimizeOption(.{
.preferred_optimize_mode = std.builtin.OptimizeMode.ReleaseSmall,
});
std.log.info("Optimize mode => {}", .{optimize});
const exe = b.addExecutable(.{
.name = "main",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("zig/main.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.optimize = optimize,
.link_libc = false,
.strip = optimize != .Debug,
.single_threaded = true,
});
exe.initial_memory = 65536 * 256 * 4;
exe.stack_size = 65536 * 16;
exe.entry = .disabled;
exe.root_module.export_symbol_names = &bridge.identifiers;
// zig build-exe main.zig -target wasm32-freestanding --export=update -fno-entry -OReleaseSmall
b.installArtifact(exe);
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = b.path("zig/main.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
}),
.optimize = optimize,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
run_unit_tests.setEnvironmentVariable("WASMTIME_BACKTRACE_DETAILS", "1");
run_unit_tests.setEnvironmentVariable("WASMTIME_NEW_CLI", "0");
run_unit_tests.has_side_effects = true;
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
const unit_tests_native = b.addTest(.{
.root_source_file = b.path("zig/main.zig"),
.optimize = optimize,
});
const run_unit_tests_native = b.addRunArtifact(unit_tests_native);
run_unit_tests_native.has_side_effects = true;
const test_native_step = b.step("test-native", "Run unit tests using native target");
test_native_step.dependOn(&run_unit_tests_native.step);
}