forked from mitchellh/zig-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
47 lines (40 loc) · 1.45 KB
/
build.zig
File metadata and controls
47 lines (40 loc) · 1.45 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
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const zig_js_module = b.addModule("zig-js", .{ .root_source_file = .{ .path = "src/main.zig" } });
const test_exe = b.addTest(.{
.name = "js-test",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
b.installArtifact(test_exe);
const test_step = b.step("test", "Run tests");
const tests_run = b.addRunArtifact(test_exe);
test_step.dependOn(&tests_run.step);
// Example
{
const wasm = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "example/main.zig" },
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.optimize = optimize,
});
wasm.root_module.addImport("zig-js", zig_js_module);
wasm.entry = .disabled;
wasm.export_memory = true;
// custom's path is relative to zig-out
const wasm_install = b.addInstallFileWithDir(
wasm.getEmittedBin(),
.{ .custom = "../example" },
"example.wasm",
);
const step = b.step("example", "Build the example project (Zig only)");
step.dependOn(&wasm_install.step);
}
}