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