Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 1 | // Copyright 2016 Google Inc. All rights reserved. |
| 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 | // http://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 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 15 | package config |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "strings" |
| 19 | |
| 20 | "android/soong/android" |
Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 21 | "android/soong/remoteexec" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 22 | ) |
| 23 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 24 | var ( |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 25 | // Flags used by lots of devices. Putting them in package static variables |
| 26 | // will save bytes in build.ninja so they aren't repeated for every file |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 27 | commonGlobalCflags = []string{ |
| 28 | "-DANDROID", |
| 29 | "-fmessage-length=0", |
| 30 | "-W", |
| 31 | "-Wall", |
| 32 | "-Wno-unused", |
| 33 | "-Winit-self", |
| 34 | "-Wpointer-arith", |
George Burgess IV | fb81db2 | 2020-02-22 19:28:56 -0800 | [diff] [blame] | 35 | "-Wunreachable-code-loop-increment", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 36 | |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 37 | // Make paths in deps files relative |
| 38 | "-no-canonical-prefixes", |
Colin Cross | 39d450b | 2017-11-06 12:53:30 -0800 | [diff] [blame] | 39 | "-fno-canonical-system-headers", |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 40 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 41 | "-DNDEBUG", |
| 42 | "-UDEBUG", |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 43 | |
| 44 | "-fno-exceptions", |
| 45 | "-Wno-multichar", |
| 46 | |
| 47 | "-O2", |
| 48 | "-g", |
Yi Kong | 110cd5f | 2020-11-04 01:44:15 +0800 | [diff] [blame] | 49 | "-fdebug-info-for-profiling", |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 50 | |
| 51 | "-fno-strict-aliasing", |
Dan Willemsen | 5d980c8 | 2019-08-27 19:37:10 -0700 | [diff] [blame] | 52 | |
| 53 | "-Werror=date-time", |
Elliott Hughes | 2cdbdf1 | 2019-12-03 18:13:00 -0800 | [diff] [blame] | 54 | "-Werror=pragma-pack", |
| 55 | "-Werror=pragma-pack-suspicious-include", |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 56 | "-Werror=string-plus-int", |
George Burgess IV | fb81db2 | 2020-02-22 19:28:56 -0800 | [diff] [blame] | 57 | "-Werror=unreachable-code-loop-increment", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Colin Cross | 6f6a428 | 2016-10-17 14:19:06 -0700 | [diff] [blame] | 60 | commonGlobalConlyflags = []string{} |
Elliott Hughes | 5a0401a | 2016-10-07 13:12:58 -0700 | [diff] [blame] | 61 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 62 | deviceGlobalCflags = []string{ |
| 63 | "-fdiagnostics-color", |
| 64 | |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 65 | "-ffunction-sections", |
Colin Cross | ea3141d | 2017-11-06 14:02:02 -0800 | [diff] [blame] | 66 | "-fdata-sections", |
| 67 | "-fno-short-enums", |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 68 | "-funwind-tables", |
| 69 | "-fstack-protector-strong", |
| 70 | "-Wa,--noexecstack", |
| 71 | "-D_FORTIFY_SOURCE=2", |
| 72 | |
| 73 | "-Wstrict-aliasing=2", |
| 74 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 75 | "-Werror=return-type", |
| 76 | "-Werror=non-virtual-dtor", |
| 77 | "-Werror=address", |
| 78 | "-Werror=sequence-point", |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 79 | "-Werror=format-security", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Colin Cross | 26f1450 | 2017-11-06 13:59:48 -0800 | [diff] [blame] | 82 | deviceGlobalCppflags = []string{ |
| 83 | "-fvisibility-inlines-hidden", |
| 84 | } |
| 85 | |
Colin Cross | 324a457 | 2017-11-02 23:09:41 -0700 | [diff] [blame] | 86 | deviceGlobalLdflags = []string{ |
| 87 | "-Wl,-z,noexecstack", |
| 88 | "-Wl,-z,relro", |
| 89 | "-Wl,-z,now", |
| 90 | "-Wl,--build-id=md5", |
| 91 | "-Wl,--warn-shared-textrel", |
| 92 | "-Wl,--fatal-warnings", |
| 93 | "-Wl,--no-undefined-version", |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 94 | // TODO: Eventually we should link against a libunwind.a with hidden symbols, and then these |
| 95 | // --exclude-libs arguments can be removed. |
Christopher Ferris | c3a1e22 | 2019-04-10 17:57:50 -0700 | [diff] [blame] | 96 | "-Wl,--exclude-libs,libgcc.a", |
Yi Kong | 3d8792f | 2019-05-06 16:18:33 -0700 | [diff] [blame] | 97 | "-Wl,--exclude-libs,libgcc_stripped.a", |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 98 | "-Wl,--exclude-libs,libunwind_llvm.a", |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 99 | "-Wl,--exclude-libs,libunwind.a", |
Ryo Hashimoto | 5818b93 | 2021-03-23 15:05:22 +0900 | [diff] [blame] | 100 | "-Wl,--icf=safe", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 103 | deviceGlobalLldflags = append(ClangFilterUnknownLldflags(deviceGlobalLdflags), |
| 104 | []string{ |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 105 | "-fuse-ld=lld", |
| 106 | }...) |
| 107 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 108 | hostGlobalCflags = []string{} |
| 109 | |
Colin Cross | 26f1450 | 2017-11-06 13:59:48 -0800 | [diff] [blame] | 110 | hostGlobalCppflags = []string{} |
| 111 | |
Colin Cross | 324a457 | 2017-11-02 23:09:41 -0700 | [diff] [blame] | 112 | hostGlobalLdflags = []string{} |
| 113 | |
Chih-Hung Hsieh | 3101a96 | 2018-04-17 14:16:05 -0700 | [diff] [blame] | 114 | hostGlobalLldflags = []string{"-fuse-ld=lld"} |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 115 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 116 | commonGlobalCppflags = []string{ |
| 117 | "-Wsign-promo", |
| 118 | } |
| 119 | |
| 120 | noOverrideGlobalCflags = []string{ |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 121 | "-Werror=bool-operation", |
| 122 | "-Werror=implicit-int-float-conversion", |
| 123 | "-Werror=int-in-bool-context", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 124 | "-Werror=int-to-pointer-cast", |
| 125 | "-Werror=pointer-to-int-cast", |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 126 | "-Werror=string-compare", |
| 127 | "-Werror=xor-used-as-pow", |
Stephen Hines | 2210e72 | 2020-07-15 11:11:57 -0700 | [diff] [blame] | 128 | // http://b/161386391 for -Wno-void-pointer-to-enum-cast |
| 129 | "-Wno-void-pointer-to-enum-cast", |
| 130 | // http://b/161386391 for -Wno-void-pointer-to-int-cast |
| 131 | "-Wno-void-pointer-to-int-cast", |
| 132 | // http://b/161386391 for -Wno-pointer-to-int-cast |
| 133 | "-Wno-pointer-to-int-cast", |
George Burgess IV | 6c69164 | 2019-09-18 17:52:05 -0700 | [diff] [blame] | 134 | "-Werror=fortify-source", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 137 | IllegalFlags = []string{ |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 138 | "-w", |
| 139 | } |
Colin Cross | 6f6a428 | 2016-10-17 14:19:06 -0700 | [diff] [blame] | 140 | |
Dan Albert | 043833c | 2017-02-03 16:13:38 -0800 | [diff] [blame] | 141 | CStdVersion = "gnu99" |
Elliott Hughes | 34e4e41 | 2018-11-30 16:03:06 +0000 | [diff] [blame] | 142 | CppStdVersion = "gnu++17" |
Dan Albert | 043833c | 2017-02-03 16:13:38 -0800 | [diff] [blame] | 143 | ExperimentalCStdVersion = "gnu11" |
Elliott Hughes | 3797612 | 2018-11-28 14:16:39 -0800 | [diff] [blame] | 144 | ExperimentalCppStdVersion = "gnu++2a" |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 145 | |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 146 | // prebuilts/clang default settings. |
| 147 | ClangDefaultBase = "prebuilts/clang/host" |
Pirama Arumuga Nainar | 8a71786 | 2021-04-15 10:01:22 -0700 | [diff] [blame] | 148 | ClangDefaultVersion = "clang-r416183b" |
| 149 | ClangDefaultShortVersion = "12.0.5" |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 150 | |
Chih-Hung Hsieh | 775edde | 2017-12-24 22:24:47 -0800 | [diff] [blame] | 151 | // Directories with warnings from Android.bp files. |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 152 | WarningAllowedProjects = []string{ |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 153 | "device/", |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 154 | "vendor/", |
| 155 | } |
| 156 | |
Chih-Hung Hsieh | 775edde | 2017-12-24 22:24:47 -0800 | [diff] [blame] | 157 | // Directories with warnings from Android.mk files. |
| 158 | WarningAllowedOldProjects = []string{} |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 159 | ) |
| 160 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 161 | var pctx = android.NewPackageContext("android/soong/cc/config") |
| 162 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 163 | func init() { |
Kousik Kumar | d207cbe | 2020-10-20 05:52:49 +0000 | [diff] [blame] | 164 | if android.BuildOs == android.Linux { |
| 165 | commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=") |
| 166 | } |
| 167 | |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame^] | 168 | exportStringListStaticVariable("CommonGlobalConlyflags", commonGlobalConlyflags) |
| 169 | exportStringListStaticVariable("DeviceGlobalCppflags", deviceGlobalCppflags) |
| 170 | exportStringListStaticVariable("DeviceGlobalLdflags", deviceGlobalLdflags) |
| 171 | exportStringListStaticVariable("DeviceGlobalLldflags", deviceGlobalLldflags) |
| 172 | exportStringListStaticVariable("HostGlobalCppflags", hostGlobalCppflags) |
| 173 | exportStringListStaticVariable("HostGlobalLdflags", hostGlobalLdflags) |
| 174 | exportStringListStaticVariable("HostGlobalLldflags", hostGlobalLldflags) |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 175 | |
| 176 | // Export the static default CommonClangGlobalCflags to Bazel. |
| 177 | // TODO(187086342): handle cflags that are set in VariableFuncs. |
| 178 | commonClangGlobalCFlags := append( |
| 179 | ClangFilterUnknownCflags(commonGlobalCflags), |
| 180 | []string{ |
| 181 | "${ClangExtraCflags}", |
| 182 | // Default to zero initialization. |
| 183 | "-ftrivial-auto-var-init=zero", |
| 184 | "-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang", |
| 185 | }...) |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame^] | 186 | exportedStringListVars.Set("CommonClangGlobalCflags", commonClangGlobalCFlags) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 187 | |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 188 | pctx.VariableFunc("CommonClangGlobalCflags", func(ctx android.PackageVarContext) string { |
| 189 | flags := ClangFilterUnknownCflags(commonGlobalCflags) |
| 190 | flags = append(flags, "${ClangExtraCflags}") |
| 191 | |
| 192 | // http://b/131390872 |
| 193 | // Automatically initialize any uninitialized stack variables. |
Stephen Hines | 5c873ac | 2020-05-14 00:59:09 +0000 | [diff] [blame] | 194 | // Prefer zero-init if multiple options are set. |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 195 | if ctx.Config().IsEnvTrue("AUTO_ZERO_INITIALIZE") { |
| 196 | flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang") |
| 197 | } else if ctx.Config().IsEnvTrue("AUTO_PATTERN_INITIALIZE") { |
| 198 | flags = append(flags, "-ftrivial-auto-var-init=pattern") |
Stephen Hines | 797e195 | 2020-01-28 14:43:11 -0800 | [diff] [blame] | 199 | } else if ctx.Config().IsEnvTrue("AUTO_UNINITIALIZE") { |
| 200 | flags = append(flags, "-ftrivial-auto-var-init=uninitialized") |
Stephen Hines | 0e1d5d8 | 2020-01-30 15:06:00 -0800 | [diff] [blame] | 201 | } else { |
Stephen Hines | 5c873ac | 2020-05-14 00:59:09 +0000 | [diff] [blame] | 202 | // Default to zero initialization. |
| 203 | flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang") |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 204 | } |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 205 | return strings.Join(flags, " ") |
| 206 | }) |
| 207 | |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 208 | // Export the static default DeviceClangGlobalCflags to Bazel. |
| 209 | // TODO(187086342): handle cflags that are set in VariableFuncs. |
| 210 | deviceClangGlobalCflags := append(ClangFilterUnknownCflags(deviceGlobalCflags), "${ClangExtraTargetCflags}") |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame^] | 211 | exportedStringListVars.Set("DeviceClangGlobalCflags", deviceClangGlobalCflags) |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 212 | |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 213 | pctx.VariableFunc("DeviceClangGlobalCflags", func(ctx android.PackageVarContext) string { |
| 214 | if ctx.Config().Fuchsia() { |
| 215 | return strings.Join(ClangFilterUnknownCflags(deviceGlobalCflags), " ") |
| 216 | } else { |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 217 | return strings.Join(deviceClangGlobalCflags, " ") |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 218 | } |
| 219 | }) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 220 | |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame^] | 221 | exportStringListStaticVariable("HostClangGlobalCflags", ClangFilterUnknownCflags(hostGlobalCflags)) |
| 222 | exportStringListStaticVariable("NoOverrideClangGlobalCflags", append(ClangFilterUnknownCflags(noOverrideGlobalCflags), "${ClangExtraNoOverrideCflags}")) |
| 223 | exportStringListStaticVariable("CommonClangGlobalCppflags", append(ClangFilterUnknownCflags(commonGlobalCppflags), "${ClangExtraCppflags}")) |
| 224 | exportStringListStaticVariable("ClangExternalCflags", []string{"${ClangExtraExternalCflags}"}) |
Yi Kong | cc80f8d | 2018-06-06 14:42:44 -0700 | [diff] [blame] | 225 | |
Colin Cross | 1cfd89a | 2016-09-15 09:30:46 -0700 | [diff] [blame] | 226 | // Everything in these lists is a crime against abstraction and dependency tracking. |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 227 | // Do not add anything to this list. |
Jingwen Chen | 2199995 | 2021-05-19 05:53:51 +0000 | [diff] [blame] | 228 | commonGlobalIncludes := []string{ |
| 229 | "system/core/include", |
| 230 | "system/logging/liblog/include", |
| 231 | "system/media/audio/include", |
| 232 | "hardware/libhardware/include", |
| 233 | "hardware/libhardware_legacy/include", |
| 234 | "hardware/ril/include", |
| 235 | "frameworks/native/include", |
| 236 | "frameworks/native/opengl/include", |
| 237 | "frameworks/av/include", |
| 238 | } |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame^] | 239 | exportedStringListVars.Set("CommonGlobalIncludes", commonGlobalIncludes) |
Jingwen Chen | 2199995 | 2021-05-19 05:53:51 +0000 | [diff] [blame] | 240 | pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I", commonGlobalIncludes) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 241 | |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 242 | pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase) |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 243 | pctx.VariableFunc("ClangBase", func(ctx android.PackageVarContext) string { |
| 244 | if override := ctx.Config().Getenv("LLVM_PREBUILTS_BASE"); override != "" { |
| 245 | return override |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 246 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 247 | return "${ClangDefaultBase}" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 248 | }) |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 249 | pctx.VariableFunc("ClangVersion", func(ctx android.PackageVarContext) string { |
| 250 | if override := ctx.Config().Getenv("LLVM_PREBUILTS_VERSION"); override != "" { |
| 251 | return override |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 252 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 253 | return ClangDefaultVersion |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 254 | }) |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 255 | pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}") |
| 256 | pctx.StaticVariable("ClangBin", "${ClangPath}/bin") |
| 257 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 258 | pctx.VariableFunc("ClangShortVersion", func(ctx android.PackageVarContext) string { |
| 259 | if override := ctx.Config().Getenv("LLVM_RELEASE_VERSION"); override != "" { |
| 260 | return override |
Stephen Hines | e55a4cc | 2016-11-18 17:12:38 -0800 | [diff] [blame] | 261 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 262 | return ClangDefaultShortVersion |
Stephen Hines | e55a4cc | 2016-11-18 17:12:38 -0800 | [diff] [blame] | 263 | }) |
Stephen Hines | 755fe07 | 2018-01-24 19:58:36 -0800 | [diff] [blame] | 264 | pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib64/clang/${ClangShortVersion}/lib/linux") |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 265 | |
Jayant Chowdhary | e622d20 | 2017-02-01 19:19:52 -0800 | [diff] [blame] | 266 | // These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts |
| 267 | // being used for the rest of the build process. |
| 268 | pctx.SourcePathVariable("RSClangBase", "prebuilts/clang/host") |
| 269 | pctx.SourcePathVariable("RSClangVersion", "clang-3289846") |
| 270 | pctx.SourcePathVariable("RSReleaseVersion", "3.8") |
| 271 | pctx.StaticVariable("RSLLVMPrebuiltsPath", "${RSClangBase}/${HostPrebuiltTag}/${RSClangVersion}/bin") |
| 272 | pctx.StaticVariable("RSIncludePath", "${RSLLVMPrebuiltsPath}/../lib64/clang/${RSReleaseVersion}/include") |
| 273 | |
Jeff Gaston | 734e380 | 2017-04-10 15:47:24 -0700 | [diff] [blame] | 274 | pctx.PrefixedExistentPathsForSourcesVariable("RsGlobalIncludes", "-I", |
Colin Cross | 2a252be | 2017-05-01 17:37:24 -0700 | [diff] [blame] | 275 | []string{ |
| 276 | "external/clang/lib/Headers", |
| 277 | "frameworks/rs/script_api/include", |
| 278 | }) |
| 279 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 280 | pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string { |
| 281 | if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" { |
| 282 | return override + " " |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 283 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 284 | return "" |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 285 | }) |
Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 286 | |
Colin Cross | 77cdcfd | 2021-03-12 11:28:25 -0800 | [diff] [blame] | 287 | pctx.StaticVariableWithEnvOverride("RECXXPool", "RBE_CXX_POOL", remoteexec.DefaultPool) |
| 288 | pctx.StaticVariableWithEnvOverride("RECXXLinksPool", "RBE_CXX_LINKS_POOL", remoteexec.DefaultPool) |
| 289 | pctx.StaticVariableWithEnvOverride("REClangTidyPool", "RBE_CLANG_TIDY_POOL", remoteexec.DefaultPool) |
| 290 | pctx.StaticVariableWithEnvOverride("RECXXLinksExecStrategy", "RBE_CXX_LINKS_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 291 | pctx.StaticVariableWithEnvOverride("REClangTidyExecStrategy", "RBE_CLANG_TIDY_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 292 | pctx.StaticVariableWithEnvOverride("REAbiDumperExecStrategy", "RBE_ABI_DUMPER_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 293 | pctx.StaticVariableWithEnvOverride("REAbiLinkerExecStrategy", "RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) |
| 297 | |
Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 298 | func envOverrideFunc(envVar, defaultVal string) func(ctx android.PackageVarContext) string { |
| 299 | return func(ctx android.PackageVarContext) string { |
| 300 | if override := ctx.Config().Getenv(envVar); override != "" { |
| 301 | return override |
| 302 | } |
| 303 | return defaultVal |
| 304 | } |
| 305 | } |