diff options
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 118 |
1 files changed, 30 insertions, 88 deletions
@@ -20,11 +20,9 @@ const c_flags = &[_][]const u8{ "-ggdb", }; -const boot_src = &[_][]const u8{"boot/boot.S"}; - const kernel_src = &[_][]const u8{ "kernel/entry.S", // must be first - "kernel/kernel.c", // main function + "kernel/main.c", // main function "kernel/cpu/cpu.c", "kernel/cpu/fpu.c", "kernel/cpu/idt.c", @@ -36,8 +34,34 @@ const kernel_src = &[_][]const u8{ "kernel/drivers/tty.c", "kernel/drivers/uart.c", "kernel/fs/fs.c", - "kernel/lib/fputc.c", + "kernel/lib/atox.c", + "kernel/lib/bound.c", + "kernel/lib/btoa.c", + "kernel/lib/ctoi.c", + "kernel/lib/isdigit.c", + "kernel/lib/isspace.c", + "kernel/lib/itoc.c", + "kernel/lib/kalloc.c", + "kernel/lib/kprintf.c", + "kernel/lib/memcmp.c", + "kernel/lib/memcpy.c", + "kernel/lib/memcpyv.c", + "kernel/lib/memmove.c", + "kernel/lib/memmovev.c", + "kernel/lib/memset.c", + "kernel/lib/memsetv.c", "kernel/lib/panic.c", + "kernel/lib/stpcpy.c", + "kernel/lib/stpncpy.c", + "kernel/lib/strcat.c", + "kernel/lib/strcpy.c", + "kernel/lib/strlen.c", + "kernel/lib/strncmp.c", + "kernel/lib/strncpy.c", + "kernel/lib/strtoux.c", + "kernel/lib/strtox.c", + "kernel/lib/uxtoa.c", + "kernel/lib/xtoa.c", "kernel/mboot/mboot.c", "kernel/mboot/mmap.c", "kernel/memory/memory.c", @@ -46,61 +70,11 @@ const kernel_src = &[_][]const u8{ "kernel/memory/virtalloc.c", }; -const lib_src = &[_][]const u8{ - "lib/alloc.c", - "lib/atox.c", - "lib/bound.c", - "lib/btoa.c", - "lib/ctoi.c", - "lib/delay.c", - "lib/isdigit.c", - "lib/isspace.c", - "lib/itoc.c", - "lib/memcmp.c", - "lib/memcpy.c", - "lib/memcpyv.c", - "lib/memmove.c", - "lib/memmovev.c", - "lib/memset.c", - "lib/memsetv.c", - "lib/printf.c", - "lib/stpcpy.c", - "lib/stpncpy.c", - "lib/strcat.c", - "lib/strcpy.c", - "lib/strlen.c", - "lib/strncmp.c", - "lib/strncpy.c", - "lib/strtoux.c", - "lib/strtox.c", - "lib/timetostr.c", - "lib/uxtoa.c", - "lib/xtoa.c", -}; - const Prog = struct { name: []const u8, source: []const []const u8, }; -const util_progs = &[_]Prog{ - // mkblob - Prog{ - .name = "mkblob", - .source = &[_][]const u8{"util/mkblob.c"}, - }, - // listblob - Prog{ - .name = "listblob", - .source = &[_][]const u8{"util/listblob.c"}, - }, - // BuildImage - Prog{ - .name = "BuildImage", - .source = &[_][]const u8{"util/BuildImage.c"}, - }, -}; - const AddSourcesOpts = struct { exe: *std.Build.Step.Compile, sources: []const []const []const u8, c_flags: []const []const u8 }; fn add_sources(b: *std.Build, opts: AddSourcesOpts) void { @@ -138,8 +112,7 @@ fn build_kern_binary(b: *std.Build, opts: BuildKernBinaryOpts) void { .strip = opts.strip, }); - // add include paths - exe.addIncludePath(b.path("include/")); + // add include path if (opts.include != null) { exe.addIncludePath(b.path(opts.include.?)); } @@ -198,12 +171,6 @@ fn build_native_binary(b: *std.Build, opts: BuildNativeBinaryOpts) void { pub fn build(b: *std.Build) !void { // context - const target32 = std.Build.resolveTargetQuery(b, .{ - .cpu_arch = std.Target.Cpu.Arch.x86, - .os_tag = std.Target.Os.Tag.freestanding, - .abi = std.Target.Abi.gnu, - .ofmt = std.Target.ObjectFormat.elf, - }); const target64 = std.Build.resolveTargetQuery(b, .{ .cpu_arch = std.Target.Cpu.Arch.x86_64, .os_tag = std.Target.Os.Tag.freestanding, @@ -212,19 +179,6 @@ pub fn build(b: *std.Build) !void { }); const optimize = std.builtin.OptimizeMode.ReleaseFast; - // boot - build_kern_binary(b, .{ - .name = "boot", - .target = target32, - .optimize = optimize, - .sources = &.{ - boot_src, - }, - .linker = "boot/boot.ld", - .entry = "bootentry", - .include = "boot/include", - }); - // kernel build_kern_binary(b, .{ .name = "kernel", @@ -232,20 +186,8 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, .sources = &.{ kernel_src, - lib_src, }, - .linker = "kernel/kernel.ld", + .linker = "config/kernel.ld", .include = "kernel/include", }); - - // util_progs - for (util_progs) |prog| { - build_native_binary(b, .{ - .name = prog.name, - .optimize = optimize, - .sources = &.{ - prog.source, - }, - }); - } } |