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