-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.zig
More file actions
77 lines (66 loc) · 1.81 KB
/
build.zig
File metadata and controls
77 lines (66 loc) · 1.81 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
65
66
67
68
69
70
71
72
73
74
75
76
77
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const strip = optimize == .ReleaseFast or optimize == .ReleaseSmall;
const engine = b.addModule("engine", .{
.root_source_file = b.path("src/engine/main.zig"),
});
const main_exe = b.addExecutable(.{
.name = "2048",
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli/main.zig"),
.target = target,
.optimize = optimize,
.strip = strip,
.imports = &.{
.{
.name = "engine",
.module = engine,
},
},
}),
});
b.installArtifact(main_exe);
const main_cmd = b.addRunArtifact(main_exe);
main_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
main_cmd.addArgs(args);
}
const main_run = b.step("run", "Run the main application");
main_run.dependOn(&main_cmd.step);
const wasm_target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
.cpu_features_add = std.Target.wasm.featureSet(&.{
.atomics,
.bulk_memory,
.extended_const,
.multivalue,
.nontrapping_fptoint,
.sign_ext,
.simd128,
.tail_call,
}),
});
const wasm_main = b.addExecutable(.{
.name = "main",
.root_module = b.createModule(.{
.root_source_file = b.path("src/wasm/main.zig"),
.target = wasm_target,
.optimize = optimize,
.strip = strip,
.imports = &.{
.{
.name = "engine",
.module = engine,
},
},
}),
});
wasm_main.rdynamic = true;
wasm_main.entry = .disabled;
const bin = wasm_main.getEmittedBin();
const artifact = b.addInstallFile(bin, "main.wasm");
b.getInstallStep().dependOn(&artifact.step);
}