Andrew Scull | e982771 | 2018-10-19 14:54:20 +0100 | [diff] [blame] | 1 | # Copyright 2018 Google LLC |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 15 | # Configuration of the build toolchain. |
| 16 | declare_args() { |
Andrew Scull | b401ba3 | 2018-11-09 10:30:54 +0000 | [diff] [blame] | 17 | # The name of the project being built. |
| 18 | project = "reference" |
| 19 | |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 20 | # Enable extra debugging. |
| 21 | is_debug = true |
| 22 | |
Andrew Scull | b401ba3 | 2018-11-09 10:30:54 +0000 | [diff] [blame] | 23 | # Whether to build against the platform for embedded images consisting of |
| 24 | # include paths and defines. This is also used for host targets that simulate |
| 25 | # an embedded image. |
| 26 | use_platform = false |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 27 | } |
| 28 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 29 | # Check that we support the attempted build. |
| 30 | assert(host_os == "linux", "Only linux builds are currently supported.") |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 31 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 32 | # Setup the standard variables. |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 33 | if (target_os == "") { |
| 34 | target_os = host_os |
| 35 | } |
| 36 | if (target_cpu == "") { |
| 37 | target_cpu = host_cpu |
| 38 | } |
| 39 | if (current_os == "") { |
| 40 | current_os = target_os |
| 41 | } |
| 42 | if (current_cpu == "") { |
| 43 | current_cpu = target_cpu |
| 44 | } |
| 45 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 46 | assert(target_os == host_os, "Cross compiles not yet supported.") |
| 47 | assert(target_cpu == host_cpu, "Cross compiles not yet supported.") |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 48 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 49 | # All binary targets will get this list of configs by default. |
| 50 | _shared_binary_target_configs = [ "//build:compiler_defaults" ] |
| 51 | |
| 52 | # If it's not building a host utility, it's building against the platform so apply the configuration. |
Andrew Scull | b401ba3 | 2018-11-09 10:30:54 +0000 | [diff] [blame] | 53 | if (use_platform) { |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 54 | _shared_binary_target_configs += [ "//build:platform" ] |
| 55 | } |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 56 | |
| 57 | # Apply that default list to the binary target types. |
| 58 | set_defaults("executable") { |
| 59 | configs = _shared_binary_target_configs |
Andrew Scull | a158e91 | 2018-07-16 11:32:13 +0100 | [diff] [blame] | 60 | } |
| 61 | set_defaults("static_library") { |
| 62 | configs = _shared_binary_target_configs |
| 63 | } |
| 64 | set_defaults("shared_library") { |
| 65 | configs = _shared_binary_target_configs |
| 66 | } |
| 67 | set_defaults("source_set") { |
| 68 | configs = _shared_binary_target_configs |
| 69 | } |
| 70 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 71 | # The default toolchain is the target toolchain for building utilities and tests. |
| 72 | set_default_toolchain("//build/toolchain:host_clang") |