Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame^] | 1 | # This build configuration extends GN's cross-compilation concepts of "target", |
| 2 | # "host" and "current" with "arch" which is used to refer to the embedded |
| 3 | # architecture that the bare metal images are being built for. |
| 4 | # |
| 5 | # The concepts of "target", "host" and "current" are used when bulding tests |
| 6 | # and utilities for the non-embedded device. Note that there hasn't been any |
| 7 | # thought given to support building for anything other than the host so it |
| 8 | # probably won't work. |
| 9 | # |
| 10 | # In summary: |
| 11 | # - host{_os,_cpu,_toolchain} is for the system running the build |
| 12 | # - target{_os,_cpu,_toolchain} is for the system that will run utilities and tests |
| 13 | # - arch{,_toolchain} is for the embedded system that will run the bare metal images |
| 14 | |
| 15 | # Configuration of the build toolchain. |
| 16 | declare_args() { |
| 17 | # Enable extra debugging. |
| 18 | is_debug = true |
| 19 | |
| 20 | # Set to true to build with gcc (default is clang). |
| 21 | use_gcc = false |
| 22 | |
| 23 | # The architecture to build the bare metal images for. |
| 24 | arch = "aarch64" |
| 25 | |
| 26 | # The platform to build the bare metal images for. |
| 27 | arch_platform = "qemu" |
| 28 | |
| 29 | # Set by arch toolchain. Prefix for binutils tools. |
| 30 | arch_tool_prefix = "" |
| 31 | } |
| 32 | |
| 33 | # Check that we support the attempted build |
| 34 | assert(host_os == "linux", "Only linux builds are currently supported") |
| 35 | |
| 36 | # Check that the requested architecture is supported |
| 37 | assert(arch == "aarch64", "Unsupported arch: $arch") |
| 38 | |
| 39 | # Setup the standard variables |
| 40 | if (target_os == "") { |
| 41 | target_os = host_os |
| 42 | } |
| 43 | if (target_cpu == "") { |
| 44 | target_cpu = host_cpu |
| 45 | } |
| 46 | if (current_os == "") { |
| 47 | current_os = target_os |
| 48 | } |
| 49 | if (current_cpu == "") { |
| 50 | current_cpu = target_cpu |
| 51 | } |
| 52 | |
| 53 | assert(target_os == host_os, "Cross compiles not yet supported") |
| 54 | assert(target_cpu == host_cpu, "Cross compiles not yet supported") |
| 55 | |
| 56 | # All binary targets will get this list of configs by default |
| 57 | _shared_binary_target_configs = [ "//build:compiler_defaults" ] |
| 58 | |
| 59 | # Apply that default list to the binary target types. |
| 60 | set_defaults("executable") { |
| 61 | configs = _shared_binary_target_configs |
| 62 | # Executables get this additional configuration |
| 63 | configs += [ "//build:executable_ldconfig" ] |
| 64 | } |
| 65 | set_defaults("static_library") { |
| 66 | configs = _shared_binary_target_configs |
| 67 | } |
| 68 | set_defaults("shared_library") { |
| 69 | configs = _shared_binary_target_configs |
| 70 | } |
| 71 | set_defaults("source_set") { |
| 72 | configs = _shared_binary_target_configs |
| 73 | } |
| 74 | |
| 75 | # Select host, target and arch toolchains |
| 76 | if (use_gcc) { |
| 77 | host_toolchain = "//build/toolchain/host:gcc" |
| 78 | target_toolchain = "//build/toolchain/host:gcc" |
| 79 | arch_toolchain = "//build/toolchain/arch:gcc_${arch}" |
| 80 | } else { |
| 81 | host_toolchain = "//build/toolchain/host:clang" |
| 82 | target_toolchain = "//build/toolchain/host:clang" |
| 83 | arch_toolchain = "//build/toolchain/arch:clang_${arch}" |
| 84 | } |
| 85 | |
| 86 | # The default toolchain is the target toolchain for building utilities and tests |
| 87 | set_default_toolchain(target_toolchain) |