Hi all -
I think I’m very close to getting a successful build but I’m getting this error -
andy@obsidian:~/Zig-DOS$ zig build
/home/andy/Zig-DOS/build.zig:20:19: error: no field named 'cpu_arch' in struct 'Build.ResolvedTarget'
kernel_target.cpu_arch = .x86_64;
^~~~~~~~
I did a web search - not much joy there. Looked at the docs and found this -
host: ResolvedTarget
Deprecated. Use b.graph.host
.
Ok, fine, I’ll try that. So, I put this in my build script -
kernel_target.graph.host = .x86_64;
After that, I got this -
andy@obsidian:~/Zig-DOS$ zig build
/home/andy/Zig-DOS/build.zig:21:19: error: no field named 'graph' in struct 'Build.ResolvedTarget'
kernel_target.graph.host = .x86_64;
^~~~~
Arrgh!
I tried to do the right thing, searching around and looking at the docs before coming here, but doing that didn’t help in this instance.
So, I’m hoping someone may be able to help.
Btw - here is my build script -
// build.zig
// The OS build file.
// This code is released to the public domain.
// "Share and enjoy....." :)
const std = @import("std");
pub fn build(b: *std.Build) void {
// Standard target options allow the user to specify target via command line
const optimize = b.standardOptimizeOption(.{});
// Get the user-provided target options (optional)
const base_target = b.standardTargetOptions(.{});
// Create a mutable copy for the kernel target
var kernel_target = base_target ; // orelse std.build.UserTarget.init();
// kernel_target.cpu_arch = .x86_64;
kernel_target.graph.host = .x86_64;
kernel_target.os_tag = .freestanding;
// Create a mutable copy for the bootloader target
var bootloader_target = base_target ; // orelse std.build.UserTarget.init();
bootloader_target.cpu_arch = .x86_64;
bootloader_target.os_tag = .uefi;
// Create an executable for the kernel
const kernel = b.addExecutable(.{
.name = "Zig-DOS-Kernel",
.root_source_file = b.path("src/kernel/main.zig"),
.target = kernel_target,
.optimize = optimize,
});
// Install the kernel artifact
b.installArtifact(kernel);
// Build the bootloader with the correct entry point
const bootloader = b.addExecutable(.{
.name = "Zig-DOS-Bootloader",
.root_source_file = b.path("src/boot/main.zig"),
.target = bootloader_target,
.optimize = optimize,
.entry_symbol = "efiMain",
});
// Install the bootloader artifact
b.installArtifact(bootloader);
}
Many thanks in advance! Bye for now -
- mooseman