1# Copyright 2018 The Hafnium Authors.
2#
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file or at
5# https://opensource.org/licenses/BSD-3-Clause.
6
7# Configuration of the build toolchain.
8declare_args() {
9  # The name of the project being built.
10  project = "reference"
11
12  # This default path is overriden from the Makefile based on
13  # the toolchain_lib arg passed through gn.
14  toolchain_lib =
15      rebase_path("//prebuilts/linux-x64/clang/lib64/clang/12.0.5/include")
16
17  # Whether to build against the platform for embedded images consisting of
18  # include paths and defines. This is also used for host targets that simulate
19  # an embedded image.
20  use_platform = false
21
22  # Whether assertions are included in the build, this is overriden from the Makefile
23  # based on the enable_assertions arg passed through gn
24  enable_assertions = 1
25}
26
27# Check that we support the attempted build.
28assert(host_os == "linux", "Only linux builds are currently supported.")
29
30# Setup the standard variables.
31if (target_os == "") {
32  target_os = host_os
33}
34if (target_cpu == "") {
35  target_cpu = host_cpu
36}
37if (current_os == "") {
38  current_os = target_os
39}
40if (current_cpu == "") {
41  current_cpu = target_cpu
42}
43
44assert(target_os == host_os, "Cross compiles not yet supported.")
45assert(target_cpu == host_cpu, "Cross compiles not yet supported.")
46
47# All binary targets will get this list of configs by default.
48_shared_binary_target_configs = [ "//build:compiler_defaults" ]
49
50# If it's not building a host utility, it's building against the platform so apply the configuration.
51if (use_platform) {
52  _shared_binary_target_configs += [ "//build:platform" ]
53}
54
55# Apply that default list to the binary target types.
56set_defaults("executable") {
57  configs = _shared_binary_target_configs
58}
59set_defaults("static_library") {
60  configs = _shared_binary_target_configs
61}
62set_defaults("shared_library") {
63  configs = _shared_binary_target_configs
64}
65set_defaults("source_set") {
66  configs = _shared_binary_target_configs
67}
68
69# The default toolchain is the target toolchain for building utilities and tests.
70set_default_toolchain("//build/toolchain:host_clang")
71