| # 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 |
| toolchain_tags = [ "efi" ] |
| exclude_variant_tags = [ |
| "instrumented", |
| "gcc", |
| ] |
| configs = [ "//src/firmware/gigaboot:efi_config" ] |
| |
| # TODO: harmless, but just to match build.mk |
| remove_common_configs = [ "//build/config: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 (is_efi_toolchain) { |
| # This is the top config for all code in the efi_toolchain. |
| config("efi_config") { |
| configs = [ |
| "//zircon/kernel:standalone", |
| "//build/config/sanitizers:no_sanitizers", |
| |
| # TODO: "//zircon/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})" ] |
| } |
| |
| # Gigaboot would be difficult to test on-device, so we run host unittests |
| # instead, stubbing out the necessary functions. |
| group("tests") { |
| testonly = true |
| deps = [ |
| "lib:gigaboot_shared_lib_test($host_toolchain)", |
| "src:gigaboot_test($host_toolchain)", |
| ] |
| } |
| } |