blob: aa60b3fd3c6201841cceb442d7ab05035641a0f7 [file] [log] [blame]
Dan Willemsen1e704462016-08-21 15:17:17 -07001// Copyright 2017 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
15package build
16
17import (
Nan Zhang2e6a4ff2018-02-14 13:27:26 -080018 "io/ioutil"
Dan Willemsenc2af0be2017-01-20 14:10:01 -080019 "log"
20 "os"
Dan Willemsen1e704462016-08-21 15:17:17 -070021 "path/filepath"
22 "runtime"
23 "strconv"
24 "strings"
Nan Zhang2e6a4ff2018-02-14 13:27:26 -080025 "time"
Jeff Gastonefc1b412017-03-29 17:29:06 -070026
27 "android/soong/shared"
Dan Willemsen1e704462016-08-21 15:17:17 -070028)
29
30type Config struct{ *configImpl }
31
32type configImpl struct {
33 // From the environment
34 arguments []string
35 goma bool
36 environ *Environment
37
38 // From the arguments
Colin Cross37193492017-11-16 17:55:00 -080039 parallel int
40 keepGoing int
41 verbose bool
42 checkbuild bool
43 dist bool
44 skipMake bool
Dan Willemsen1e704462016-08-21 15:17:17 -070045
46 // From the product config
Dan Willemsen02781d52017-05-12 19:28:13 -070047 katiArgs []string
48 ninjaArgs []string
49 katiSuffix string
50 targetDevice string
Dan Willemsen3d60b112018-04-04 22:25:56 -070051
52 brokenDupRules bool
Dan Willemsen1e704462016-08-21 15:17:17 -070053}
54
Dan Willemsenc2af0be2017-01-20 14:10:01 -080055const srcDirFileCheck = "build/soong/root.bp"
56
Dan Willemsen1e704462016-08-21 15:17:17 -070057func NewConfig(ctx Context, args ...string) Config {
58 ret := &configImpl{
59 environ: OsEnvironment(),
60 }
61
Dan Willemsen9b587492017-07-10 22:13:00 -070062 // Sane default matching ninja
63 ret.parallel = runtime.NumCPU() + 2
64 ret.keepGoing = 1
65
66 ret.parseArgs(ctx, args)
67
Dan Willemsen0c3919e2017-03-02 15:49:10 -080068 // Make sure OUT_DIR is set appropriately
Dan Willemsen02f3add2017-05-12 13:50:19 -070069 if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
70 ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
71 } else {
Dan Willemsen0c3919e2017-03-02 15:49:10 -080072 outDir := "out"
73 if baseDir, ok := ret.environ.Get("OUT_DIR_COMMON_BASE"); ok {
74 if wd, err := os.Getwd(); err != nil {
75 ctx.Fatalln("Failed to get working directory:", err)
76 } else {
77 outDir = filepath.Join(baseDir, filepath.Base(wd))
78 }
79 }
80 ret.environ.Set("OUT_DIR", outDir)
81 }
82
Dan Willemsen1e704462016-08-21 15:17:17 -070083 ret.environ.Unset(
84 // We're already using it
85 "USE_SOONG_UI",
86
87 // We should never use GOROOT/GOPATH from the shell environment
88 "GOROOT",
89 "GOPATH",
90
91 // These should only come from Soong, not the environment.
92 "CLANG",
93 "CLANG_CXX",
94 "CCC_CC",
95 "CCC_CXX",
96
97 // Used by the goma compiler wrapper, but should only be set by
98 // gomacc
99 "GOMACC_PATH",
Dan Willemsen0c3919e2017-03-02 15:49:10 -0800100
101 // We handle this above
102 "OUT_DIR_COMMON_BASE",
Dan Willemsen68a09852017-04-18 13:56:57 -0700103
104 // Variables that have caused problems in the past
105 "DISPLAY",
106 "GREP_OPTIONS",
Dan Willemsenc40e10b2017-07-11 14:30:00 -0700107
108 // Drop make flags
109 "MAKEFLAGS",
110 "MAKELEVEL",
111 "MFLAGS",
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700112
113 // Set in envsetup.sh, reset in makefiles
114 "ANDROID_JAVA_TOOLCHAIN",
Dan Willemsen1e704462016-08-21 15:17:17 -0700115 )
116
117 // Tell python not to spam the source tree with .pyc files.
118 ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
119
Dan Willemsen32a669b2018-03-08 19:42:00 -0800120 ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
121
Dan Willemsenc2af0be2017-01-20 14:10:01 -0800122 // Precondition: the current directory is the top of the source tree
123 if _, err := os.Stat(srcDirFileCheck); err != nil {
124 if os.IsNotExist(err) {
125 log.Fatalf("Current working directory must be the source tree. %q not found", srcDirFileCheck)
126 }
127 log.Fatalln("Error verifying tree state:", err)
128 }
129
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700130 if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
131 log.Println("You are building in a directory whose absolute path contains a space character:")
132 log.Println()
133 log.Printf("%q\n", srcDir)
134 log.Println()
135 log.Fatalln("Directory names containing spaces are not supported")
Dan Willemsendb8457c2017-05-12 16:38:17 -0700136 }
137
138 if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
139 log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
140 log.Println()
141 log.Printf("%q\n", outDir)
142 log.Println()
143 log.Fatalln("Directory names containing spaces are not supported")
144 }
145
146 if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
147 log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
148 log.Println()
149 log.Printf("%q\n", distDir)
150 log.Println()
151 log.Fatalln("Directory names containing spaces are not supported")
152 }
153
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700154 // Configure Java-related variables, including adding it to $PATH
Tobias Thierere59aeff2017-12-20 22:40:39 +0000155 java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
156 java9Home := filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700157 javaHome := func() string {
158 if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
159 return override
160 }
Tobias Thierer18099fd2017-11-17 14:14:29 +0000161 v, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK9")
162 if !ok {
163 v2, ok2 := ret.environ.Get("RUN_ERROR_PRONE")
164 if ok2 && (v2 == "true") {
165 v = "false"
166 } else {
167 v = "1.8"
168 }
169 }
170 if v != "false" {
Tobias Thierere59aeff2017-12-20 22:40:39 +0000171 return java9Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700172 }
Tobias Thierere59aeff2017-12-20 22:40:39 +0000173 return java8Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700174 }()
175 absJavaHome := absPath(ctx, javaHome)
176
Dan Willemsened869522018-01-08 14:58:46 -0800177 ret.configureLocale(ctx)
178
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700179 newPath := []string{filepath.Join(absJavaHome, "bin")}
180 if path, ok := ret.environ.Get("PATH"); ok && path != "" {
181 newPath = append(newPath, path)
182 }
183 ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
184 ret.environ.Set("JAVA_HOME", absJavaHome)
185 ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
Tobias Thierere59aeff2017-12-20 22:40:39 +0000186 ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
187 ret.environ.Set("ANDROID_JAVA9_HOME", java9Home)
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700188 ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
189
Nan Zhang2e6a4ff2018-02-14 13:27:26 -0800190 outDir := ret.OutDir()
191 buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
192 var content string
193 if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
194 content = buildDateTime
195 } else {
196 content = strconv.FormatInt(time.Now().Unix(), 10)
197 }
198 err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
199 if err != nil {
200 ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
201 }
202 ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
203
Dan Willemsen9b587492017-07-10 22:13:00 -0700204 return Config{ret}
205}
206
207func (c *configImpl) parseArgs(ctx Context, args []string) {
208 for i := 0; i < len(args); i++ {
209 arg := strings.TrimSpace(args[i])
Dan Willemsen1e704462016-08-21 15:17:17 -0700210 if arg == "--make-mode" {
Dan Willemsen1e704462016-08-21 15:17:17 -0700211 } else if arg == "showcommands" {
Dan Willemsen9b587492017-07-10 22:13:00 -0700212 c.verbose = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700213 } else if arg == "--skip-make" {
214 c.skipMake = true
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700215 } else if len(arg) > 0 && arg[0] == '-' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700216 parseArgNum := func(def int) int {
217 if len(arg) > 2 {
218 p, err := strconv.ParseUint(arg[2:], 10, 31)
219 if err != nil {
220 ctx.Fatalf("Failed to parse %q: %v", arg, err)
221 }
222 return int(p)
223 } else if i+1 < len(args) {
224 p, err := strconv.ParseUint(args[i+1], 10, 31)
225 if err == nil {
226 i++
227 return int(p)
228 }
229 }
230 return def
231 }
232
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700233 if len(arg) > 1 && arg[1] == 'j' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700234 c.parallel = parseArgNum(c.parallel)
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700235 } else if len(arg) > 1 && arg[1] == 'k' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700236 c.keepGoing = parseArgNum(0)
Dan Willemsen1e704462016-08-21 15:17:17 -0700237 } else {
238 ctx.Fatalln("Unknown option:", arg)
239 }
Dan Willemsen091525e2017-07-11 14:17:50 -0700240 } else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
241 c.environ.Set(k, v)
Dan Willemsen1e704462016-08-21 15:17:17 -0700242 } else {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700243 if arg == "dist" {
244 c.dist = true
Colin Cross37193492017-11-16 17:55:00 -0800245 } else if arg == "checkbuild" {
246 c.checkbuild = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700247 }
Dan Willemsen9b587492017-07-10 22:13:00 -0700248 c.arguments = append(c.arguments, arg)
Dan Willemsen1e704462016-08-21 15:17:17 -0700249 }
250 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700251}
252
Dan Willemsened869522018-01-08 14:58:46 -0800253func (c *configImpl) configureLocale(ctx Context) {
254 cmd := Command(ctx, Config{c}, "locale", "locale", "-a")
255 output, err := cmd.Output()
256
257 var locales []string
258 if err == nil {
259 locales = strings.Split(string(output), "\n")
260 } else {
261 // If we're unable to list the locales, let's assume en_US.UTF-8
262 locales = []string{"en_US.UTF-8"}
263 ctx.Verbosef("Failed to list locales (%q), falling back to %q", err, locales)
264 }
265
266 // gettext uses LANGUAGE, which is passed directly through
267
268 // For LANG and LC_*, only preserve the evaluated version of
269 // LC_MESSAGES
270 user_lang := ""
271 if lc_all, ok := c.environ.Get("LC_ALL"); ok {
272 user_lang = lc_all
273 } else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
274 user_lang = lc_messages
275 } else if lang, ok := c.environ.Get("LANG"); ok {
276 user_lang = lang
277 }
278
279 c.environ.UnsetWithPrefix("LC_")
280
281 if user_lang != "" {
282 c.environ.Set("LC_MESSAGES", user_lang)
283 }
284
285 // The for LANG, use C.UTF-8 if it exists (Debian currently, proposed
286 // for others)
287 if inList("C.UTF-8", locales) {
288 c.environ.Set("LANG", "C.UTF-8")
289 } else if inList("en_US.UTF-8", locales) {
290 c.environ.Set("LANG", "en_US.UTF-8")
291 } else if inList("en_US.utf8", locales) {
292 // These normalize to the same thing
293 c.environ.Set("LANG", "en_US.UTF-8")
294 } else {
295 ctx.Fatalln("System doesn't support either C.UTF-8 or en_US.UTF-8")
296 }
297}
298
Dan Willemsen1e704462016-08-21 15:17:17 -0700299// Lunch configures the environment for a specific product similarly to the
300// `lunch` bash function.
301func (c *configImpl) Lunch(ctx Context, product, variant string) {
302 if variant != "eng" && variant != "userdebug" && variant != "user" {
303 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
304 }
305
306 c.environ.Set("TARGET_PRODUCT", product)
307 c.environ.Set("TARGET_BUILD_VARIANT", variant)
308 c.environ.Set("TARGET_BUILD_TYPE", "release")
309 c.environ.Unset("TARGET_BUILD_APPS")
310}
311
312// Tapas configures the environment to build one or more unbundled apps,
313// similarly to the `tapas` bash function.
314func (c *configImpl) Tapas(ctx Context, apps []string, arch, variant string) {
315 if len(apps) == 0 {
316 apps = []string{"all"}
317 }
318 if variant == "" {
319 variant = "eng"
320 }
321
322 if variant != "eng" && variant != "userdebug" && variant != "user" {
323 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
324 }
325
326 var product string
327 switch arch {
Dan Willemsen1e704462016-08-21 15:17:17 -0700328 case "arm", "":
329 product = "aosp_arm"
330 case "arm64":
331 product = "aosm_arm64"
332 case "mips":
333 product = "aosp_mips"
334 case "mips64":
335 product = "aosp_mips64"
336 case "x86":
337 product = "aosp_x86"
338 case "x86_64":
339 product = "aosp_x86_64"
340 default:
341 ctx.Fatalf("Invalid architecture: %q", arch)
342 }
343
344 c.environ.Set("TARGET_PRODUCT", product)
345 c.environ.Set("TARGET_BUILD_VARIANT", variant)
346 c.environ.Set("TARGET_BUILD_TYPE", "release")
347 c.environ.Set("TARGET_BUILD_APPS", strings.Join(apps, " "))
348}
349
350func (c *configImpl) Environment() *Environment {
351 return c.environ
352}
353
354func (c *configImpl) Arguments() []string {
355 return c.arguments
356}
357
358func (c *configImpl) OutDir() string {
359 if outDir, ok := c.environ.Get("OUT_DIR"); ok {
360 return outDir
361 }
362 return "out"
363}
364
Dan Willemsen8a073a82017-02-04 17:30:44 -0800365func (c *configImpl) DistDir() string {
366 if distDir, ok := c.environ.Get("DIST_DIR"); ok {
367 return distDir
368 }
369 return filepath.Join(c.OutDir(), "dist")
370}
371
Dan Willemsen1e704462016-08-21 15:17:17 -0700372func (c *configImpl) NinjaArgs() []string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700373 if c.skipMake {
374 return c.arguments
375 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700376 return c.ninjaArgs
377}
378
379func (c *configImpl) SoongOutDir() string {
380 return filepath.Join(c.OutDir(), "soong")
381}
382
Jeff Gastonefc1b412017-03-29 17:29:06 -0700383func (c *configImpl) TempDir() string {
384 return shared.TempDirForOutDir(c.SoongOutDir())
385}
386
Jeff Gastonb64fc1c2017-08-04 12:30:12 -0700387func (c *configImpl) FileListDir() string {
388 return filepath.Join(c.OutDir(), ".module_paths")
389}
390
Dan Willemsen1e704462016-08-21 15:17:17 -0700391func (c *configImpl) KatiSuffix() string {
392 if c.katiSuffix != "" {
393 return c.katiSuffix
394 }
395 panic("SetKatiSuffix has not been called")
396}
397
Colin Cross37193492017-11-16 17:55:00 -0800398// Checkbuild returns true if "checkbuild" was one of the build goals, which means that the
399// user is interested in additional checks at the expense of build time.
400func (c *configImpl) Checkbuild() bool {
401 return c.checkbuild
402}
403
Dan Willemsen8a073a82017-02-04 17:30:44 -0800404func (c *configImpl) Dist() bool {
405 return c.dist
406}
407
Dan Willemsen1e704462016-08-21 15:17:17 -0700408func (c *configImpl) IsVerbose() bool {
409 return c.verbose
410}
411
Dan Willemsene0879fc2017-08-04 15:06:27 -0700412func (c *configImpl) SkipMake() bool {
413 return c.skipMake
414}
415
Dan Willemsen1e704462016-08-21 15:17:17 -0700416func (c *configImpl) TargetProduct() string {
417 if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
418 return v
419 }
420 panic("TARGET_PRODUCT is not defined")
421}
422
Dan Willemsen02781d52017-05-12 19:28:13 -0700423func (c *configImpl) TargetDevice() string {
424 return c.targetDevice
425}
426
427func (c *configImpl) SetTargetDevice(device string) {
428 c.targetDevice = device
429}
430
431func (c *configImpl) TargetBuildVariant() string {
432 if v, ok := c.environ.Get("TARGET_BUILD_VARIANT"); ok {
433 return v
434 }
435 panic("TARGET_BUILD_VARIANT is not defined")
436}
437
Dan Willemsen1e704462016-08-21 15:17:17 -0700438func (c *configImpl) KatiArgs() []string {
439 return c.katiArgs
440}
441
442func (c *configImpl) Parallel() int {
443 return c.parallel
444}
445
446func (c *configImpl) UseGoma() bool {
447 if v, ok := c.environ.Get("USE_GOMA"); ok {
448 v = strings.TrimSpace(v)
449 if v != "" && v != "false" {
450 return true
451 }
452 }
453 return false
454}
455
456// RemoteParallel controls how many remote jobs (i.e., commands which contain
Jeff Gastonefc1b412017-03-29 17:29:06 -0700457// gomacc) are run in parallel. Note the parallelism of all other jobs is
Dan Willemsen1e704462016-08-21 15:17:17 -0700458// still limited by Parallel()
459func (c *configImpl) RemoteParallel() int {
460 if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok {
461 if i, err := strconv.Atoi(v); err == nil {
462 return i
463 }
464 }
465 return 500
466}
467
468func (c *configImpl) SetKatiArgs(args []string) {
469 c.katiArgs = args
470}
471
472func (c *configImpl) SetNinjaArgs(args []string) {
473 c.ninjaArgs = args
474}
475
476func (c *configImpl) SetKatiSuffix(suffix string) {
477 c.katiSuffix = suffix
478}
479
Dan Willemsene0879fc2017-08-04 15:06:27 -0700480func (c *configImpl) LastKatiSuffixFile() string {
481 return filepath.Join(c.OutDir(), "last_kati_suffix")
482}
483
484func (c *configImpl) HasKatiSuffix() bool {
485 return c.katiSuffix != ""
486}
487
Dan Willemsen1e704462016-08-21 15:17:17 -0700488func (c *configImpl) KatiEnvFile() string {
489 return filepath.Join(c.OutDir(), "env"+c.KatiSuffix()+".sh")
490}
491
492func (c *configImpl) KatiNinjaFile() string {
493 return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+".ninja")
494}
495
496func (c *configImpl) SoongNinjaFile() string {
497 return filepath.Join(c.SoongOutDir(), "build.ninja")
498}
499
500func (c *configImpl) CombinedNinjaFile() string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700501 if c.katiSuffix == "" {
502 return filepath.Join(c.OutDir(), "combined.ninja")
503 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700504 return filepath.Join(c.OutDir(), "combined"+c.KatiSuffix()+".ninja")
505}
506
507func (c *configImpl) SoongAndroidMk() string {
508 return filepath.Join(c.SoongOutDir(), "Android-"+c.TargetProduct()+".mk")
509}
510
511func (c *configImpl) SoongMakeVarsMk() string {
512 return filepath.Join(c.SoongOutDir(), "make_vars-"+c.TargetProduct()+".mk")
513}
514
Dan Willemsenf052f782017-05-18 15:29:04 -0700515func (c *configImpl) ProductOut() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700516 return filepath.Join(c.OutDir(), "target", "product", c.TargetDevice())
Dan Willemsenf052f782017-05-18 15:29:04 -0700517}
518
Dan Willemsen02781d52017-05-12 19:28:13 -0700519func (c *configImpl) DevicePreviousProductConfig() string {
Dan Willemsenf052f782017-05-18 15:29:04 -0700520 return filepath.Join(c.ProductOut(), "previous_build_config.mk")
521}
522
523func (c *configImpl) hostOutRoot() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700524 return filepath.Join(c.OutDir(), "host")
Dan Willemsenf052f782017-05-18 15:29:04 -0700525}
526
527func (c *configImpl) HostOut() string {
528 return filepath.Join(c.hostOutRoot(), c.HostPrebuiltTag())
529}
530
531// This probably needs to be multi-valued, so not exporting it for now
532func (c *configImpl) hostCrossOut() string {
533 if runtime.GOOS == "linux" {
534 return filepath.Join(c.hostOutRoot(), "windows-x86")
535 } else {
536 return ""
537 }
Dan Willemsen02781d52017-05-12 19:28:13 -0700538}
539
Dan Willemsen1e704462016-08-21 15:17:17 -0700540func (c *configImpl) HostPrebuiltTag() string {
541 if runtime.GOOS == "linux" {
542 return "linux-x86"
543 } else if runtime.GOOS == "darwin" {
544 return "darwin-x86"
545 } else {
546 panic("Unsupported OS")
547 }
548}
Dan Willemsenf173d592017-04-27 14:28:00 -0700549
Dan Willemsen8122bd52017-10-12 20:20:41 -0700550func (c *configImpl) PrebuiltBuildTool(name string) string {
Dan Willemsenf173d592017-04-27 14:28:00 -0700551 if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
552 if sanitize := strings.Fields(v); inList("address", sanitize) {
Dan Willemsen8122bd52017-10-12 20:20:41 -0700553 asan := filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "asan/bin", name)
554 if _, err := os.Stat(asan); err == nil {
555 return asan
556 }
Dan Willemsenf173d592017-04-27 14:28:00 -0700557 }
558 }
559 return filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "bin", name)
560}
Dan Willemsen3d60b112018-04-04 22:25:56 -0700561
562func (c *configImpl) SetBuildBrokenDupRules(val bool) {
563 c.brokenDupRules = val
564}
565
566func (c *configImpl) BuildBrokenDupRules() bool {
567 return c.brokenDupRules
568}