-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
50 lines (43 loc) · 1.62 KB
/
Copy pathbuild.zig
File metadata and controls
50 lines (43 loc) · 1.62 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{ .default_target = .{
.cpu_arch = .x86,
.os_tag = .freestanding,
} });
const optimize = b.standardOptimizeOption(.{});
_ = target;
// Note: This build.zig is a reference for the project structure.
// The actual build process for Linux 0.11 requires:
// 1. Compile each Zig module to a .o file
// 2. Assemble the .s/.S files
// 3. Link everything together as a flat binary at 0x00000
// 4. Combine with bootsect and setup to create a floppy image
//
// A full build system would need to replicate the original Makefile
// structure using Zig's build system, with appropriate linker scripts.
// Create a library that gathers all kernel Zig sources
const kernel_lib = b.addStaticLibrary(.{
.name = "kernel_zig",
.root_source_file = b.path("init/main.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .x86,
.os_tag = .freestanding,
}),
.optimize = optimize,
});
// Assembly files that need to be assembled separately
const asm_files = [_][]const u8{
"kernel/asm.s",
"kernel/system_call.s",
"kernel/chr_drv/kb.S",
"kernel/chr_drv/rs_io.s",
"mm/page.s",
};
for (asm_files) |asm_file| {
kernel_lib.addAssemblyFile(b.path(asm_file));
}
// The boot assembly files are separate and compiled to flat binaries
// bootsect.s -> bootsect (512 bytes)
// setup.s -> setup (4 sectors)
// head.s is linked as part of the kernel
}