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