-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
59 lines (53 loc) · 1.83 KB
/
build.zig
File metadata and controls
59 lines (53 loc) · 1.83 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
const std = @import("std");
const Builder = std.build.Builder;
const CrossTarget = std.zig.CrossTarget;
const log_options = [_][]const u8{
"vm", "sched", "clint", "plic", "heap", "rupt", "uart", "notify",
};
pub fn build(b: *Builder) !void {
const exe = b.addExecutable("Folly", "src/main.zig");
exe.setTarget(try CrossTarget.parse(.{
.arch_os_abi = "riscv64-freestanding",
}));
exe.code_model = .medium;
exe.setLinkerScriptPath("linker.ld");
exe.setBuildMode(.Debug);
exe.install();
const log_all = b.option(bool, "log-all", "Spam logging for all of the following to UART. Beware.") orelse false;
inline for (log_options) |opt| {
exe.addBuildOption(
bool,
"log_" ++ opt,
b.option(bool, "log-" ++ opt, "Spam logging for this particular thing to UART") orelse log_all,
);
}
const run = b.addSystemCommand(&[_][]const u8{
blk: {
if (b.env_map.get("QEMU_EXE")) |path| {
if (std.mem.endsWith(u8, path, "qemu-system-riscv64")) break :blk path;
}
std.debug.warn("Please specify the path to `qemu-system-riscv64` in the environment variable QEMU_EXE.\n", .{});
return error.MissingQEMU;
},
"-kernel",
});
run.addArtifactArg(exe);
run.addArgs(&qemu_args);
const i_dont_know_what_im_doing_help = b.step("run", "Build and launch Folly in QEMU");
i_dont_know_what_im_doing_help.dependOn(&run.step);
}
// zig fmt: off
const qemu_args = [_][]const u8{
"-machine", "virt",
"-cpu", "rv64",
"-smp", "4",
"-m", "512M",
"-nographic",
"-serial", "mon:stdio",
"-bios", "none",
"-drive", "if=none,format=raw,file=hdd.img,id=foo",
"-device", "virtio-blk-device,scsi=off,drive=foo",
"-no-reboot",
"-no-shutdown",
};
// zig fmt: on