Update code to work with zig master
This commit is contained in:
parent
4b870d3a65
commit
91b2a61acf
26 changed files with 476 additions and 438 deletions
40
build.zig
40
build.zig
|
@ -27,38 +27,38 @@ pub fn build(b: *Builder) !void {
|
|||
const main_src = "src/kernel/kmain.zig";
|
||||
|
||||
const exec = b.addExecutable("pluto", main_src);
|
||||
const constants_path = try fs.path.join(b.allocator, [_][]const u8{ "src/kernel/arch", target_str, "constants.zig" });
|
||||
const constants_path = try fs.path.join(b.allocator, &[_][]const u8{ "src/kernel/arch", target_str, "constants.zig" });
|
||||
exec.addPackagePath("constants", constants_path);
|
||||
exec.setBuildMode(build_mode);
|
||||
exec.addBuildOption(bool, "rt_test", rt_test);
|
||||
exec.setLinkerScriptPath("link.ld");
|
||||
exec.setTheTarget(target);
|
||||
|
||||
const iso_path = try fs.path.join(b.allocator, [_][]const u8{ b.exe_dir, "pluto.iso" });
|
||||
const grub_build_path = try fs.path.join(b.allocator, [_][]const u8{ b.exe_dir, "iso", "boot" });
|
||||
const iso_dir_path = try fs.path.join(b.allocator, [_][]const u8{ b.exe_dir, "iso" });
|
||||
const iso_path = try fs.path.join(b.allocator, &[_][]const u8{ b.exe_dir, "pluto.iso" });
|
||||
const grub_build_path = try fs.path.join(b.allocator, &[_][]const u8{ b.exe_dir, "iso", "boot" });
|
||||
const iso_dir_path = try fs.path.join(b.allocator, &[_][]const u8{ b.exe_dir, "iso" });
|
||||
|
||||
const mkdir_cmd = b.addSystemCommand([_][]const u8{ "mkdir", "-p", fs.path.dirname(grub_build_path).? });
|
||||
const mkdir_cmd = b.addSystemCommand(&[_][]const u8{ "mkdir", "-p", fs.path.dirname(grub_build_path).? });
|
||||
|
||||
const grub_cmd = b.addSystemCommand([_][]const u8{ "cp", "-r", "grub", grub_build_path });
|
||||
const grub_cmd = b.addSystemCommand(&[_][]const u8{ "cp", "-r", "grub", grub_build_path });
|
||||
grub_cmd.step.dependOn(&mkdir_cmd.step);
|
||||
|
||||
const cp_elf_cmd = b.addSystemCommand([_][]const u8{"cp"});
|
||||
const elf_path = try fs.path.join(b.allocator, [_][]const u8{ grub_build_path, "pluto.elf" });
|
||||
const cp_elf_cmd = b.addSystemCommand(&[_][]const u8{"cp"});
|
||||
const elf_path = try fs.path.join(b.allocator, &[_][]const u8{ grub_build_path, "pluto.elf" });
|
||||
cp_elf_cmd.addArtifactArg(exec);
|
||||
cp_elf_cmd.addArg(elf_path);
|
||||
cp_elf_cmd.step.dependOn(&grub_cmd.step);
|
||||
cp_elf_cmd.step.dependOn(&exec.step);
|
||||
|
||||
const modules_path = try fs.path.join(b.allocator, [_][]const u8{ b.exe_dir, "iso", "modules" });
|
||||
const mkdir_modules_cmd = b.addSystemCommand([_][]const u8{ "mkdir", "-p", modules_path });
|
||||
const modules_path = try fs.path.join(b.allocator, &[_][]const u8{ b.exe_dir, "iso", "modules" });
|
||||
const mkdir_modules_cmd = b.addSystemCommand(&[_][]const u8{ "mkdir", "-p", modules_path });
|
||||
|
||||
const map_file_path = try fs.path.join(b.allocator, [_][]const u8{ modules_path, "kernel.map" });
|
||||
const map_file_cmd = b.addSystemCommand([_][]const u8{ "./make_map.sh", elf_path, map_file_path });
|
||||
const map_file_path = try fs.path.join(b.allocator, &[_][]const u8{ modules_path, "kernel.map" });
|
||||
const map_file_cmd = b.addSystemCommand(&[_][]const u8{ "./make_map.sh", elf_path, map_file_path });
|
||||
map_file_cmd.step.dependOn(&cp_elf_cmd.step);
|
||||
map_file_cmd.step.dependOn(&mkdir_modules_cmd.step);
|
||||
|
||||
const iso_cmd = b.addSystemCommand([_][]const u8{ "grub-mkrescue", "-o", iso_path, iso_dir_path });
|
||||
const iso_cmd = b.addSystemCommand(&[_][]const u8{ "grub-mkrescue", "-o", iso_path, iso_dir_path });
|
||||
iso_cmd.step.dependOn(&map_file_cmd.step);
|
||||
b.default_step.dependOn(&iso_cmd.step);
|
||||
|
||||
|
@ -69,7 +69,7 @@ pub fn build(b: *Builder) !void {
|
|||
.i386 => "qemu-system-i386",
|
||||
else => unreachable,
|
||||
};
|
||||
const qemu_args = [_][]const u8{
|
||||
const qemu_args = &[_][]const u8{
|
||||
qemu_bin,
|
||||
"-cdrom",
|
||||
iso_path,
|
||||
|
@ -80,10 +80,10 @@ pub fn build(b: *Builder) !void {
|
|||
};
|
||||
const qemu_cmd = b.addSystemCommand(qemu_args);
|
||||
const qemu_debug_cmd = b.addSystemCommand(qemu_args);
|
||||
qemu_debug_cmd.addArgs([_][]const u8{ "-s", "-S" });
|
||||
qemu_debug_cmd.addArgs(&[_][]const u8{ "-s", "-S" });
|
||||
|
||||
if (rt_test) {
|
||||
const qemu_rt_test_args = [_][]const u8{ "-display", "none" };
|
||||
const qemu_rt_test_args = &[_][]const u8{ "-display", "none" };
|
||||
qemu_cmd.addArgs(qemu_rt_test_args);
|
||||
qemu_debug_cmd.addArgs(qemu_rt_test_args);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ pub fn build(b: *Builder) !void {
|
|||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
if (rt_test) {
|
||||
const script = b.addSystemCommand([_][]const u8{ "python3", "test/rt-test.py", "x86", b.zig_exe });
|
||||
const script = b.addSystemCommand(&[_][]const u8{ "python3", "test/rt-test.py", "x86", b.zig_exe });
|
||||
test_step.dependOn(&script.step);
|
||||
} else {
|
||||
const mock_path = "\"../../test/mock/kernel/\"";
|
||||
|
@ -112,13 +112,13 @@ pub fn build(b: *Builder) !void {
|
|||
}
|
||||
|
||||
const debug_step = b.step("debug", "Debug with gdb and connect to a running qemu instance");
|
||||
const symbol_file_arg = try std.mem.join(b.allocator, " ", [_][]const u8{ "symbol-file", elf_path });
|
||||
const debug_cmd = b.addSystemCommand([_][]const u8{
|
||||
const symbol_file_arg = try std.mem.join(b.allocator, " ", &[_][]const u8{ "symbol-file", elf_path });
|
||||
const debug_cmd = b.addSystemCommand(&[_][]const u8{
|
||||
"gdb",
|
||||
"-ex",
|
||||
symbol_file_arg,
|
||||
});
|
||||
debug_cmd.addArgs([_][]const u8{
|
||||
debug_cmd.addArgs(&[_][]const u8{
|
||||
"-ex",
|
||||
"target remote localhost:1234",
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue