-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
44 lines (35 loc) · 1.28 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const exe = b.addExecutable(.{
.name = "zraysm",
.root_source_file = b.path("src/main.zig"),
.target = target,
});
// Link with raylib/libraylib.a
// We are expecting the header and the library into raylib/
exe.linkLibC();
exe.addObjectFile(b.path("raylib/libraylib.a"));
exe.addIncludePath(b.path("raylib"));
// Link with wasmer
exe.addObjectFile(b.path("wasmer/lib/libwasmer.so"));
exe.addIncludePath(b.path("wasmer/include"));
// Also build and link with our own library
exe.addIncludePath(b.path("src/c"));
exe.addCSourceFiles(.{
.root = b.path("src/c"),
.files = &[_][]const u8{"foo.c"},
.flags = &[_][]const u8{},
});
// Now build
b.installArtifact(exe);
// Create the run step
const run_cmd = b.addRunArtifact(exe);
// Run depends of the install step
run_cmd.step.dependOn(b.getInstallStep());
run_cmd.setEnvironmentVariable("LD_LIBRARY_PATH", "./wasmer/lib/");
run_cmd.addArg("./src/wat/gcd.wat");
const run_step = b.step("run", "Run zayasm using ./src/wat/gdc.wat");
run_step.dependOn(&run_cmd.step);
// TODO: add a test step, ...
}