blob: d0378ec0b097a332b60f46b5732fba31ac112e1e [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
Dan Willemsenfa42f3c2018-06-15 21:54:47 -070053 pdkBuild bool
Dan Willemsen3d60b112018-04-04 22:25:56 -070054 brokenDupRules bool
Dan Willemsen18490112018-05-25 16:30:04 -070055
56 pathReplaced bool
Dan Willemsen1e704462016-08-21 15:17:17 -070057}
58
Dan Willemsenc2af0be2017-01-20 14:10:01 -080059const srcDirFileCheck = "build/soong/root.bp"
60
Dan Willemsen1e704462016-08-21 15:17:17 -070061func NewConfig(ctx Context, args ...string) Config {
62 ret := &configImpl{
63 environ: OsEnvironment(),
64 }
65
Dan Willemsen9b587492017-07-10 22:13:00 -070066 // Sane default matching ninja
67 ret.parallel = runtime.NumCPU() + 2
68 ret.keepGoing = 1
69
70 ret.parseArgs(ctx, args)
71
Dan Willemsen0c3919e2017-03-02 15:49:10 -080072 // Make sure OUT_DIR is set appropriately
Dan Willemsen02f3add2017-05-12 13:50:19 -070073 if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
74 ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
75 } else {
Dan Willemsen0c3919e2017-03-02 15:49:10 -080076 outDir := "out"
77 if baseDir, ok := ret.environ.Get("OUT_DIR_COMMON_BASE"); ok {
78 if wd, err := os.Getwd(); err != nil {
79 ctx.Fatalln("Failed to get working directory:", err)
80 } else {
81 outDir = filepath.Join(baseDir, filepath.Base(wd))
82 }
83 }
84 ret.environ.Set("OUT_DIR", outDir)
85 }
86
Dan Willemsen1e704462016-08-21 15:17:17 -070087 ret.environ.Unset(
88 // We're already using it
89 "USE_SOONG_UI",
90
91 // We should never use GOROOT/GOPATH from the shell environment
92 "GOROOT",
93 "GOPATH",
94
95 // These should only come from Soong, not the environment.
96 "CLANG",
97 "CLANG_CXX",
98 "CCC_CC",
99 "CCC_CXX",
100
101 // Used by the goma compiler wrapper, but should only be set by
102 // gomacc
103 "GOMACC_PATH",
Dan Willemsen0c3919e2017-03-02 15:49:10 -0800104
105 // We handle this above
106 "OUT_DIR_COMMON_BASE",
Dan Willemsen68a09852017-04-18 13:56:57 -0700107
108 // Variables that have caused problems in the past
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700109 "CDPATH",
Dan Willemsen68a09852017-04-18 13:56:57 -0700110 "DISPLAY",
111 "GREP_OPTIONS",
Dan Willemsenebfe33a2018-05-01 10:07:50 -0700112 "NDK_ROOT",
Dan Willemsenc40e10b2017-07-11 14:30:00 -0700113
114 // Drop make flags
115 "MAKEFLAGS",
116 "MAKELEVEL",
117 "MFLAGS",
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700118
119 // Set in envsetup.sh, reset in makefiles
120 "ANDROID_JAVA_TOOLCHAIN",
Dan Willemsen1e704462016-08-21 15:17:17 -0700121 )
122
123 // Tell python not to spam the source tree with .pyc files.
124 ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
125
Dan Willemsen32a669b2018-03-08 19:42:00 -0800126 ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
127
Dan Willemsenc2af0be2017-01-20 14:10:01 -0800128 // Precondition: the current directory is the top of the source tree
129 if _, err := os.Stat(srcDirFileCheck); err != nil {
130 if os.IsNotExist(err) {
131 log.Fatalf("Current working directory must be the source tree. %q not found", srcDirFileCheck)
132 }
133 log.Fatalln("Error verifying tree state:", err)
134 }
135
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700136 if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
137 log.Println("You are building in a directory whose absolute path contains a space character:")
138 log.Println()
139 log.Printf("%q\n", srcDir)
140 log.Println()
141 log.Fatalln("Directory names containing spaces are not supported")
Dan Willemsendb8457c2017-05-12 16:38:17 -0700142 }
143
144 if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
145 log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
146 log.Println()
147 log.Printf("%q\n", outDir)
148 log.Println()
149 log.Fatalln("Directory names containing spaces are not supported")
150 }
151
152 if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
153 log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
154 log.Println()
155 log.Printf("%q\n", distDir)
156 log.Println()
157 log.Fatalln("Directory names containing spaces are not supported")
158 }
159
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700160 // Configure Java-related variables, including adding it to $PATH
Tobias Thierere59aeff2017-12-20 22:40:39 +0000161 java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
162 java9Home := filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700163 javaHome := func() string {
164 if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
165 return override
166 }
Colin Cross997262f2018-06-19 22:49:39 -0700167 return java9Home
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700168 }()
169 absJavaHome := absPath(ctx, javaHome)
170
Dan Willemsened869522018-01-08 14:58:46 -0800171 ret.configureLocale(ctx)
172
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700173 newPath := []string{filepath.Join(absJavaHome, "bin")}
174 if path, ok := ret.environ.Get("PATH"); ok && path != "" {
175 newPath = append(newPath, path)
176 }
177 ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
178 ret.environ.Set("JAVA_HOME", absJavaHome)
179 ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
Tobias Thierere59aeff2017-12-20 22:40:39 +0000180 ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
181 ret.environ.Set("ANDROID_JAVA9_HOME", java9Home)
Dan Willemsend9e8f0a2017-10-30 13:42:06 -0700182 ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
183
Nan Zhang2e6a4ff2018-02-14 13:27:26 -0800184 outDir := ret.OutDir()
185 buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
186 var content string
187 if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
188 content = buildDateTime
189 } else {
190 content = strconv.FormatInt(time.Now().Unix(), 10)
191 }
192 err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
193 if err != nil {
194 ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
195 }
196 ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
197
Dan Willemsen9b587492017-07-10 22:13:00 -0700198 return Config{ret}
199}
200
201func (c *configImpl) parseArgs(ctx Context, args []string) {
202 for i := 0; i < len(args); i++ {
203 arg := strings.TrimSpace(args[i])
Dan Willemsen1e704462016-08-21 15:17:17 -0700204 if arg == "--make-mode" {
Dan Willemsen1e704462016-08-21 15:17:17 -0700205 } else if arg == "showcommands" {
Dan Willemsen9b587492017-07-10 22:13:00 -0700206 c.verbose = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700207 } else if arg == "--skip-make" {
208 c.skipMake = true
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700209 } else if len(arg) > 0 && arg[0] == '-' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700210 parseArgNum := func(def int) int {
211 if len(arg) > 2 {
212 p, err := strconv.ParseUint(arg[2:], 10, 31)
213 if err != nil {
214 ctx.Fatalf("Failed to parse %q: %v", arg, err)
215 }
216 return int(p)
217 } else if i+1 < len(args) {
218 p, err := strconv.ParseUint(args[i+1], 10, 31)
219 if err == nil {
220 i++
221 return int(p)
222 }
223 }
224 return def
225 }
226
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700227 if len(arg) > 1 && arg[1] == 'j' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700228 c.parallel = parseArgNum(c.parallel)
Dan Willemsen6ac63ef2017-10-17 20:35:34 -0700229 } else if len(arg) > 1 && arg[1] == 'k' {
Dan Willemsen9b587492017-07-10 22:13:00 -0700230 c.keepGoing = parseArgNum(0)
Dan Willemsen1e704462016-08-21 15:17:17 -0700231 } else {
232 ctx.Fatalln("Unknown option:", arg)
233 }
Dan Willemsen091525e2017-07-11 14:17:50 -0700234 } else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
235 c.environ.Set(k, v)
Dan Willemsen1e704462016-08-21 15:17:17 -0700236 } else {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700237 if arg == "dist" {
238 c.dist = true
Colin Cross37193492017-11-16 17:55:00 -0800239 } else if arg == "checkbuild" {
240 c.checkbuild = true
Dan Willemsene0879fc2017-08-04 15:06:27 -0700241 }
Dan Willemsen9b587492017-07-10 22:13:00 -0700242 c.arguments = append(c.arguments, arg)
Dan Willemsen1e704462016-08-21 15:17:17 -0700243 }
244 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700245}
246
Dan Willemsened869522018-01-08 14:58:46 -0800247func (c *configImpl) configureLocale(ctx Context) {
248 cmd := Command(ctx, Config{c}, "locale", "locale", "-a")
249 output, err := cmd.Output()
250
251 var locales []string
252 if err == nil {
253 locales = strings.Split(string(output), "\n")
254 } else {
255 // If we're unable to list the locales, let's assume en_US.UTF-8
256 locales = []string{"en_US.UTF-8"}
257 ctx.Verbosef("Failed to list locales (%q), falling back to %q", err, locales)
258 }
259
260 // gettext uses LANGUAGE, which is passed directly through
261
262 // For LANG and LC_*, only preserve the evaluated version of
263 // LC_MESSAGES
264 user_lang := ""
265 if lc_all, ok := c.environ.Get("LC_ALL"); ok {
266 user_lang = lc_all
267 } else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
268 user_lang = lc_messages
269 } else if lang, ok := c.environ.Get("LANG"); ok {
270 user_lang = lang
271 }
272
273 c.environ.UnsetWithPrefix("LC_")
274
275 if user_lang != "" {
276 c.environ.Set("LC_MESSAGES", user_lang)
277 }
278
279 // The for LANG, use C.UTF-8 if it exists (Debian currently, proposed
280 // for others)
281 if inList("C.UTF-8", locales) {
282 c.environ.Set("LANG", "C.UTF-8")
283 } else if inList("en_US.UTF-8", locales) {
284 c.environ.Set("LANG", "en_US.UTF-8")
285 } else if inList("en_US.utf8", locales) {
286 // These normalize to the same thing
287 c.environ.Set("LANG", "en_US.UTF-8")
288 } else {
289 ctx.Fatalln("System doesn't support either C.UTF-8 or en_US.UTF-8")
290 }
291}
292
Dan Willemsen1e704462016-08-21 15:17:17 -0700293// Lunch configures the environment for a specific product similarly to the
294// `lunch` bash function.
295func (c *configImpl) Lunch(ctx Context, product, variant string) {
296 if variant != "eng" && variant != "userdebug" && variant != "user" {
297 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
298 }
299
300 c.environ.Set("TARGET_PRODUCT", product)
301 c.environ.Set("TARGET_BUILD_VARIANT", variant)
302 c.environ.Set("TARGET_BUILD_TYPE", "release")
303 c.environ.Unset("TARGET_BUILD_APPS")
304}
305
306// Tapas configures the environment to build one or more unbundled apps,
307// similarly to the `tapas` bash function.
308func (c *configImpl) Tapas(ctx Context, apps []string, arch, variant string) {
309 if len(apps) == 0 {
310 apps = []string{"all"}
311 }
312 if variant == "" {
313 variant = "eng"
314 }
315
316 if variant != "eng" && variant != "userdebug" && variant != "user" {
317 ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
318 }
319
320 var product string
321 switch arch {
Dan Willemsen1e704462016-08-21 15:17:17 -0700322 case "arm", "":
323 product = "aosp_arm"
324 case "arm64":
325 product = "aosm_arm64"
326 case "mips":
327 product = "aosp_mips"
328 case "mips64":
329 product = "aosp_mips64"
330 case "x86":
331 product = "aosp_x86"
332 case "x86_64":
333 product = "aosp_x86_64"
334 default:
335 ctx.Fatalf("Invalid architecture: %q", arch)
336 }
337
338 c.environ.Set("TARGET_PRODUCT", product)
339 c.environ.Set("TARGET_BUILD_VARIANT", variant)
340 c.environ.Set("TARGET_BUILD_TYPE", "release")
341 c.environ.Set("TARGET_BUILD_APPS", strings.Join(apps, " "))
342}
343
344func (c *configImpl) Environment() *Environment {
345 return c.environ
346}
347
348func (c *configImpl) Arguments() []string {
349 return c.arguments
350}
351
352func (c *configImpl) OutDir() string {
353 if outDir, ok := c.environ.Get("OUT_DIR"); ok {
354 return outDir
355 }
356 return "out"
357}
358
Dan Willemsen8a073a82017-02-04 17:30:44 -0800359func (c *configImpl) DistDir() string {
360 if distDir, ok := c.environ.Get("DIST_DIR"); ok {
361 return distDir
362 }
363 return filepath.Join(c.OutDir(), "dist")
364}
365
Dan Willemsen1e704462016-08-21 15:17:17 -0700366func (c *configImpl) NinjaArgs() []string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700367 if c.skipMake {
368 return c.arguments
369 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700370 return c.ninjaArgs
371}
372
373func (c *configImpl) SoongOutDir() string {
374 return filepath.Join(c.OutDir(), "soong")
375}
376
Jeff Gastonefc1b412017-03-29 17:29:06 -0700377func (c *configImpl) TempDir() string {
378 return shared.TempDirForOutDir(c.SoongOutDir())
379}
380
Jeff Gastonb64fc1c2017-08-04 12:30:12 -0700381func (c *configImpl) FileListDir() string {
382 return filepath.Join(c.OutDir(), ".module_paths")
383}
384
Dan Willemsen1e704462016-08-21 15:17:17 -0700385func (c *configImpl) KatiSuffix() string {
386 if c.katiSuffix != "" {
387 return c.katiSuffix
388 }
389 panic("SetKatiSuffix has not been called")
390}
391
Colin Cross37193492017-11-16 17:55:00 -0800392// Checkbuild returns true if "checkbuild" was one of the build goals, which means that the
393// user is interested in additional checks at the expense of build time.
394func (c *configImpl) Checkbuild() bool {
395 return c.checkbuild
396}
397
Dan Willemsen8a073a82017-02-04 17:30:44 -0800398func (c *configImpl) Dist() bool {
399 return c.dist
400}
401
Dan Willemsen1e704462016-08-21 15:17:17 -0700402func (c *configImpl) IsVerbose() bool {
403 return c.verbose
404}
405
Dan Willemsene0879fc2017-08-04 15:06:27 -0700406func (c *configImpl) SkipMake() bool {
407 return c.skipMake
408}
409
Dan Willemsen1e704462016-08-21 15:17:17 -0700410func (c *configImpl) TargetProduct() string {
411 if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
412 return v
413 }
414 panic("TARGET_PRODUCT is not defined")
415}
416
Dan Willemsen02781d52017-05-12 19:28:13 -0700417func (c *configImpl) TargetDevice() string {
418 return c.targetDevice
419}
420
421func (c *configImpl) SetTargetDevice(device string) {
422 c.targetDevice = device
423}
424
425func (c *configImpl) TargetBuildVariant() string {
426 if v, ok := c.environ.Get("TARGET_BUILD_VARIANT"); ok {
427 return v
428 }
429 panic("TARGET_BUILD_VARIANT is not defined")
430}
431
Dan Willemsen1e704462016-08-21 15:17:17 -0700432func (c *configImpl) KatiArgs() []string {
433 return c.katiArgs
434}
435
436func (c *configImpl) Parallel() int {
437 return c.parallel
438}
439
440func (c *configImpl) UseGoma() bool {
441 if v, ok := c.environ.Get("USE_GOMA"); ok {
442 v = strings.TrimSpace(v)
443 if v != "" && v != "false" {
444 return true
445 }
446 }
447 return false
448}
449
450// RemoteParallel controls how many remote jobs (i.e., commands which contain
Jeff Gastonefc1b412017-03-29 17:29:06 -0700451// gomacc) are run in parallel. Note the parallelism of all other jobs is
Dan Willemsen1e704462016-08-21 15:17:17 -0700452// still limited by Parallel()
453func (c *configImpl) RemoteParallel() int {
454 if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok {
455 if i, err := strconv.Atoi(v); err == nil {
456 return i
457 }
458 }
459 return 500
460}
461
462func (c *configImpl) SetKatiArgs(args []string) {
463 c.katiArgs = args
464}
465
466func (c *configImpl) SetNinjaArgs(args []string) {
467 c.ninjaArgs = args
468}
469
470func (c *configImpl) SetKatiSuffix(suffix string) {
471 c.katiSuffix = suffix
472}
473
Dan Willemsene0879fc2017-08-04 15:06:27 -0700474func (c *configImpl) LastKatiSuffixFile() string {
475 return filepath.Join(c.OutDir(), "last_kati_suffix")
476}
477
478func (c *configImpl) HasKatiSuffix() bool {
479 return c.katiSuffix != ""
480}
481
Dan Willemsen1e704462016-08-21 15:17:17 -0700482func (c *configImpl) KatiEnvFile() string {
483 return filepath.Join(c.OutDir(), "env"+c.KatiSuffix()+".sh")
484}
485
486func (c *configImpl) KatiNinjaFile() string {
487 return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+".ninja")
488}
489
490func (c *configImpl) SoongNinjaFile() string {
491 return filepath.Join(c.SoongOutDir(), "build.ninja")
492}
493
494func (c *configImpl) CombinedNinjaFile() string {
Dan Willemsene0879fc2017-08-04 15:06:27 -0700495 if c.katiSuffix == "" {
496 return filepath.Join(c.OutDir(), "combined.ninja")
497 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700498 return filepath.Join(c.OutDir(), "combined"+c.KatiSuffix()+".ninja")
499}
500
501func (c *configImpl) SoongAndroidMk() string {
502 return filepath.Join(c.SoongOutDir(), "Android-"+c.TargetProduct()+".mk")
503}
504
505func (c *configImpl) SoongMakeVarsMk() string {
506 return filepath.Join(c.SoongOutDir(), "make_vars-"+c.TargetProduct()+".mk")
507}
508
Dan Willemsenf052f782017-05-18 15:29:04 -0700509func (c *configImpl) ProductOut() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700510 return filepath.Join(c.OutDir(), "target", "product", c.TargetDevice())
Dan Willemsenf052f782017-05-18 15:29:04 -0700511}
512
Dan Willemsen02781d52017-05-12 19:28:13 -0700513func (c *configImpl) DevicePreviousProductConfig() string {
Dan Willemsenf052f782017-05-18 15:29:04 -0700514 return filepath.Join(c.ProductOut(), "previous_build_config.mk")
515}
516
517func (c *configImpl) hostOutRoot() string {
Dan Willemsen4dc4e142017-09-08 14:35:43 -0700518 return filepath.Join(c.OutDir(), "host")
Dan Willemsenf052f782017-05-18 15:29:04 -0700519}
520
521func (c *configImpl) HostOut() string {
522 return filepath.Join(c.hostOutRoot(), c.HostPrebuiltTag())
523}
524
525// This probably needs to be multi-valued, so not exporting it for now
526func (c *configImpl) hostCrossOut() string {
527 if runtime.GOOS == "linux" {
528 return filepath.Join(c.hostOutRoot(), "windows-x86")
529 } else {
530 return ""
531 }
Dan Willemsen02781d52017-05-12 19:28:13 -0700532}
533
Dan Willemsen1e704462016-08-21 15:17:17 -0700534func (c *configImpl) HostPrebuiltTag() string {
535 if runtime.GOOS == "linux" {
536 return "linux-x86"
537 } else if runtime.GOOS == "darwin" {
538 return "darwin-x86"
539 } else {
540 panic("Unsupported OS")
541 }
542}
Dan Willemsenf173d592017-04-27 14:28:00 -0700543
Dan Willemsen8122bd52017-10-12 20:20:41 -0700544func (c *configImpl) PrebuiltBuildTool(name string) string {
Dan Willemsenf173d592017-04-27 14:28:00 -0700545 if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
546 if sanitize := strings.Fields(v); inList("address", sanitize) {
Dan Willemsen8122bd52017-10-12 20:20:41 -0700547 asan := filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "asan/bin", name)
548 if _, err := os.Stat(asan); err == nil {
549 return asan
550 }
Dan Willemsenf173d592017-04-27 14:28:00 -0700551 }
552 }
553 return filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "bin", name)
554}
Dan Willemsen3d60b112018-04-04 22:25:56 -0700555
556func (c *configImpl) SetBuildBrokenDupRules(val bool) {
557 c.brokenDupRules = val
558}
559
560func (c *configImpl) BuildBrokenDupRules() bool {
561 return c.brokenDupRules
562}
Dan Willemsen6ab79db2018-05-02 00:06:28 -0700563
564func (c *configImpl) SetTargetDeviceDir(dir string) {
565 c.targetDeviceDir = dir
566}
567
568func (c *configImpl) TargetDeviceDir() string {
569 return c.targetDeviceDir
570}
Dan Willemsenfa42f3c2018-06-15 21:54:47 -0700571
572func (c *configImpl) SetPdkBuild(pdk bool) {
573 c.pdkBuild = pdk
574}
575
576func (c *configImpl) IsPdkBuild() bool {
577 return c.pdkBuild
578}