blob: 302e3f48acc1ff6167663487b726f9306edfd877 [file] [log] [blame]
# This build configuration extends GN's cross-compilation concepts of "target",
# "host" and "current" with "arch" which is used to refer to the embedded
# architecture that the bare metal images are being built for.
#
# The concepts of "target", "host" and "current" are used when bulding tests
# and utilities for the non-embedded device. Note that there hasn't been any
# thought given to support building for anything other than the host so it
# probably won't work.
#
# In summary:
# - host{_os,_cpu,_toolchain} is for the system running the build
# - target{_os,_cpu,_toolchain} is for the system that will run utilities and tests
# - arch{,_toolchain} is for the embedded system that will run the bare metal images
# Configuration of the build toolchain.
declare_args() {
# Enable extra debugging.
is_debug = true
# Set to true to build with gcc (default is clang).
use_gcc = false
# The architecture to build the bare metal images for.
arch = ""
# Set by arch toolchain. Prefix for binutils tools.
arch_tool_prefix = ""
}
# Check that we support the attempted build
assert(host_os == "linux", "Only linux builds are currently supported")
# Check that the requested architecture is supported
assert(arch == "aarch64" || arch == "fake", "Unsupported arch: $arch")
# Setup the standard variables
if (target_os == "") {
target_os = host_os
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_os == "") {
current_os = target_os
}
if (current_cpu == "") {
current_cpu = target_cpu
}
assert(target_os == host_os, "Cross compiles not yet supported")
assert(target_cpu == host_cpu, "Cross compiles not yet supported")
# All binary targets will get this list of configs by default
_shared_binary_target_configs = [
"//build:compiler_defaults",
"//build:sections",
"//build:lto",
]
# Apply that default list to the binary target types.
set_defaults("executable") {
configs = _shared_binary_target_configs
# Executables get this additional configuration
configs += [ "//build:executable_ldconfig" ]
}
set_defaults("static_library") {
configs = _shared_binary_target_configs
}
set_defaults("shared_library") {
configs = _shared_binary_target_configs
}
set_defaults("source_set") {
configs = _shared_binary_target_configs
}
# Select host, target and arch toolchains
if (use_gcc) {
host_toolchain = "//build/toolchain/host:gcc"
target_toolchain = "//build/toolchain/host:gcc"
fake_toolchain = "//build/toolchain/host:gcc_fake_arch"
arch_toolchain = "//build/toolchain/arch:gcc_${arch}"
} else {
host_toolchain = "//build/toolchain/host:clang"
target_toolchain = "//build/toolchain/host:clang"
fake_toolchain = "//build/toolchain/host:clang_fake_arch"
arch_toolchain = "//build/toolchain/arch:clang_${arch}"
}
# The default toolchain is the target toolchain for building utilities and tests
set_default_toolchain(target_toolchain)