blob: 5622dff64e828f9f315a5b56bf9ec9c4f68fb688 [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 Willemsen6ab79db2018-05-02 00:06:28 -070047 katiArgs []string
48 ninjaArgs []string
49 katiSuffix string
50 targetDevice string
51 targetDeviceDir string
Dan Willemsen3d60b112018-04-04 22:25:56 -070052
53 brokenDupRules bool
Dan Willemsen1e704462016-08-21 15:17:17 -070054}
55
Dan Willemsenc2af0be2017-01-20 14:10:01 -080056const srcDirFileCheck = "build/soong/root.bp"
57
Dan Willemsen1e704462016-08-21 15:17:17 -070058func NewConfig(ctx Context, args ...string) Config {
59 ret := &configImpl{
60 environ: OsEnvironment(),
61 }
62
Dan Willemsen9b587492017-07-10 22:13:00 -070063 // Sane default matching ninja
64 ret.parallel = runtime.NumCPU() + 2
65 ret.keepGoing = 1
66
67 ret.parseArgs(ctx, args)
68
Dan Willemsen0c3919e2017-03-02 15:49:10 -080069 // Make sure OUT_DIR is set appropriately
Dan Willemsen02f3add2017-05-12 13:50:19 -070070 if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
71 ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
72 } else {
Dan Willemsen0c3919e2017-03-02 15:49:10 -080073 outDir := "out"
74 if baseDir, ok := ret.environ.Get("OUT_DIR_COMMON_BASE"); ok {
75 if wd, err := os.Getwd(); err != nil {
76 ctx.Fatalln("Failed to get working directory:", err)
77 } else {
78 outDir = filepath.Join(baseDir, filepath.Base(wd))
79 }
80 }
81 ret.environ.Set("OUT_DIR", outDir)
82 }
83
Dan Willemsen1e704462016-08-21 15:17:17 -070084 ret.environ.Unset(
85 // We're already using it
86 "USE_SOONG_UI",
87
88 // We should never use GOROOT/GOPATH from the shell environment
89 "GOROOT",
90 "GOPATH",
91
92 // These should only come from Soong, not the environment.
93 "CLANG",
94 "CLANG_CXX",
95 "CCC_CC",
96 "CCC_CXX",
97
98 // Used by the goma compiler wrapper, but should only be set by
99 // gomacc
100 "GOMACC_PATH",
Dan Willemsen0c3919e2017-03-02 15:49:10 -0800101
102 // We handle this above
103 "OUT_DIR_COMMON_BASE",
Dan Willemsen68a09852017-04-18 13:56:57 -0700104
105 // Variables that have caused problems in the past
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700106 "CDPATH",
Dan Willemsen68a09852017-04-18 13:56:57 -0700107 "DISPLAY",
108 "GREP_OPTIONS",
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700109 "NDK_ROOT",
Dan Willemsenc40e10b2017-07-11 14:30:00 -0700110
111 // Drop make flags
112 "MAKEFLAGS",
113 "MAKELEVEL",
114 "MFLAGS",
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700115
116 // Set in envsetup.sh, reset in makefiles
117 "ANDROID_JAVA_TOOLCHAIN",
Dan Willemsen1e704462016-08-21 15:17:17 -0700118 )
119
120 // Tell python not to spam the source tree with .pyc files.
121 ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
122
Dan Willemsen32a669b2018-03-08 19:42:00 -0800123 ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
124
Dan Willemsenc2af0be2017-01-20 14:10:01 -0800125 // Precondition: the current directory is the top of the source tree
126 if _, err := os.Stat(srcDirFileCheck); err != nil {
127 if os.IsNotExist(err) {
128 log.Fatalf("Current working directory must be the source tree. %q not found", srcDirFileCheck)
129 }
130 log.Fatalln("Error verifying tree state:", err)
131 }
132
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700133 if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
134 log.Println("You are building in a directory whose absolute path contains a space character:")
135 log.Println()
136 log.Printf("%q\n", srcDir)
137 log.Println()
138 log.Fatalln("Directory names containing spaces are not supported")
Dan Willemsendb8457c2017-05-12 16:38:17 -0700139 }
140
141 if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
142 log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
143 log.Println()
144 log.Printf("%q\n", outDir)
145 log.Println()
146 log.Fatalln("Directory names containing spaces are not supported")
147 }
148
149 if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
150 log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
151 log.Println()
152 log.Printf("%q\n", distDir)
153 log.Println()
154 log.Fatalln("Directory names containing spaces are not supported")
155 }
156
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700157 // Configure Java-related variables, including adding it to $PATH
Tobias Thierere59aeff2017-12-20 22:40:39 +0000158 java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
159 java9Home := filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700160 javaHome := func() string {
161 if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
162 return override
163 }
Tobias Thierer18099fd2017-11-17 14:14:29 +0000164 v, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK9")
165 if !ok {
166 v2, ok2 := ret.environ.Get("RUN_ERROR_PRONE")
167 if ok2 && (v2 == "true") {
168 v = "false"
169 } else {
170 v = "1.8"
171 }
172 }
173 if v != "false" {
Tobias Thierere59aeff2017-12-20 22:40:39 +0000174 return java9Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700175 }
Tobias Thierere59aeff2017-12-20 22:40:39 +0000176 return java8Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700177 }()
178 absJavaHome := absPath(ctx, javaHome)
179
Dan Willemsened869522018-01-08 14:58:46 -0800180 ret.configureLocale(ctx)
181
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700182 newPath := []string{filepath.Join(absJavaHome, "bin")}
183 if path, ok := ret.environ.Get("PATH"); ok && path != "" {
184 newPath = append(newPath, path)
185 }
186 ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
187 ret.environ.Set("JAVA_HOME", absJavaHome)
188 ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
Tobias Thierere59aeff2017-12-20 22:40:39 +0000189 ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
190 ret.environ.Set("ANDROID_JAVA9_HOME", java9Home)
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700191 ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
192
Nan Zhang2e6a4ff2018-02-14 13:27:26 -0800193 outDir := ret.OutDir()
194 buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
195 var content string
196 if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
197 content = buildDateTime
198 } else {
199 content = strconv.FormatInt(time.Now().Unix(), 10)
200 }
201 err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
202 if err != nil {
203 ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
204 }
205 ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
206
Dan Willemsen9b587492017-07-10 22:13:00 -0700207 return Config{ret}
208}
209
210func (c *configImpl) parseArgs(ctx Context, args []string) {
211 for i := 0; i < len(args); i++ {
212 arg := strings.TrimSpace(args[i])
Dan Willemsen1e704462016-08-21 15:17:17 -0700213 if arg == "--make-mode" {
Dan Willemsen1e704462016-08-21 15:17:17 -0700214 } else if arg == "showcommands" {
Dan Willemsen9b587492017-07-10 22:13:00 -0700215 c.verbose = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700216 } else if arg == "--skip-make" {
217 c.skipMake = true
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700218 } else if len(arg) > 0 && arg[0] == '-' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700219 parseArgNum := func(def int) int {
220 if len(arg) > 2 {
221 p, err := strconv.ParseUint(arg[2:], 10, 31)
222 if err != nil {
223 ctx.Fatalf("Failed to parse %q: %v", arg, err)
224 }
225 return int(p)
226 } else if i+1 < len(args) {
227 p, err := strconv.ParseUint(args[i+1], 10, 31)
228 if err == nil {
229 i++
230 return int(p)
231 }
232 }
233 return def
234 }
235
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700236 if len(arg) > 1 && arg[1] == 'j' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700237 c.parallel = parseArgNum(c.parallel)
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700238 } else if len(arg) > 1 && arg[1] == 'k' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700239 c.keepGoing = parseArgNum(0)
Dan Willemsen1e704462016-08-21 15:17:17 -0700240 } else {
241 ctx.Fatalln("Unknown option:", arg)
242 }
Dan Willemsen091525e2017-07-11 14:17:50 -0700243 } else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
244 c.environ.Set(k, v)
Dan Willemsen1e704462016-08-21 15:17:17 -0700245 } else {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700246 if arg == "dist" {
247 c.dist = true
Colin Cross37193492017-11-16 17:55:00 -0800248 } else if arg == "checkbuild" {
249 c.checkbuild = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700250 }
Dan Willemsen9b587492017-07-10 22:13:00 -0700251 c.arguments = append(c.arguments, arg)
Dan Willemsen1e704462016-08-21 15:17:17 -0700252 }
253 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700254}
255
Dan Willemsened869522018-01-08 14:58:46 -0800256func (c *configImpl) configureLocale(ctx Context) {
257 cmd := Command(ctx, Config{c}, "locale", "locale", "-a")
258 output, err := cmd.Output()
259
260 var locales []string
261 if err == nil {
262 locales = strings.Split(string(output), "\n")
263 } else {
264 // If we're unable to list the locales, let's assume en_US.UTF-8
265 locales = []string{"en_US.UTF-8"}
266 ctx.Verbosef("Failed to list locales (%q), falling back to %q", err, locales)
267 }
268
269 // gettext uses LANGUAGE, which is passed directly through
270
271 // For LANG and LC_*, only preserve the evaluated version of
272 // LC_MESSAGES
273 user_lang := ""
274 if lc_all, ok := c.environ.Get("LC_ALL"); ok {
275 user_lang = lc_all
276 } else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
277 user_lang = lc_messages
278 } else if lang, ok := c.environ.Get("LANG"); ok {
279 user_lang = lang
280 }
281
282 c.environ.UnsetWithPrefix("LC_")
283
284 if user_lang != "" {
285 c.environ.Set("LC_MESSAGES", user_lang)
286 }
287
288 // The for LANG, use C.UTF-8 if it exists (Debian currently, proposed
289 // for others)
290 if inList("C.UTF-8", locales) {
291 c.environ.Set("LANG", "C.UTF-8")
292 } else if inList("en_US.UTF-8", locales) {
293 c.environ.Set("LANG", "en_US.UTF-8")
294 } else if inList("en_US.utf8", locales) {
295 // These normalize to the same thing
296 c.environ.Set("LANG", "en_US.UTF-8")
297 } else {
298 ctx.Fatalln("System doesn't support either C.UTF-8 or en_US.UTF-8")
299 }
300}
301
Dan Willemsen1e704462016-08-21 15:17:17 -0700302// Lunch configures the environment for a specific product similarly to the
303// `lunch` bash function.
304func (c *configImpl) Lunch(ctx Context, product, variant string) {
305 if variant != "eng" && variant != "userdebug" && variant != "user" {
306 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
307 }
308
309 c.environ.Set("TARGET_PRODUCT", product)
310 c.environ.Set("TARGET_BUILD_VARIANT", variant)
311 c.environ.Set("TARGET_BUILD_TYPE", "release")
312 c.environ.Unset("TARGET_BUILD_APPS")
313}
314
315// Tapas configures the environment to build one or more unbundled apps,
316// similarly to the `tapas` bash function.
317func (c *configImpl) Tapas(ctx Context, apps []string, arch, variant string) {
318 if len(apps) == 0 {
319 apps = []string{"all"}
320 }
321 if variant == "" {
322 variant = "eng"
323 }
324
325 if variant != "eng" && variant != "userdebug" && variant != "user" {
326 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
327 }
328
329 var product string
330 switch arch {
Dan Willemsen1e704462016-08-21 15:17:17 -0700331 case "arm", "":
332 product = "aosp_arm"
333 case "arm64":
334 product = "aosm_arm64"
335 case "mips":
336 product = "aosp_mips"
337 case "mips64":
338 product = "aosp_mips64"
339 case "x86":
340 product = "aosp_x86"
341 case "x86_64":
342 product = "aosp_x86_64"
343 default:
344 ctx.Fatalf("Invalid architecture: %q", arch)
345 }
346
347 c.environ.Set("TARGET_PRODUCT", product)
348 c.environ.Set("TARGET_BUILD_VARIANT", variant)
349 c.environ.Set("TARGET_BUILD_TYPE", "release")
350 c.environ.Set("TARGET_BUILD_APPS", strings.Join(apps, " "))
351}
352
353func (c *configImpl) Environment() *Environment {
354 return c.environ
355}
356
357func (c *configImpl) Arguments() []string {
358 return c.arguments
359}
360
361func (c *configImpl) OutDir() string {
362 if outDir, ok := c.environ.Get("OUT_DIR"); ok {
363 return outDir
364 }
365 return "out"
366}
367
Dan Willemsen8a073a82017-02-04 17:30:44 -0800368func (c *configImpl) DistDir() string {
369 if distDir, ok := c.environ.Get("DIST_DIR"); ok {
370 return distDir
371 }
372 return filepath.Join(c.OutDir(), "dist")
373}
374
Dan Willemsen1e704462016-08-21 15:17:17 -0700375func (c *configImpl) NinjaArgs() []string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700376 if c.skipMake {
377 return c.arguments
378 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700379 return c.ninjaArgs
380}
381
382func (c *configImpl) SoongOutDir() string {
383 return filepath.Join(c.OutDir(), "soong")
384}
385
Jeff Gastonefc1b412017-03-29 17:29:06 -0700386func (c *configImpl) TempDir() string {
387 return shared.TempDirForOutDir(c.SoongOutDir())
388}
389
Jeff Gastonb64fc1c2017-08-04 12:30:12 -0700390func (c *configImpl) FileListDir() string {
391 return filepath.Join(c.OutDir(), ".module_paths")
392}
393
Dan Willemsen1e704462016-08-21 15:17:17 -0700394func (c *configImpl) KatiSuffix() string {
395 if c.katiSuffix != "" {
396 return c.katiSuffix
397 }
398 panic("SetKatiSuffix has not been called")
399}
400
Colin Cross37193492017-11-16 17:55:00 -0800401// Checkbuild returns true if "checkbuild" was one of the build goals, which means that the
402// user is interested in additional checks at the expense of build time.
403func (c *configImpl) Checkbuild() bool {
404 return c.checkbuild
405}
406
Dan Willemsen8a073a82017-02-04 17:30:44 -0800407func (c *configImpl) Dist() bool {
408 return c.dist
409}
410
Dan Willemsen1e704462016-08-21 15:17:17 -0700411func (c *configImpl) IsVerbose() bool {
412 return c.verbose
413}
414
Dan Willemsene0879fc2017-08-04 15:06:27 -0700415func (c *configImpl) SkipMake() bool {
416 return c.skipMake
417}
418
Dan Willemsen1e704462016-08-21 15:17:17 -0700419func (c *configImpl) TargetProduct() string {
420 if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
421 return v
422 }
423 panic("TARGET_PRODUCT is not defined")
424}
425
Dan Willemsen02781d52017-05-12 19:28:13 -0700426func (c *configImpl) TargetDevice() string {
427 return c.targetDevice
428}
429
430func (c *configImpl) SetTargetDevice(device string) {
431 c.targetDevice = device
432}
433
434func (c *configImpl) TargetBuildVariant() string {
435 if v, ok := c.environ.Get("TARGET_BUILD_VARIANT"); ok {
436 return v
437 }
438 panic("TARGET_BUILD_VARIANT is not defined")
439}
440
Dan Willemsen1e704462016-08-21 15:17:17 -0700441func (c *configImpl) KatiArgs() []string {
442 return c.katiArgs
443}
444
445func (c *configImpl) Parallel() int {
446 return c.parallel
447}
448
449func (c *configImpl) UseGoma() bool {
450 if v, ok := c.environ.Get("USE_GOMA"); ok {
451 v = strings.TrimSpace(v)
452 if v != "" && v != "false" {
453 return true
454 }
455 }
456 return false
457}
458
459// RemoteParallel controls how many remote jobs (i.e., commands which contain
Jeff Gastonefc1b412017-03-29 17:29:06 -0700460// gomacc) are run in parallel. Note the parallelism of all other jobs is
Dan Willemsen1e704462016-08-21 15:17:17 -0700461// still limited by Parallel()
462func (c *configImpl) RemoteParallel() int {
463 if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok {
464 if i, err := strconv.Atoi(v); err == nil {
465 return i
466 }
467 }
468 return 500
469}
470
471func (c *configImpl) SetKatiArgs(args []string) {
472 c.katiArgs = args
473}
474
475func (c *configImpl) SetNinjaArgs(args []string) {
476 c.ninjaArgs = args
477}
478
479func (c *configImpl) SetKatiSuffix(suffix string) {
480 c.katiSuffix = suffix
481}
482
Dan Willemsene0879fc2017-08-04 15:06:27 -0700483func (c *configImpl) LastKatiSuffixFile() string {
484 return filepath.Join(c.OutDir(), "last_kati_suffix")
485}
486
487func (c *configImpl) HasKatiSuffix() bool {
488 return c.katiSuffix != ""
489}
490
Dan Willemsen1e704462016-08-21 15:17:17 -0700491func (c *configImpl) KatiEnvFile() string {
492 return filepath.Join(c.OutDir(), "env"+c.KatiSuffix()+".sh")
493}
494
495func (c *configImpl) KatiNinjaFile() string {
496 return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+".ninja")
497}
498
499func (c *configImpl) SoongNinjaFile() string {
500 return filepath.Join(c.SoongOutDir(), "build.ninja")
501}
502
503func (c *configImpl) CombinedNinjaFile() string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700504 if c.katiSuffix == "" {
505 return filepath.Join(c.OutDir(), "combined.ninja")
506 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700507 return filepath.Join(c.OutDir(), "combined"+c.KatiSuffix()+".ninja")
508}
509
510func (c *configImpl) SoongAndroidMk() string {
511 return filepath.Join(c.SoongOutDir(), "Android-"+c.TargetProduct()+".mk")
512}
513
514func (c *configImpl) SoongMakeVarsMk() string {
515 return filepath.Join(c.SoongOutDir(), "make_vars-"+c.TargetProduct()+".mk")
516}
517
Dan Willemsenf052f782017-05-18 15:29:04 -0700518func (c *configImpl) ProductOut() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700519 return filepath.Join(c.OutDir(), "target", "product", c.TargetDevice())
Dan Willemsenf052f782017-05-18 15:29:04 -0700520}
521
Dan Willemsen02781d52017-05-12 19:28:13 -0700522func (c *configImpl) DevicePreviousProductConfig() string {
Dan Willemsenf052f782017-05-18 15:29:04 -0700523 return filepath.Join(c.ProductOut(), "previous_build_config.mk")
524}
525
526func (c *configImpl) hostOutRoot() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700527 return filepath.Join(c.OutDir(), "host")
Dan Willemsenf052f782017-05-18 15:29:04 -0700528}
529
530func (c *configImpl) HostOut() string {
531 return filepath.Join(c.hostOutRoot(), c.HostPrebuiltTag())
532}
533
534// This probably needs to be multi-valued, so not exporting it for now
535func (c *configImpl) hostCrossOut() string {
536 if runtime.GOOS == "linux" {
537 return filepath.Join(c.hostOutRoot(), "windows-x86")
538 } else {
539 return ""
540 }
Dan Willemsen02781d52017-05-12 19:28:13 -0700541}
542
Dan Willemsen1e704462016-08-21 15:17:17 -0700543func (c *configImpl) HostPrebuiltTag() string {
544 if runtime.GOOS == "linux" {
545 return "linux-x86"
546 } else if runtime.GOOS == "darwin" {
547 return "darwin-x86"
548 } else {
549 panic("Unsupported OS")
550 }
551}
Dan Willemsenf173d592017-04-27 14:28:00 -0700552
Dan Willemsen8122bd52017-10-12 20:20:41 -0700553func (c *configImpl) PrebuiltBuildTool(name string) string {
Dan Willemsenf173d592017-04-27 14:28:00 -0700554 if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
555 if sanitize := strings.Fields(v); inList("address", sanitize) {
Dan Willemsen8122bd52017-10-12 20:20:41 -0700556 asan := filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "asan/bin", name)
557 if _, err := os.Stat(asan); err == nil {
558 return asan
559 }
Dan Willemsenf173d592017-04-27 14:28:00 -0700560 }
561 }
562 return filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "bin", name)
563}
Dan Willemsen3d60b112018-04-04 22:25:56 -0700564
565func (c *configImpl) SetBuildBrokenDupRules(val bool) {
566 c.brokenDupRules = val
567}
568
569func (c *configImpl) BuildBrokenDupRules() bool {
570 return c.brokenDupRules
571}
Dan Willemsen6ab79db2018-05-02 00:06:28 -0700572
573func (c *configImpl) SetTargetDeviceDir(dir string) {
574 c.targetDeviceDir = dir
575}
576
577func (c *configImpl) TargetDeviceDir() string {
578 return c.targetDeviceDir
579}