Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 1 | // Copyright (C) 2016 The Android Open Source Project |
| 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 | |
| 15 | package art |
| 16 | |
| 17 | import ( |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 18 | "android/soong/android" |
| 19 | "android/soong/cc" |
| 20 | "fmt" |
Colin Cross | 6e95dd5 | 2016-09-12 15:37:10 -0700 | [diff] [blame] | 21 | "sync" |
Colin Cross | 84b6933 | 2017-11-01 14:23:17 -0700 | [diff] [blame] | 22 | |
| 23 | "github.com/google/blueprint/proptools" |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | var supportedArches = []string{"arm", "arm64", "mips", "mips64", "x86", "x86_64"} |
| 27 | |
| 28 | func globalFlags(ctx android.BaseContext) ([]string, []string) { |
| 29 | var cflags []string |
| 30 | var asflags []string |
| 31 | |
Colin Cross | be332ed | 2016-09-21 13:23:53 -0700 | [diff] [blame] | 32 | opt := envDefault(ctx, "ART_NDEBUG_OPT_FLAG", "-O3") |
| 33 | cflags = append(cflags, opt) |
| 34 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 35 | tlab := false |
| 36 | |
| 37 | gcType := envDefault(ctx, "ART_DEFAULT_GC_TYPE", "CMS") |
| 38 | |
| 39 | if envTrue(ctx, "ART_TEST_DEBUG_GC") { |
| 40 | gcType = "SS" |
| 41 | tlab = true |
| 42 | } |
| 43 | |
| 44 | cflags = append(cflags, "-DART_DEFAULT_GC_TYPE_IS_"+gcType) |
| 45 | if tlab { |
| 46 | cflags = append(cflags, "-DART_USE_TLAB=1") |
| 47 | } |
| 48 | |
| 49 | imtSize := envDefault(ctx, "ART_IMT_SIZE", "43") |
| 50 | cflags = append(cflags, "-DIMT_SIZE="+imtSize) |
| 51 | |
| 52 | if envTrue(ctx, "ART_HEAP_POISONING") { |
| 53 | cflags = append(cflags, "-DART_HEAP_POISONING=1") |
| 54 | asflags = append(asflags, "-DART_HEAP_POISONING=1") |
| 55 | } |
| 56 | |
Hiroshi Yamauchi | da75ad7 | 2017-01-24 11:06:47 -0800 | [diff] [blame] | 57 | if !envFalse(ctx, "ART_USE_READ_BARRIER") && ctx.AConfig().ArtUseReadBarrier() { |
Roland Levillain | b81e9e9 | 2017-04-20 17:35:32 +0100 | [diff] [blame] | 58 | // Used to change the read barrier type. Valid values are BAKER, BROOKS, |
| 59 | // TABLELOOKUP. The default is BAKER. |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 60 | barrierType := envDefault(ctx, "ART_READ_BARRIER_TYPE", "BAKER") |
| 61 | cflags = append(cflags, |
| 62 | "-DART_USE_READ_BARRIER=1", |
| 63 | "-DART_READ_BARRIER_TYPE_IS_"+barrierType+"=1") |
| 64 | asflags = append(asflags, |
| 65 | "-DART_USE_READ_BARRIER=1", |
| 66 | "-DART_READ_BARRIER_TYPE_IS_"+barrierType+"=1") |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Andreas Gampe | 655c6fd | 2017-05-24 21:42:10 -0700 | [diff] [blame] | 69 | // We need larger stack overflow guards for ASAN, as the compiled code will have |
| 70 | // larger frame sizes. For simplicity, just use global not-target-specific cflags. |
| 71 | // Note: We increase this for both debug and non-debug, as the overflow gap will |
| 72 | // be compiled into managed code. We always preopt (and build core images) with |
| 73 | // the debug version. So make the gap consistent (and adjust for the worst). |
| 74 | if len(ctx.AConfig().SanitizeDevice()) > 0 || len(ctx.AConfig().SanitizeHost()) > 0 { |
| 75 | cflags = append(cflags, |
Colin Cross | 2db58b6 | 2017-06-27 10:38:31 -0700 | [diff] [blame] | 76 | "-DART_STACK_OVERFLOW_GAP_arm=8192", |
| 77 | "-DART_STACK_OVERFLOW_GAP_arm64=8192", |
| 78 | "-DART_STACK_OVERFLOW_GAP_mips=16384", |
| 79 | "-DART_STACK_OVERFLOW_GAP_mips64=16384", |
| 80 | "-DART_STACK_OVERFLOW_GAP_x86=16384", |
| 81 | "-DART_STACK_OVERFLOW_GAP_x86_64=20480") |
Andreas Gampe | 655c6fd | 2017-05-24 21:42:10 -0700 | [diff] [blame] | 82 | } else { |
| 83 | cflags = append(cflags, |
Colin Cross | 2db58b6 | 2017-06-27 10:38:31 -0700 | [diff] [blame] | 84 | "-DART_STACK_OVERFLOW_GAP_arm=8192", |
| 85 | "-DART_STACK_OVERFLOW_GAP_arm64=8192", |
| 86 | "-DART_STACK_OVERFLOW_GAP_mips=16384", |
| 87 | "-DART_STACK_OVERFLOW_GAP_mips64=16384", |
| 88 | "-DART_STACK_OVERFLOW_GAP_x86=8192", |
| 89 | "-DART_STACK_OVERFLOW_GAP_x86_64=8192") |
Andreas Gampe | 655c6fd | 2017-05-24 21:42:10 -0700 | [diff] [blame] | 90 | } |
Andreas Gampe | bc9f10c | 2017-05-19 08:28:06 -0700 | [diff] [blame] | 91 | |
Andreas Gampe | dbf0e0f | 2017-07-11 08:34:48 -0700 | [diff] [blame] | 92 | if envTrue(ctx, "ART_ENABLE_ADDRESS_SANITIZER") { |
| 93 | // Used to enable full sanitization, i.e., user poisoning, under ASAN. |
| 94 | cflags = append(cflags, "-DART_ENABLE_ADDRESS_SANITIZER=1") |
| 95 | asflags = append(asflags, "-DART_ENABLE_ADDRESS_SANITIZER=1") |
| 96 | } |
| 97 | |
Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 98 | if envTrue(ctx, "ART_MIPS32_CHECK_ALIGNMENT") { |
| 99 | // Enable the use of MIPS32 CHECK_ALIGNMENT macro for debugging purposes |
| 100 | asflags = append(asflags, "-DART_MIPS32_CHECK_ALIGNMENT") |
| 101 | } |
| 102 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 103 | return cflags, asflags |
| 104 | } |
| 105 | |
Colin Cross | be332ed | 2016-09-21 13:23:53 -0700 | [diff] [blame] | 106 | func debugFlags(ctx android.BaseContext) []string { |
| 107 | var cflags []string |
| 108 | |
| 109 | opt := envDefault(ctx, "ART_DEBUG_OPT_FLAG", "-O2") |
| 110 | cflags = append(cflags, opt) |
| 111 | |
| 112 | return cflags |
| 113 | } |
| 114 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 115 | func deviceFlags(ctx android.BaseContext) []string { |
| 116 | var cflags []string |
| 117 | deviceFrameSizeLimit := 1736 |
| 118 | if len(ctx.AConfig().SanitizeDevice()) > 0 { |
Vishwath Mohan | 1ecc4fe | 2016-09-26 09:22:42 -0700 | [diff] [blame] | 119 | deviceFrameSizeLimit = 7400 |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 120 | } |
| 121 | cflags = append(cflags, |
| 122 | fmt.Sprintf("-Wframe-larger-than=%d", deviceFrameSizeLimit), |
| 123 | fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", deviceFrameSizeLimit), |
| 124 | ) |
| 125 | |
| 126 | cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.AConfig().LibartImgDeviceBaseAddress()) |
| 127 | if envTrue(ctx, "ART_TARGET_LINUX") { |
| 128 | cflags = append(cflags, "-DART_TARGET_LINUX") |
| 129 | } else { |
| 130 | cflags = append(cflags, "-DART_TARGET_ANDROID") |
| 131 | } |
| 132 | minDelta := envDefault(ctx, "LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA", "-0x1000000") |
| 133 | maxDelta := envDefault(ctx, "LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA", "0x1000000") |
| 134 | cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta) |
| 135 | cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta) |
| 136 | |
| 137 | return cflags |
| 138 | } |
| 139 | |
| 140 | func hostFlags(ctx android.BaseContext) []string { |
| 141 | var cflags []string |
| 142 | hostFrameSizeLimit := 1736 |
Colin Cross | 3174b68 | 2016-09-19 12:25:31 -0700 | [diff] [blame] | 143 | if len(ctx.AConfig().SanitizeHost()) > 0 { |
| 144 | // art/test/137-cfi/cfi.cc |
| 145 | // error: stack frame size of 1944 bytes in function 'Java_Main_unwindInProcess' |
| 146 | hostFrameSizeLimit = 6400 |
| 147 | } |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 148 | cflags = append(cflags, |
| 149 | fmt.Sprintf("-Wframe-larger-than=%d", hostFrameSizeLimit), |
| 150 | fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", hostFrameSizeLimit), |
| 151 | ) |
| 152 | |
| 153 | cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.AConfig().LibartImgHostBaseAddress()) |
| 154 | minDelta := envDefault(ctx, "LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA", "-0x1000000") |
| 155 | maxDelta := envDefault(ctx, "LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA", "0x1000000") |
| 156 | cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta) |
| 157 | cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta) |
| 158 | |
Andreas Gampe | fcc7d67 | 2017-07-19 10:30:22 -0700 | [diff] [blame] | 159 | if len(ctx.AConfig().SanitizeHost()) > 0 && !envFalse(ctx, "ART_ENABLE_ADDRESS_SANITIZER") { |
| 160 | // We enable full sanitization on the host by default. |
| 161 | cflags = append(cflags, "-DART_ENABLE_ADDRESS_SANITIZER=1") |
| 162 | } |
| 163 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 164 | return cflags |
| 165 | } |
| 166 | |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 167 | func globalDefaults(ctx android.LoadHookContext) { |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 168 | type props struct { |
| 169 | Target struct { |
| 170 | Android struct { |
| 171 | Cflags []string |
| 172 | } |
| 173 | Host struct { |
| 174 | Cflags []string |
| 175 | } |
| 176 | } |
Colin Cross | 2db58b6 | 2017-06-27 10:38:31 -0700 | [diff] [blame] | 177 | Cflags []string |
| 178 | Asflags []string |
Bharadwaj Kalandhabhatta | 0bb4031 | 2017-06-01 10:47:00 -0700 | [diff] [blame] | 179 | Sanitize struct { |
Colin Cross | 2db58b6 | 2017-06-27 10:38:31 -0700 | [diff] [blame] | 180 | Recover []string |
Bharadwaj Kalandhabhatta | 0bb4031 | 2017-06-01 10:47:00 -0700 | [diff] [blame] | 181 | } |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | p := &props{} |
| 185 | p.Cflags, p.Asflags = globalFlags(ctx) |
| 186 | p.Target.Android.Cflags = deviceFlags(ctx) |
| 187 | p.Target.Host.Cflags = hostFlags(ctx) |
Bharadwaj Kalandhabhatta | 0bb4031 | 2017-06-01 10:47:00 -0700 | [diff] [blame] | 188 | |
| 189 | if envTrue(ctx, "ART_DEX_FILE_ACCESS_TRACKING") { |
| 190 | p.Cflags = append(p.Cflags, "-DART_DEX_FILE_ACCESS_TRACKING") |
Colin Cross | 2db58b6 | 2017-06-27 10:38:31 -0700 | [diff] [blame] | 191 | p.Sanitize.Recover = []string{ |
Bharadwaj Kalandhabhatta | 0bb4031 | 2017-06-01 10:47:00 -0700 | [diff] [blame] | 192 | "address", |
| 193 | } |
| 194 | } |
| 195 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 196 | ctx.AppendProperties(p) |
Colin Cross | fe6064a | 2016-08-30 13:49:26 -0700 | [diff] [blame] | 197 | } |
Colin Cross | 6326d1b | 2016-09-06 10:24:28 -0700 | [diff] [blame] | 198 | |
Colin Cross | be332ed | 2016-09-21 13:23:53 -0700 | [diff] [blame] | 199 | func debugDefaults(ctx android.LoadHookContext) { |
| 200 | type props struct { |
| 201 | Cflags []string |
| 202 | } |
| 203 | |
| 204 | p := &props{} |
| 205 | p.Cflags = debugFlags(ctx) |
| 206 | ctx.AppendProperties(p) |
| 207 | } |
| 208 | |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 209 | func customLinker(ctx android.LoadHookContext) { |
Colin Cross | fe6064a | 2016-08-30 13:49:26 -0700 | [diff] [blame] | 210 | linker := envDefault(ctx, "CUSTOM_TARGET_LINKER", "") |
Colin Cross | 84b6933 | 2017-11-01 14:23:17 -0700 | [diff] [blame] | 211 | type props struct { |
| 212 | DynamicLinker string |
Colin Cross | fe6064a | 2016-08-30 13:49:26 -0700 | [diff] [blame] | 213 | } |
Colin Cross | 84b6933 | 2017-11-01 14:23:17 -0700 | [diff] [blame] | 214 | |
| 215 | p := &props{} |
| 216 | if linker != "" { |
| 217 | p.DynamicLinker = linker |
| 218 | } |
| 219 | |
| 220 | ctx.AppendProperties(p) |
Colin Cross | fe6064a | 2016-08-30 13:49:26 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 223 | func prefer32Bit(ctx android.LoadHookContext) { |
Colin Cross | 84b6933 | 2017-11-01 14:23:17 -0700 | [diff] [blame] | 224 | type props struct { |
| 225 | Target struct { |
| 226 | Host struct { |
| 227 | Compile_multilib *string |
Colin Cross | 6326d1b | 2016-09-06 10:24:28 -0700 | [diff] [blame] | 228 | } |
| 229 | } |
Colin Cross | 6326d1b | 2016-09-06 10:24:28 -0700 | [diff] [blame] | 230 | } |
Colin Cross | 84b6933 | 2017-11-01 14:23:17 -0700 | [diff] [blame] | 231 | |
| 232 | p := &props{} |
| 233 | if envTrue(ctx, "HOST_PREFER_32_BIT") { |
| 234 | p.Target.Host.Compile_multilib = proptools.StringPtr("prefer32") |
| 235 | } |
| 236 | |
| 237 | ctx.AppendProperties(p) |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Colin Cross | 6e95dd5 | 2016-09-12 15:37:10 -0700 | [diff] [blame] | 240 | func testMap(config android.Config) map[string][]string { |
| 241 | return config.Once("artTests", func() interface{} { |
| 242 | return make(map[string][]string) |
| 243 | }).(map[string][]string) |
| 244 | } |
| 245 | |
| 246 | func testInstall(ctx android.InstallHookContext) { |
| 247 | testMap := testMap(ctx.AConfig()) |
| 248 | |
| 249 | var name string |
| 250 | if ctx.Host() { |
| 251 | name = "host_" |
| 252 | } else { |
| 253 | name = "device_" |
| 254 | } |
| 255 | name += ctx.Arch().ArchType.String() + "_" + ctx.ModuleName() |
| 256 | |
| 257 | artTestMutex.Lock() |
| 258 | defer artTestMutex.Unlock() |
| 259 | |
| 260 | tests := testMap[name] |
| 261 | tests = append(tests, ctx.Path().RelPathString()) |
| 262 | testMap[name] = tests |
| 263 | } |
| 264 | |
| 265 | var artTestMutex sync.Mutex |
| 266 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 267 | func init() { |
Colin Cross | 96548c9 | 2016-10-12 14:26:55 -0700 | [diff] [blame] | 268 | android.RegisterModuleType("art_cc_library", artLibrary) |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 269 | android.RegisterModuleType("art_cc_static_library", artStaticLibrary) |
Colin Cross | 96548c9 | 2016-10-12 14:26:55 -0700 | [diff] [blame] | 270 | android.RegisterModuleType("art_cc_binary", artBinary) |
| 271 | android.RegisterModuleType("art_cc_test", artTest) |
| 272 | android.RegisterModuleType("art_cc_test_library", artTestLibrary) |
| 273 | android.RegisterModuleType("art_cc_defaults", artDefaultsFactory) |
| 274 | android.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory) |
| 275 | android.RegisterModuleType("art_debug_defaults", artDebugDefaultsFactory) |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 278 | func artGlobalDefaultsFactory() android.Module { |
| 279 | module := artDefaultsFactory() |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 280 | android.AddLoadHook(module, globalDefaults) |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 281 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 282 | return module |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 285 | func artDebugDefaultsFactory() android.Module { |
| 286 | module := artDefaultsFactory() |
Colin Cross | be332ed | 2016-09-21 13:23:53 -0700 | [diff] [blame] | 287 | android.AddLoadHook(module, debugDefaults) |
| 288 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 289 | return module |
Colin Cross | be332ed | 2016-09-21 13:23:53 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 292 | func artDefaultsFactory() android.Module { |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 293 | c := &codegenProperties{} |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 294 | module := cc.DefaultsFactory(c) |
Colin Cross | 6e95dd5 | 2016-09-12 15:37:10 -0700 | [diff] [blame] | 295 | android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, true) }) |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 296 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 297 | return module |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 300 | func artLibrary() android.Module { |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 301 | m, _ := cc.NewLibrary(android.HostAndDeviceSupported) |
| 302 | module := m.Init() |
| 303 | |
| 304 | installCodegenCustomizer(module, true) |
| 305 | |
| 306 | return module |
| 307 | } |
| 308 | |
| 309 | func artStaticLibrary() android.Module { |
| 310 | m, library := cc.NewLibrary(android.HostAndDeviceSupported) |
| 311 | library.BuildOnlyStatic() |
| 312 | module := m.Init() |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 313 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 314 | installCodegenCustomizer(module, true) |
Colin Cross | fe6064a | 2016-08-30 13:49:26 -0700 | [diff] [blame] | 315 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 316 | return module |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 319 | func artBinary() android.Module { |
Colin Cross | 123989f | 2016-09-07 14:12:50 -0700 | [diff] [blame] | 320 | binary, _ := cc.NewBinary(android.HostAndDeviceSupported) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 321 | module := binary.Init() |
Colin Cross | 123989f | 2016-09-07 14:12:50 -0700 | [diff] [blame] | 322 | |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 323 | android.AddLoadHook(module, customLinker) |
| 324 | android.AddLoadHook(module, prefer32Bit) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 325 | return module |
Colin Cross | 123989f | 2016-09-07 14:12:50 -0700 | [diff] [blame] | 326 | } |
| 327 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 328 | func artTest() android.Module { |
Colin Cross | c7376e0 | 2016-09-08 12:52:18 -0700 | [diff] [blame] | 329 | test := cc.NewTest(android.HostAndDeviceSupported) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 330 | module := test.Init() |
Colin Cross | c7376e0 | 2016-09-08 12:52:18 -0700 | [diff] [blame] | 331 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 332 | installCodegenCustomizer(module, false) |
Colin Cross | 6e95dd5 | 2016-09-12 15:37:10 -0700 | [diff] [blame] | 333 | |
Colin Cross | 6e51178 | 2016-09-13 13:41:03 -0700 | [diff] [blame] | 334 | android.AddLoadHook(module, customLinker) |
| 335 | android.AddLoadHook(module, prefer32Bit) |
Colin Cross | 6e95dd5 | 2016-09-12 15:37:10 -0700 | [diff] [blame] | 336 | android.AddInstallHook(module, testInstall) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 337 | return module |
Colin Cross | c7376e0 | 2016-09-08 12:52:18 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 340 | func artTestLibrary() android.Module { |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 341 | test := cc.NewTestLibrary(android.HostAndDeviceSupported) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 342 | module := test.Init() |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 343 | |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 344 | installCodegenCustomizer(module, false) |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 345 | |
| 346 | android.AddLoadHook(module, prefer32Bit) |
| 347 | android.AddInstallHook(module, testInstall) |
Colin Cross | ca06ea3 | 2017-06-27 10:38:55 -0700 | [diff] [blame] | 348 | return module |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Colin Cross | 1f7f3bd | 2016-07-27 10:12:38 -0700 | [diff] [blame] | 351 | func envDefault(ctx android.BaseContext, key string, defaultValue string) string { |
| 352 | ret := ctx.AConfig().Getenv(key) |
| 353 | if ret == "" { |
| 354 | return defaultValue |
| 355 | } |
| 356 | return ret |
| 357 | } |
| 358 | |
| 359 | func envTrue(ctx android.BaseContext, key string) bool { |
| 360 | return ctx.AConfig().Getenv(key) == "true" |
| 361 | } |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 362 | |
| 363 | func envFalse(ctx android.BaseContext, key string) bool { |
| 364 | return ctx.AConfig().Getenv(key) == "false" |
| 365 | } |