This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
49 lines (40 loc) · 1.5 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
const std = @import("std");
const Builder = std.build.Builder;
const deps = @import("./deps.zig");
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const native = b.addExecutable("2021-7drl", "src/main.zig");
native.setTarget(target);
native.setBuildMode(mode);
native.install();
native.linkLibC();
native.linkSystemLibrary("SDL2");
deps.addAllTo(native);
b.step("native", "Build native binary").dependOn(&native.step);
const native_run = native.run();
// Start the program in the directory with the assets in it
native_run.cwd = "static";
const native_run_step = b.step("run", "Run the native binary");
native_run_step.dependOn(&native_run.step);
const web = b.addStaticLibrary("2021-7drl-web", "src/main.zig");
web.setBuildMode(mode);
web.setOutputDir(b.fmt("{s}/www", .{b.install_prefix}));
web.setTarget(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
});
deps.addAllTo(web);
const static = b.addInstallDirectory(.{
.source_dir = "static",
.install_dir = .Prefix,
.install_subdir = "www",
});
const build_web = b.step("web", "Build WASM application");
build_web.dependOn(&web.step);
build_web.dependOn(&static.step);
var main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
}