# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/zircon/standard.gni")

if (current_toolchain == default_toolchain) {
  # In the default toolchain, simply define the bootloader toolchains
  # to be used to build Gigaboot as a Win32 PE32+ executable.

  import("//build/toolchain/zircon/zircon_toolchain_suite.gni")

  # Define a Zircon EFI toolchain. These are required to build the Gigaboot
  # bootloader (see //src/firmware/gigaboot/README.md)
  #
  # Parameters:
  #    cpu: [required]
  #      Fuchsia device CPU name (e.g. "x64" or "arm64")
  #      Type: string
  #
  template("zircon_efi_toolchain") {
    zircon_toolchain_suite(target_name) {
      cpu = invoker.cpu
      os = "win"
      environment = "efi"
      with_shared = false
      exclude_variant_tags = [
        "instrumented",
        "gcc",
      ]
      configs = [ "//src/firmware/gigaboot:efi_config" ]

      # TODO: harmless, but just to match build.mk
      remove_common_configs = [ "//build/config/zircon:default_frame_pointers" ]
    }
  }

  # These toolchains will be used to build the EFI bootloader.
  foreach(cpu, standard_fuchsia_cpus) {
    zircon_efi_toolchain("efi_$cpu") {
      cpu = "$cpu"
    }
  }
}

if (zircon_toolchain != false && zircon_toolchain.environment == "efi") {
  # This is the top config for all code in the efi_toolchain.
  config("efi_config") {
    configs = [
      "//build/config/zircon:standalone",
      "//build/config/zircon:no_sanitizers",

      # TODO: "$zx/kernel:warnings",
    ]
    include_dirs = [ "include" ]
    cflags = [
      "-std=c99",
      "-fshort-wchar",
    ]
  }

  # Any config listed in toolchain_variant must have a _deps group listing
  # extra dependencies for it.
  group("efi_config_deps") {
  }

  # This is the Gigaboot bootloader binary.
  executable("bootloader") {
    output_dir = root_out_dir
    if (current_cpu == "arm64") {
      output_name = "bootaa64"
    } else {
      output_name = "boot${current_cpu}"
    }
    output_extension = "efi"

    deps = [
      "lib",
      "src",
    ]

    ldflags = [
      "-Wl,/subsystem:efi_application",
      "-Wl,/entry:efi_main",

      # These only really affect instrumented builds but are always harmless.
      "-noprofilelib",
      "-Wl,/nodefaultlib",
    ]
  }
} else {
  group("bootloader") {
    public_deps = [ ":bootloader(//src/firmware/gigaboot:efi_${current_cpu})" ]
  }
}
