blob: 530c3a892fc82a54f45631953950643f10e4a4de [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
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700105 "CDPATH",
Dan Willemsen68a09852017-04-18 13:56:57 -0700106 "DISPLAY",
107 "GREP_OPTIONS",
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700108 "NDK_ROOT",
Dan Willemsenc40e10b2017-07-11 14:30:00 -0700109
110 // Drop make flags
111 "MAKEFLAGS",
112 "MAKELEVEL",
113 "MFLAGS",
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700114
115 // Set in envsetup.sh, reset in makefiles
116 "ANDROID_JAVA_TOOLCHAIN",
Dan Willemsen1e704462016-08-21 15:17:17 -0700117 )
118
119 // Tell python not to spam the source tree with .pyc files.
120 ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
121
Dan Willemsen32a669b2018-03-08 19:42:00 -0800122 ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
123
Dan Willemsenc2af0be2017-01-20 14:10:01 -0800124 // Precondition: the current directory is the top of the source tree
125 if _, err := os.Stat(srcDirFileCheck); err != nil {
126 if os.IsNotExist(err) {
127 log.Fatalf("Current working directory must be the source tree. %q not found", srcDirFileCheck)
128 }
129 log.Fatalln("Error verifying tree state:", err)
130 }
131
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700132 if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
133 log.Println("You are building in a directory whose absolute path contains a space character:")
134 log.Println()
135 log.Printf("%q\n", srcDir)
136 log.Println()
137 log.Fatalln("Directory names containing spaces are not supported")
Dan Willemsendb8457c2017-05-12 16:38:17 -0700138 }
139
140 if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
141 log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
142 log.Println()
143 log.Printf("%q\n", outDir)
144 log.Println()
145 log.Fatalln("Directory names containing spaces are not supported")
146 }
147
148 if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
149 log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
150 log.Println()
151 log.Printf("%q\n", distDir)
152 log.Println()
153 log.Fatalln("Directory names containing spaces are not supported")
154 }
155
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700156 // Configure Java-related variables, including adding it to $PATH
Tobias Thierere59aeff2017-12-20 22:40:39 +0000157 java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
158 java9Home := filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700159 javaHome := func() string {
160 if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
161 return override
162 }
Tobias Thierer18099fd2017-11-17 14:14:29 +0000163 v, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK9")
164 if !ok {
165 v2, ok2 := ret.environ.Get("RUN_ERROR_PRONE")
166 if ok2 && (v2 == "true") {
167 v = "false"
168 } else {
169 v = "1.8"
170 }
171 }
172 if v != "false" {
Tobias Thierere59aeff2017-12-20 22:40:39 +0000173 return java9Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700174 }
Tobias Thierere59aeff2017-12-20 22:40:39 +0000175 return java8Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700176 }()
177 absJavaHome := absPath(ctx, javaHome)
178
Dan Willemsened869522018-01-08 14:58:46 -0800179 ret.configureLocale(ctx)
180
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700181 newPath := []string{filepath.Join(absJavaHome, "bin")}
182 if path, ok := ret.environ.Get("PATH"); ok && path != "" {
183 newPath = append(newPath, path)
184 }
185 ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
186 ret.environ.Set("JAVA_HOME", absJavaHome)
187 ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
Tobias Thierere59aeff2017-12-20 22:40:39 +0000188 ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
189 ret.environ.Set("ANDROID_JAVA9_HOME", java9Home)
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700190 ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
191
Nan Zhang2e6a4ff2018-02-14 13:27:26 -0800192 outDir := ret.OutDir()
193 buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
194 var content string
195 if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
196 content = buildDateTime
197 } else {
198 content = strconv.FormatInt(time.Now().Unix(), 10)
199 }
200 err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
201 if err != nil {
202 ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
203 }
204 ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
205
Dan Willemsen9b587492017-07-10 22:13:00 -0700206 return Config{ret}
207}
208
209func (c *configImpl) parseArgs(ctx Context, args []string) {
210 for i := 0; i < len(args); i++ {
211 arg := strings.TrimSpace(args[i])
Dan Willemsen1e704462016-08-21 15:17:17 -0700212 if arg == "--make-mode" {
Dan Willemsen1e704462016-08-21 15:17:17 -0700213 } else if arg == "showcommands" {
Dan Willemsen9b587492017-07-10 22:13:00 -0700214 c.verbose = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700215 } else if arg == "--skip-make" {
216 c.skipMake = true
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700217 } else if len(arg) > 0 && arg[0] == '-' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700218 parseArgNum := func(def int) int {
219 if len(arg) > 2 {
220 p, err := strconv.ParseUint(arg[2:], 10, 31)
221 if err != nil {
222 ctx.Fatalf("Failed to parse %q: %v", arg, err)
223 }
224 return int(p)
225 } else if i+1 < len(args) {
226 p, err := strconv.ParseUint(args[i+1], 10, 31)
227 if err == nil {
228 i++
229 return int(p)
230 }
231 }
232 return def
233 }
234
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700235 if len(arg) > 1 && arg[1] == 'j' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700236 c.parallel = parseArgNum(c.parallel)
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700237 } else if len(arg) > 1 && arg[1] == 'k' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700238 c.keepGoing = parseArgNum(0)
Dan Willemsen1e704462016-08-21 15:17:17 -0700239 } else {
240 ctx.Fatalln("Unknown option:", arg)
241 }
Dan Willemsen091525e2017-07-11 14:17:50 -0700242 } else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
243 c.environ.Set(k, v)
Dan Willemsen1e704462016-08-21 15:17:17 -0700244 } else {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700245 if arg == "dist" {
246 c.dist = true
Colin Cross37193492017-11-16 17:55:00 -0800247 } else if arg == "checkbuild" {
248 c.checkbuild = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700249 }
Dan Willemsen9b587492017-07-10 22:13:00 -0700250 c.arguments = append(c.arguments, arg)
Dan Willemsen1e704462016-08-21 15:17:17 -0700251 }
252 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700253}
254
Dan Willemsened869522018-01-08 14:58:46 -0800255func (c *configImpl) configureLocale(ctx Context) {
256 cmd := Command(ctx, Config{c}, "locale", "locale", "-a")
257 output, err := cmd.Output()
258
259 var locales []string
260 if err == nil {
261 locales = strings.Split(string(output), "\n")
262 } else {
263 // If we're unable to list the locales, let's assume en_US.UTF-8
264 locales = []string{"en_US.UTF-8"}
265 ctx.Verbosef("Failed to list locales (%q), falling back to %q", err, locales)
266 }
267
268 // gettext uses LANGUAGE, which is passed directly through
269
270 // For LANG and LC_*, only preserve the evaluated version of
271 // LC_MESSAGES
272 user_lang := ""
273 if lc_all, ok := c.environ.Get("LC_ALL"); ok {
274 user_lang = lc_all
275 } else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
276 user_lang = lc_messages
277 } else if lang, ok := c.environ.Get("LANG"); ok {
278 user_lang = lang
279 }
280
281 c.environ.UnsetWithPrefix("LC_")
282
283 if user_lang != "" {
284 c.environ.Set("LC_MESSAGES", user_lang)
285 }
286
287 // The for LANG, use C.UTF-8 if it exists (Debian currently, proposed
288 // for others)
289 if inList("C.UTF-8", locales) {
290 c.environ.Set("LANG", "C.UTF-8")
291 } else if inList("en_US.UTF-8", locales) {
292 c.environ.Set("LANG", "en_US.UTF-8")
293 } else if inList("en_US.utf8", locales) {
294 // These normalize to the same thing
295 c.environ.Set("LANG", "en_US.UTF-8")
296 } else {
297 ctx.Fatalln("System doesn't support either C.UTF-8 or en_US.UTF-8")
298 }
299}
300
Dan Willemsen1e704462016-08-21 15:17:17 -0700301// Lunch configures the environment for a specific product similarly to the
302// `lunch` bash function.
303func (c *configImpl) Lunch(ctx Context, product, variant string) {
304 if variant != "eng" && variant != "userdebug" && variant != "user" {
305 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
306 }
307
308 c.environ.Set("TARGET_PRODUCT", product)
309 c.environ.Set("TARGET_BUILD_VARIANT", variant)
310 c.environ.Set("TARGET_BUILD_TYPE", "release")
311 c.environ.Unset("TARGET_BUILD_APPS")
312}
313
314// Tapas configures the environment to build one or more unbundled apps,
315// similarly to the `tapas` bash function.
316func (c *configImpl) Tapas(ctx Context, apps []string, arch, variant string) {
317 if len(apps) == 0 {
318 apps = []string{"all"}
319 }
320 if variant == "" {
321 variant = "eng"
322 }
323
324 if variant != "eng" && variant != "userdebug" && variant != "user" {
325 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
326 }
327
328 var product string
329 switch arch {
Dan Willemsen1e704462016-08-21 15:17:17 -0700330 case "arm", "":
331 product = "aosp_arm"
332 case "arm64":
333 product = "aosm_arm64"
334 case "mips":
335 product = "aosp_mips"
336 case "mips64":
337 product = "aosp_mips64"
338 case "x86":
339 product = "aosp_x86"
340 case "x86_64":
341 product = "aosp_x86_64"
342 default:
343 ctx.Fatalf("Invalid architecture: %q", arch)
344 }
345
346 c.environ.Set("TARGET_PRODUCT", product)
347 c.environ.Set("TARGET_BUILD_VARIANT", variant)
348 c.environ.Set("TARGET_BUILD_TYPE", "release")
349 c.environ.Set("TARGET_BUILD_APPS", strings.Join(apps, " "))
350}
351
352func (c *configImpl) Environment() *Environment {
353 return c.environ
354}
355
356func (c *configImpl) Arguments() []string {
357 return c.arguments
358}
359
360func (c *configImpl) OutDir() string {
361 if outDir, ok := c.environ.Get("OUT_DIR"); ok {
362 return outDir
363 }
364 return "out"
365}
366
Dan Willemsen8a073a82017-02-04 17:30:44 -0800367func (c *configImpl) DistDir() string {
368 if distDir, ok := c.environ.Get("DIST_DIR"); ok {
369 return distDir
370 }
371 return filepath.Join(c.OutDir(), "dist")
372}
373
Dan Willemsen1e704462016-08-21 15:17:17 -0700374func (c *configImpl) NinjaArgs() []string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700375 if c.skipMake {
376 return c.arguments
377 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700378 return c.ninjaArgs
379}
380
381func (c *configImpl) SoongOutDir() string {
382 return filepath.Join(c.OutDir(), "soong")
383}
384
Jeff Gastonefc1b412017-03-29 17:29:06 -0700385func (c *configImpl) TempDir() string {
386 return shared.TempDirForOutDir(c.SoongOutDir())
387}
388
Jeff Gastonb64fc1c2017-08-04 12:30:12 -0700389func (c *configImpl) FileListDir() string {
390 return filepath.Join(c.OutDir(), ".module_paths")
391}
392
Dan Willemsen1e704462016-08-21 15:17:17 -0700393func (c *configImpl) KatiSuffix() string {
394 if c.katiSuffix != "" {
395 return c.katiSuffix
396 }
397 panic("SetKatiSuffix has not been called")
398}
399
Colin Cross37193492017-11-16 17:55:00 -0800400// Checkbuild returns true if "checkbuild" was one of the build goals, which means that the
401// user is interested in additional checks at the expense of build time.
402func (c *configImpl) Checkbuild() bool {
403 return c.checkbuild
404}
405
Dan Willemsen8a073a82017-02-04 17:30:44 -0800406func (c *configImpl) Dist() bool {
407 return c.dist
408}
409
Dan Willemsen1e704462016-08-21 15:17:17 -0700410func (c *configImpl) IsVerbose() bool {
411 return c.verbose
412}
413
Dan Willemsene0879fc2017-08-04 15:06:27 -0700414func (c *configImpl) SkipMake() bool {
415 return c.skipMake
416}
417
Dan Willemsen1e704462016-08-21 15:17:17 -0700418func (c *configImpl) TargetProduct() string {
419 if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
420 return v
421 }
422 panic("TARGET_PRODUCT is not defined")
423}
424
Dan Willemsen02781d52017-05-12 19:28:13 -0700425func (c *configImpl) TargetDevice() string {
426 return c.targetDevice
427}
428
429func (c *configImpl) SetTargetDevice(device string) {
430 c.targetDevice = device
431}
432
433func (c *configImpl) TargetBuildVariant() string {
434 if v, ok := c.environ.Get("TARGET_BUILD_VARIANT"); ok {
435 return v
436 }
437 panic("TARGET_BUILD_VARIANT is not defined")
438}
439
Dan Willemsen1e704462016-08-21 15:17:17 -0700440func (c *configImpl) KatiArgs() []string {
441 return c.katiArgs
442}
443
444func (c *configImpl) Parallel() int {
445 return c.parallel
446}
447
448func (c *configImpl) UseGoma() bool {
449 if v, ok := c.environ.Get("USE_GOMA"); ok {
450 v = strings.TrimSpace(v)
451 if v != "" && v != "false" {
452 return true
453 }
454 }
455 return false
456}
457
458// RemoteParallel controls how many remote jobs (i.e., commands which contain
Jeff Gastonefc1b412017-03-29 17:29:06 -0700459// gomacc) are run in parallel. Note the parallelism of all other jobs is
Dan Willemsen1e704462016-08-21 15:17:17 -0700460// still limited by Parallel()
461func (c *configImpl) RemoteParallel() int {
462 if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok {
463 if i, err := strconv.Atoi(v); err == nil {
464 return i
465 }
466 }
467 return 500
468}
469
470func (c *configImpl) SetKatiArgs(args []string) {
471 c.katiArgs = args
472}
473
474func (c *configImpl) SetNinjaArgs(args []string) {
475 c.ninjaArgs = args
476}
477
478func (c *configImpl) SetKatiSuffix(suffix string) {
479 c.katiSuffix = suffix
480}
481
Dan Willemsene0879fc2017-08-04 15:06:27 -0700482func (c *configImpl) LastKatiSuffixFile() string {
483 return filepath.Join(c.OutDir(), "last_kati_suffix")
484}
485
486func (c *configImpl) HasKatiSuffix() bool {
487 return c.katiSuffix != ""
488}
489
Dan Willemsen1e704462016-08-21 15:17:17 -0700490func (c *configImpl) KatiEnvFile() string {
491 return filepath.Join(c.OutDir(), "env"+c.KatiSuffix()+".sh")
492}
493
494func (c *configImpl) KatiNinjaFile() string {
495 return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+".ninja")
496}
497
498func (c *configImpl) SoongNinjaFile() string {
499 return filepath.Join(c.SoongOutDir(), "build.ninja")
500}
501
502func (c *configImpl) CombinedNinjaFile() string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700503 if c.katiSuffix == "" {
504 return filepath.Join(c.OutDir(), "combined.ninja")
505 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700506 return filepath.Join(c.OutDir(), "combined"+c.KatiSuffix()+".ninja")
507}
508
509func (c *configImpl) SoongAndroidMk() string {
510 return filepath.Join(c.SoongOutDir(), "Android-"+c.TargetProduct()+".mk")
511}
512
513func (c *configImpl) SoongMakeVarsMk() string {
514 return filepath.Join(c.SoongOutDir(), "make_vars-"+c.TargetProduct()+".mk")
515}
516
Dan Willemsenf052f782017-05-18 15:29:04 -0700517func (c *configImpl) ProductOut() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700518 return filepath.Join(c.OutDir(), "target", "product", c.TargetDevice())
Dan Willemsenf052f782017-05-18 15:29:04 -0700519}
520
Dan Willemsen02781d52017-05-12 19:28:13 -0700521func (c *configImpl) DevicePreviousProductConfig() string {
Dan Willemsenf052f782017-05-18 15:29:04 -0700522 return filepath.Join(c.ProductOut(), "previous_build_config.mk")
523}
524
525func (c *configImpl) hostOutRoot() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700526 return filepath.Join(c.OutDir(), "host")
Dan Willemsenf052f782017-05-18 15:29:04 -0700527}
528
529func (c *configImpl) HostOut() string {
530 return filepath.Join(c.hostOutRoot(), c.HostPrebuiltTag())
531}
532
533// This probably needs to be multi-valued, so not exporting it for now
534func (c *configImpl) hostCrossOut() string {
535 if runtime.GOOS == "linux" {
536 return filepath.Join(c.hostOutRoot(), "windows-x86")
537 } else {
538 return ""
539 }
Dan Willemsen02781d52017-05-12 19:28:13 -0700540}
541
Dan Willemsen1e704462016-08-21 15:17:17 -0700542func (c *configImpl) HostPrebuiltTag() string {
543 if runtime.GOOS == "linux" {
544 return "linux-x86"
545 } else if runtime.GOOS == "darwin" {
546 return "darwin-x86"
547 } else {
548 panic("Unsupported OS")
549 }
550}
Dan Willemsenf173d592017-04-27 14:28:00 -0700551
Dan Willemsen8122bd52017-10-12 20:20:41 -0700552func (c *configImpl) PrebuiltBuildTool(name string) string {
Dan Willemsenf173d592017-04-27 14:28:00 -0700553 if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
554 if sanitize := strings.Fields(v); inList("address", sanitize) {
Dan Willemsen8122bd52017-10-12 20:20:41 -0700555 asan := filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "asan/bin", name)
556 if _, err := os.Stat(asan); err == nil {
557 return asan
558 }
Dan Willemsenf173d592017-04-27 14:28:00 -0700559 }
560 }
561 return filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "bin", name)
562}
Dan Willemsen3d60b112018-04-04 22:25:56 -0700563
564func (c *configImpl) SetBuildBrokenDupRules(val bool) {
565 c.brokenDupRules = val
566}
567
568func (c *configImpl) BuildBrokenDupRules() bool {
569 return c.brokenDupRules
570}