-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
40 lines (34 loc) · 1.25 KB
/
Copy pathbuild.zig
File metadata and controls
40 lines (34 loc) · 1.25 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
const std = @import("std");
pub fn build(builder: *std.Build) void {
const target = builder.resolveTargetQuery(.{
.cpu_arch = .x86_64,
.os_tag = .uefi,
.cpu_features_sub = std.Target.x86.featureSet(&.{ .mmx, .sse, .sse2, .sse3, .ssse3, .sse4_1, .sse4_2, .avx, .avx2, .avx512f }),
});
const optimize = builder.standardOptimizeOption(.{});
const exe = builder.addExecutable(.{
.name = "bootx64",
.root_module = builder.createModule(.{
.root_source_file = builder.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
builder.installArtifact(exe);
const run_step = builder.step("run", "Run in QEMU");
const qemu = builder.addSystemCommand(&.{"qemu-system-x86_64"});
const disk = builder.addWriteFiles();
const boot_file = disk.addCopyFile(exe.getEmittedBin(), "EFI/BOOT/BOOTX64.EFI");
qemu.stdio = .inherit;
qemu.addArgs(&.{
"-serial",
"stdio",
"-m",
"2G",
"-drive",
"if=pflash,format=raw,readonly=on,file=ovmf.fd",
"-drive",
});
qemu.addPrefixedDirectoryArg("format=raw,file=fat:rw:", boot_file.dirname().dirname().dirname());
run_step.dependOn(&qemu.step);
}