-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.zig
51 lines (44 loc) · 1.63 KB
/
build.zig
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
const std = @import("std");
const build_capy = @import("capy");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const capy_dep = b.dependency("capy", .{
.target = target,
.optimize = optimize,
.app_name = @as([]const u8, "capy-template"),
});
const capy = capy_dep.module("capy");
const exe = b.addExecutable(.{
.name = "capy-template",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("capy", capy);
b.installArtifact(exe);
const run_cmd = try build_capy.runStep(exe, .{ .args = b.args });
const run_step = b.step("run", "Run the app");
run_step.dependOn(run_cmd);
// Building for WebAssembly
@setEvalBranchQuota(5000);
const wasm = b.addExecutable(.{
.name = "capy-template",
.root_source_file = b.path("src/main.zig"),
.target = b.resolveTargetQuery(
comptime std.Target.Query.parse(.{ .arch_os_abi = "wasm32-wasi" }) catch unreachable,
),
.optimize = optimize,
});
wasm.root_module.addImport("capy", capy);
const serve = try build_capy.runStep(wasm, .{});
const serve_step = b.step("serve", "Start a local web server to run this application");
serve_step.dependOn(serve);
const exe_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step);
}