Newer
Older
minerva / Meta / gn / secondary / Kernel / Prekernel / BUILD.gn
@minerva minerva on 13 Jul 1 KB Initial commit
import("//Meta/gn/build/minerva_target.gni")
import("//Meta/gn/build/sysroot.gni")

assert(current_os == "minerva")
assert(current_cpu == "x86_64")

group("Prekernel") {
  deps = [ ":install_prekernel" ]
}

executable("Prekernel_bin") {
  configs += [ "//Kernel:Kernel_config" ]
  deps = [ "//Userland/Libraries/LibC:install_libc_headers" ]
  cflags = [
    "-fno-pic",
    "-fno-pie",
  ]
  ldflags = [
    "-static",
    "-fno-pie",
    "-Wl,-T" + rebase_path("linker.ld", root_build_dir),
  ]
  sources = [
    "//Kernel//Library/MiniStdLib.cpp",
    "//Userland/Libraries/LibELF/Relocation.cpp",
    "UBSanitizer.cpp",
    "boot.S",
    "init.cpp",
    "multiboot.S",
  ]
}

action("postprocess_prekernel") {
  script = "//Meta/gn/build/invoke_process_with_args.py"
  inputs = [ "$target_out_dir/Prekernel_bin" ]
  outputs = [ "$target_gen_dir/Prekernel" ]
  deps = [ ":Prekernel_bin" ]
  args = [
    "$minerva_objcopy",
    "-O",
    "elf32-i386",
    rebase_path(inputs[0], root_build_dir),
    rebase_path(outputs[0], root_build_dir),
  ]
}

copy("install_prekernel") {
  deps = [ ":postprocess_prekernel" ]
  sources = [ "$target_gen_dir/Prekernel" ]
  outputs = [ "$sysroot/boot/{{source_file_part}}" ]
}