Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 1 | # Copyright 2020 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # 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, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame] | 15 | # gn-format disable |
| 16 | import("//build_overrides/pigweed.gni") |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 17 | declare_args() { |
| 18 | # Sets the sanitizer to pass to clang. Valid values are those for "-fsanitize" |
| 19 | # listed in https://clang.llvm.org/docs/UsersManual.html#id9. |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 20 | pw_toolchain_SANITIZER = "" |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 21 | |
| 22 | # Indicates if this build is a part of OSS-Fuzz, which needs to be able to |
| 23 | # provide its own compiler and flags. This violates the build hermeticisim and |
| 24 | # should only be used for OSS-Fuzz. |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 25 | pw_toolchain_OSS_FUZZ_ENABLED = false |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | # Specifies the tools used by host Clang toolchains. |
| 29 | _host_clang_toolchain = { |
| 30 | # Note: On macOS, there is no "llvm-ar", only "ar", which happens to be LLVM |
| 31 | # ar. This should get updated for linux systems. |
| 32 | ar = "ar" |
| 33 | |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 34 | if (pw_toolchain_OSS_FUZZ_ENABLED) { |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 35 | cc = getenv("CC") |
| 36 | cxx = getenv("CXX") |
| 37 | } else { |
| 38 | cc = "clang" |
| 39 | cxx = "clang++" |
| 40 | } |
| 41 | |
| 42 | is_host_toolchain = true |
| 43 | } |
| 44 | |
| 45 | # Common default scope shared by all host Clang toolchains. |
| 46 | _defaults = { |
| 47 | default_configs = [ |
| 48 | "$dir_pw_build:extra_debugging", |
| 49 | "$dir_pw_toolchain/host_clang:no_system_libcpp", |
| 50 | "$dir_pw_toolchain/host_clang:xcode_sysroot", |
| 51 | ] |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 52 | if (pw_toolchain_SANITIZER != "") { |
Alexei Frolov | 258fc1b | 2020-06-10 16:24:50 -0700 | [diff] [blame] | 53 | configs += |
| 54 | [ "$dir_pw_toolchain/host_clang:sanitize_$pw_toolchain_SANITIZER" ] |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 55 | } |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 56 | if (pw_toolchain_OSS_FUZZ_ENABLED) { |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 57 | default_configs += oss_fuzz_added_configs |
| 58 | default_configs += [ "$dir_pw_fuzzer:oss_fuzz_extra" ] |
| 59 | |
| 60 | # Add the configs to be removed. They will be de-duplicated, and this |
| 61 | # ensures they are present to be removed. |
| 62 | default_configs += oss_fuzz_removed_configs |
Alexei Frolov | e9bc14b | 2020-06-15 10:25:10 -0700 | [diff] [blame^] | 63 | remove_default_configs = oss_fuzz_removed_configs |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
Armando Montanez | 164624f | 2020-06-10 15:00:29 -0700 | [diff] [blame] | 67 | pw_toolchain_host_clang = { |
| 68 | debug = { |
| 69 | name = "host_clang_debug" |
| 70 | forward_variables_from(_host_clang_toolchain, "*") |
| 71 | defaults = { |
| 72 | forward_variables_from(_defaults, "*") |
| 73 | default_configs += [ "$dir_pw_build:optimize_debugging" ] |
| 74 | } |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 75 | } |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 76 | |
Armando Montanez | 164624f | 2020-06-10 15:00:29 -0700 | [diff] [blame] | 77 | speed_optimized = { |
| 78 | name = "host_clang_speed_optimized" |
| 79 | forward_variables_from(_host_clang_toolchain, "*") |
| 80 | defaults = { |
| 81 | forward_variables_from(_defaults, "*") |
| 82 | default_configs += [ "$dir_pw_build:optimize_speed" ] |
| 83 | } |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 84 | } |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 85 | |
Armando Montanez | 164624f | 2020-06-10 15:00:29 -0700 | [diff] [blame] | 86 | size_optimized = { |
| 87 | name = "host_clang_size_optimized" |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 88 | forward_variables_from(_host_clang_toolchain, "*") |
| 89 | defaults = { |
| 90 | forward_variables_from(_defaults, "*") |
| 91 | default_configs += [ "$dir_pw_build:optimize_size" ] |
| 92 | } |
Armando Montanez | 164624f | 2020-06-10 15:00:29 -0700 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
| 96 | # Describes host clang toolchains. |
| 97 | pw_toolchain_host_clang_list = [ |
| 98 | pw_toolchain_host_clang.debug, |
| 99 | pw_toolchain_host_clang.speed_optimized, |
| 100 | pw_toolchain_host_clang.size_optimized, |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 101 | ] |