blob: af2a5deb545d2b64b8a1859b209c9233f72d440d [file] [log] [blame]
Colin Cross1f7f3bd2016-07-27 10:12:38 -07001// 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
15package art
16
17import (
Colin Cross1f7f3bd2016-07-27 10:12:38 -070018 "fmt"
Alex Lightda948ce2018-12-06 17:05:41 +000019 "log"
David Srbecky1cf46a32020-06-22 15:39:00 +010020 "strings"
Colin Cross6e95dd52016-09-12 15:37:10 -070021 "sync"
Colin Cross84b69332017-11-01 14:23:17 -070022
23 "github.com/google/blueprint/proptools"
Colin Crossdd3b7aa2019-07-31 13:47:39 -070024
25 "android/soong/android"
26 "android/soong/apex"
27 "android/soong/cc"
Colin Cross1f7f3bd2016-07-27 10:12:38 -070028)
29
Vladimir Markobe0d3cf2020-02-12 10:52:22 +000030var supportedArches = []string{"arm", "arm64", "x86", "x86_64"}
Colin Cross1f7f3bd2016-07-27 10:12:38 -070031
Colin Crossdd3b7aa2019-07-31 13:47:39 -070032func globalFlags(ctx android.LoadHookContext) ([]string, []string) {
Colin Cross1f7f3bd2016-07-27 10:12:38 -070033 var cflags []string
34 var asflags []string
35
Colin Crossdd3b7aa2019-07-31 13:47:39 -070036 opt := ctx.Config().GetenvWithDefault("ART_NDEBUG_OPT_FLAG", "-O3")
Colin Crossbe332ed2016-09-21 13:23:53 -070037 cflags = append(cflags, opt)
38
Colin Cross1f7f3bd2016-07-27 10:12:38 -070039 tlab := false
40
Colin Crossdd3b7aa2019-07-31 13:47:39 -070041 gcType := ctx.Config().GetenvWithDefault("ART_DEFAULT_GC_TYPE", "CMS")
Colin Cross1f7f3bd2016-07-27 10:12:38 -070042
Colin Crossdd3b7aa2019-07-31 13:47:39 -070043 if ctx.Config().IsEnvTrue("ART_TEST_DEBUG_GC") {
Colin Cross1f7f3bd2016-07-27 10:12:38 -070044 gcType = "SS"
45 tlab = true
46 }
47
48 cflags = append(cflags, "-DART_DEFAULT_GC_TYPE_IS_"+gcType)
49 if tlab {
50 cflags = append(cflags, "-DART_USE_TLAB=1")
51 }
52
Colin Crossdd3b7aa2019-07-31 13:47:39 -070053 if ctx.Config().IsEnvTrue("ART_HEAP_POISONING") {
Colin Cross1f7f3bd2016-07-27 10:12:38 -070054 cflags = append(cflags, "-DART_HEAP_POISONING=1")
55 asflags = append(asflags, "-DART_HEAP_POISONING=1")
56 }
Colin Crossdd3b7aa2019-07-31 13:47:39 -070057 if ctx.Config().IsEnvTrue("ART_USE_CXX_INTERPRETER") {
David Srbecky8ed45c82018-11-08 15:08:57 +000058 cflags = append(cflags, "-DART_USE_CXX_INTERPRETER=1")
59 }
Colin Cross1f7f3bd2016-07-27 10:12:38 -070060
Colin Crossdd3b7aa2019-07-31 13:47:39 -070061 if !ctx.Config().IsEnvFalse("ART_USE_READ_BARRIER") && ctx.Config().ArtUseReadBarrier() {
Roland Levillainb81e9e92017-04-20 17:35:32 +010062 // Used to change the read barrier type. Valid values are BAKER, BROOKS,
63 // TABLELOOKUP. The default is BAKER.
Colin Crossdd3b7aa2019-07-31 13:47:39 -070064 barrierType := ctx.Config().GetenvWithDefault("ART_READ_BARRIER_TYPE", "BAKER")
Colin Cross1f7f3bd2016-07-27 10:12:38 -070065 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 Cross1f7f3bd2016-07-27 10:12:38 -070071 }
72
Colin Crossdd3b7aa2019-07-31 13:47:39 -070073 if !ctx.Config().IsEnvFalse("ART_USE_GENERATIONAL_CC") {
Mathieu Chartier8d1a9962016-08-17 16:39:45 -070074 cflags = append(cflags, "-DART_USE_GENERATIONAL_CC=1")
75 }
76
Colin Crossdd3b7aa2019-07-31 13:47:39 -070077 cdexLevel := ctx.Config().GetenvWithDefault("ART_DEFAULT_COMPACT_DEX_LEVEL", "fast")
Mathieu Chartier8d1a9962016-08-17 16:39:45 -070078 cflags = append(cflags, "-DART_DEFAULT_COMPACT_DEX_LEVEL="+cdexLevel)
Mathieu Chartiera7f6b812017-12-11 13:34:29 -080079
Andreas Gampe655c6fd2017-05-24 21:42:10 -070080 // We need larger stack overflow guards for ASAN, as the compiled code will have
81 // larger frame sizes. For simplicity, just use global not-target-specific cflags.
82 // Note: We increase this for both debug and non-debug, as the overflow gap will
83 // be compiled into managed code. We always preopt (and build core images) with
84 // the debug version. So make the gap consistent (and adjust for the worst).
Colin Crossdd3b7aa2019-07-31 13:47:39 -070085 if len(ctx.Config().SanitizeDevice()) > 0 || len(ctx.Config().SanitizeHost()) > 0 {
Andreas Gampe655c6fd2017-05-24 21:42:10 -070086 cflags = append(cflags,
Colin Cross2db58b62017-06-27 10:38:31 -070087 "-DART_STACK_OVERFLOW_GAP_arm=8192",
Evgenii Stepanov9e3954d2019-09-12 15:58:52 -070088 "-DART_STACK_OVERFLOW_GAP_arm64=16384",
Colin Cross2db58b62017-06-27 10:38:31 -070089 "-DART_STACK_OVERFLOW_GAP_x86=16384",
90 "-DART_STACK_OVERFLOW_GAP_x86_64=20480")
Andreas Gampe655c6fd2017-05-24 21:42:10 -070091 } else {
92 cflags = append(cflags,
Colin Cross2db58b62017-06-27 10:38:31 -070093 "-DART_STACK_OVERFLOW_GAP_arm=8192",
94 "-DART_STACK_OVERFLOW_GAP_arm64=8192",
Colin Cross2db58b62017-06-27 10:38:31 -070095 "-DART_STACK_OVERFLOW_GAP_x86=8192",
96 "-DART_STACK_OVERFLOW_GAP_x86_64=8192")
Andreas Gampe655c6fd2017-05-24 21:42:10 -070097 }
Andreas Gampebc9f10c2017-05-19 08:28:06 -070098
Colin Crossdd3b7aa2019-07-31 13:47:39 -070099 if ctx.Config().IsEnvTrue("ART_ENABLE_ADDRESS_SANITIZER") {
Andreas Gampedbf0e0f2017-07-11 08:34:48 -0700100 // Used to enable full sanitization, i.e., user poisoning, under ASAN.
101 cflags = append(cflags, "-DART_ENABLE_ADDRESS_SANITIZER=1")
102 asflags = append(asflags, "-DART_ENABLE_ADDRESS_SANITIZER=1")
103 }
104
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700105 if !ctx.Config().IsEnvFalse("USE_D8_DESUGAR") {
Alan Leung8f514ee2017-12-08 14:08:25 -0800106 cflags = append(cflags, "-DUSE_D8_DESUGAR=1")
107 }
108
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700109 return cflags, asflags
110}
111
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700112func debugFlags(ctx android.LoadHookContext) []string {
Colin Crossbe332ed2016-09-21 13:23:53 -0700113 var cflags []string
114
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700115 opt := ctx.Config().GetenvWithDefault("ART_DEBUG_OPT_FLAG", "-O2")
Colin Crossbe332ed2016-09-21 13:23:53 -0700116 cflags = append(cflags, opt)
117
118 return cflags
119}
120
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700121func deviceFlags(ctx android.LoadHookContext) []string {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700122 var cflags []string
123 deviceFrameSizeLimit := 1736
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700124 if len(ctx.Config().SanitizeDevice()) > 0 {
Vishwath Mohan1ecc4fe2016-09-26 09:22:42 -0700125 deviceFrameSizeLimit = 7400
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700126 }
127 cflags = append(cflags,
128 fmt.Sprintf("-Wframe-larger-than=%d", deviceFrameSizeLimit),
129 fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", deviceFrameSizeLimit),
130 )
131
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700132 cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.Config().LibartImgDeviceBaseAddress())
133 if ctx.Config().IsEnvTrue("ART_TARGET_LINUX") {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700134 cflags = append(cflags, "-DART_TARGET_LINUX")
135 } else {
136 cflags = append(cflags, "-DART_TARGET_ANDROID")
137 }
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700138 minDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA", "-0x1000000")
139 maxDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA", "0x1000000")
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700140 cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta)
141 cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta)
142
143 return cflags
144}
145
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700146func hostFlags(ctx android.LoadHookContext) []string {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700147 var cflags []string
148 hostFrameSizeLimit := 1736
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700149 if len(ctx.Config().SanitizeHost()) > 0 {
Colin Cross3174b682016-09-19 12:25:31 -0700150 // art/test/137-cfi/cfi.cc
151 // error: stack frame size of 1944 bytes in function 'Java_Main_unwindInProcess'
David Srbecky9cc67b12018-10-25 10:10:35 +0000152 hostFrameSizeLimit = 6400
Colin Cross3174b682016-09-19 12:25:31 -0700153 }
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700154 cflags = append(cflags,
155 fmt.Sprintf("-Wframe-larger-than=%d", hostFrameSizeLimit),
156 fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", hostFrameSizeLimit),
157 )
158
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700159 cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.Config().LibartImgHostBaseAddress())
160 minDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA", "-0x1000000")
161 maxDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA", "0x1000000")
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700162 cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta)
163 cflags = append(cflags, "-DART_BASE_ADDRESS_MAX_DELTA="+maxDelta)
164
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700165 if len(ctx.Config().SanitizeHost()) > 0 && !ctx.Config().IsEnvFalse("ART_ENABLE_ADDRESS_SANITIZER") {
Andreas Gampefcc7d672017-07-19 10:30:22 -0700166 // We enable full sanitization on the host by default.
167 cflags = append(cflags, "-DART_ENABLE_ADDRESS_SANITIZER=1")
168 }
169
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700170 return cflags
171}
172
Colin Cross6e511782016-09-13 13:41:03 -0700173func globalDefaults(ctx android.LoadHookContext) {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700174 type props struct {
175 Target struct {
176 Android struct {
177 Cflags []string
178 }
179 Host struct {
180 Cflags []string
181 }
182 }
Colin Cross2db58b62017-06-27 10:38:31 -0700183 Cflags []string
184 Asflags []string
Bharadwaj Kalandhabhatta0bb40312017-06-01 10:47:00 -0700185 Sanitize struct {
Colin Cross2db58b62017-06-27 10:38:31 -0700186 Recover []string
Bharadwaj Kalandhabhatta0bb40312017-06-01 10:47:00 -0700187 }
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700188 }
189
190 p := &props{}
191 p.Cflags, p.Asflags = globalFlags(ctx)
192 p.Target.Android.Cflags = deviceFlags(ctx)
193 p.Target.Host.Cflags = hostFlags(ctx)
Bharadwaj Kalandhabhatta0bb40312017-06-01 10:47:00 -0700194
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700195 if ctx.Config().IsEnvTrue("ART_DEX_FILE_ACCESS_TRACKING") {
Bharadwaj Kalandhabhatta0bb40312017-06-01 10:47:00 -0700196 p.Cflags = append(p.Cflags, "-DART_DEX_FILE_ACCESS_TRACKING")
Colin Cross2db58b62017-06-27 10:38:31 -0700197 p.Sanitize.Recover = []string{
Bharadwaj Kalandhabhatta0bb40312017-06-01 10:47:00 -0700198 "address",
199 }
200 }
201
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700202 ctx.AppendProperties(p)
Colin Crossfe6064a2016-08-30 13:49:26 -0700203}
Colin Cross6326d1b2016-09-06 10:24:28 -0700204
Colin Crossbe332ed2016-09-21 13:23:53 -0700205func debugDefaults(ctx android.LoadHookContext) {
206 type props struct {
207 Cflags []string
208 }
209
210 p := &props{}
211 p.Cflags = debugFlags(ctx)
212 ctx.AppendProperties(p)
213}
214
Colin Cross6e511782016-09-13 13:41:03 -0700215func customLinker(ctx android.LoadHookContext) {
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700216 linker := ctx.Config().Getenv("CUSTOM_TARGET_LINKER")
Colin Cross84b69332017-11-01 14:23:17 -0700217 type props struct {
218 DynamicLinker string
Colin Crossfe6064a2016-08-30 13:49:26 -0700219 }
Colin Cross84b69332017-11-01 14:23:17 -0700220
221 p := &props{}
222 if linker != "" {
223 p.DynamicLinker = linker
224 }
225
226 ctx.AppendProperties(p)
Colin Crossfe6064a2016-08-30 13:49:26 -0700227}
228
Colin Cross6e511782016-09-13 13:41:03 -0700229func prefer32Bit(ctx android.LoadHookContext) {
Colin Cross84b69332017-11-01 14:23:17 -0700230 type props struct {
231 Target struct {
232 Host struct {
233 Compile_multilib *string
Colin Cross6326d1b2016-09-06 10:24:28 -0700234 }
235 }
Colin Cross6326d1b2016-09-06 10:24:28 -0700236 }
Colin Cross84b69332017-11-01 14:23:17 -0700237
238 p := &props{}
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700239 if ctx.Config().IsEnvTrue("HOST_PREFER_32_BIT") {
Colin Cross84b69332017-11-01 14:23:17 -0700240 p.Target.Host.Compile_multilib = proptools.StringPtr("prefer32")
241 }
242
Martin Stjernholme1a44512020-01-31 22:43:43 +0000243 // Prepend to make it overridable in the blueprints. Note that it doesn't work
244 // to override the property in a cc_defaults module.
245 ctx.PrependProperties(p)
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700246}
247
Colin Crossb81d22d2019-02-06 12:42:54 -0800248var testMapKey = android.NewOnceKey("artTests")
249
Colin Cross6e95dd52016-09-12 15:37:10 -0700250func testMap(config android.Config) map[string][]string {
Colin Crossb81d22d2019-02-06 12:42:54 -0800251 return config.Once(testMapKey, func() interface{} {
Colin Cross6e95dd52016-09-12 15:37:10 -0700252 return make(map[string][]string)
253 }).(map[string][]string)
254}
255
256func testInstall(ctx android.InstallHookContext) {
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700257 testMap := testMap(ctx.Config())
Colin Cross6e95dd52016-09-12 15:37:10 -0700258
259 var name string
260 if ctx.Host() {
261 name = "host_"
262 } else {
263 name = "device_"
264 }
265 name += ctx.Arch().ArchType.String() + "_" + ctx.ModuleName()
266
267 artTestMutex.Lock()
268 defer artTestMutex.Unlock()
269
270 tests := testMap[name]
Colin Cross83072062019-10-02 16:06:58 -0700271 tests = append(tests, ctx.Path().ToMakePath().String())
Colin Cross6e95dd52016-09-12 15:37:10 -0700272 testMap[name] = tests
273}
274
David Srbecky1cf46a32020-06-22 15:39:00 +0100275var testcasesContentKey = android.NewOnceKey("artTestcasesContent")
276
277func testcasesContent(config android.Config) map[string]string {
278 return config.Once(testcasesContentKey, func() interface{} {
279 return make(map[string]string)
280 }).(map[string]string)
281}
282
283// Binaries and libraries also need to be copied in the testcases directory for
284// running tests on host. This method adds module to the list of needed files.
285// The 'key' is the file in testcases and 'value' is the path to copy it from.
286// The actual copy will be done in make since soong does not do installations.
287func addTestcasesFile(ctx android.InstallHookContext) {
288 testcasesContent := testcasesContent(ctx.Config())
289
290 artTestMutex.Lock()
291 defer artTestMutex.Unlock()
292
293 if ctx.Os().Class == android.Host {
David Srbeckyb0713ca2020-07-01 15:04:39 +0100294 src := ctx.SrcPath().String()
295 path := strings.Split(ctx.Path().ToMakePath().String(), "/")
296 // Keep last two parts of the install path (e.g. bin/dex2oat).
297 dst := strings.Join(path[len(path)-2:], "/")
298 testcasesContent[dst] = src
David Srbecky1cf46a32020-06-22 15:39:00 +0100299 }
300}
301
Colin Cross6e95dd52016-09-12 15:37:10 -0700302var artTestMutex sync.Mutex
303
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700304func init() {
Paul Duffin0c89d572019-06-27 14:21:12 +0100305 artModuleTypes := []string{
306 "art_cc_library",
307 "art_cc_library_static",
308 "art_cc_binary",
309 "art_cc_test",
310 "art_cc_test_library",
311 "art_cc_defaults",
312 "libart_cc_defaults",
313 "libart_static_cc_defaults",
314 "art_global_defaults",
315 "art_debug_defaults",
Roland Levillain4fb71cc2019-09-11 18:39:59 +0100316 "art_apex_test_host",
Paul Duffin0c89d572019-06-27 14:21:12 +0100317 }
318 android.AddNeverAllowRules(
319 android.NeverAllow().
320 NotIn("art", "external/vixl").
321 ModuleType(artModuleTypes...))
322
Colin Cross96548c92016-10-12 14:26:55 -0700323 android.RegisterModuleType("art_cc_library", artLibrary)
Steven Moreland73030ed2019-01-03 14:23:28 -0800324 android.RegisterModuleType("art_cc_library_static", artStaticLibrary)
Colin Cross96548c92016-10-12 14:26:55 -0700325 android.RegisterModuleType("art_cc_binary", artBinary)
326 android.RegisterModuleType("art_cc_test", artTest)
327 android.RegisterModuleType("art_cc_test_library", artTestLibrary)
328 android.RegisterModuleType("art_cc_defaults", artDefaultsFactory)
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100329 android.RegisterModuleType("libart_cc_defaults", libartDefaultsFactory)
Andreas Gampeec5ed062018-01-26 16:20:02 -0800330 android.RegisterModuleType("libart_static_cc_defaults", libartStaticDefaultsFactory)
Colin Cross96548c92016-10-12 14:26:55 -0700331 android.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory)
332 android.RegisterModuleType("art_debug_defaults", artDebugDefaultsFactory)
Alex Lightda948ce2018-12-06 17:05:41 +0000333
Ulyana Trafimovich7a20cbd2019-11-08 11:27:31 +0000334 // ART apex is special because it must include dexpreopt files for bootclasspath jars.
335 android.RegisterModuleType("art_apex", artApexBundleFactory)
336 android.RegisterModuleType("art_apex_test", artTestApexBundleFactory)
337
Alex Lightda948ce2018-12-06 17:05:41 +0000338 // TODO: This makes the module disable itself for host if HOST_PREFER_32_BIT is
339 // set. We need this because the multilib types of binaries listed in the apex
340 // rule must match the declared type. This is normally not difficult but HOST_PREFER_32_BIT
341 // changes this to 'prefer32' on all host binaries. Since HOST_PREFER_32_BIT is
342 // only used for testing we can just disable the module.
343 // See b/120617876 for more information.
Roland Levillain61f07162019-06-26 12:44:04 +0100344 android.RegisterModuleType("art_apex_test_host", artHostTestApexBundleFactory)
Alex Lightda948ce2018-12-06 17:05:41 +0000345}
346
Ulyana Trafimovich7a20cbd2019-11-08 11:27:31 +0000347func artApexBundleFactory() android.Module {
348 return apex.ApexBundleFactory(false /*testApex*/, true /*artApex*/)
349}
350
351func artTestApexBundleFactory() android.Module {
352 return apex.ApexBundleFactory(true /*testApex*/, true /*artApex*/)
353}
354
Roland Levillain61f07162019-06-26 12:44:04 +0100355func artHostTestApexBundleFactory() android.Module {
Ulyana Trafimovich7a20cbd2019-11-08 11:27:31 +0000356 module := apex.ApexBundleFactory(true /*testApex*/, true /*artApex*/)
Alex Lightda948ce2018-12-06 17:05:41 +0000357 android.AddLoadHook(module, func(ctx android.LoadHookContext) {
Colin Crossdd3b7aa2019-07-31 13:47:39 -0700358 if ctx.Config().IsEnvTrue("HOST_PREFER_32_BIT") {
Alex Lightda948ce2018-12-06 17:05:41 +0000359 type props struct {
360 Target struct {
361 Host struct {
362 Enabled *bool
363 }
364 }
365 }
366
367 p := &props{}
368 p.Target.Host.Enabled = proptools.BoolPtr(false)
369 ctx.AppendProperties(p)
370 log.Print("Disabling host build of " + ctx.ModuleName() + " for HOST_PREFER_32_BIT=true")
371 }
372 })
373
374 return module
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700375}
376
Colin Crossca06ea32017-06-27 10:38:55 -0700377func artGlobalDefaultsFactory() android.Module {
378 module := artDefaultsFactory()
Colin Cross6e511782016-09-13 13:41:03 -0700379 android.AddLoadHook(module, globalDefaults)
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700380
Colin Crossca06ea32017-06-27 10:38:55 -0700381 return module
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700382}
383
Colin Crossca06ea32017-06-27 10:38:55 -0700384func artDebugDefaultsFactory() android.Module {
385 module := artDefaultsFactory()
Colin Crossbe332ed2016-09-21 13:23:53 -0700386 android.AddLoadHook(module, debugDefaults)
387
Colin Crossca06ea32017-06-27 10:38:55 -0700388 return module
Colin Crossbe332ed2016-09-21 13:23:53 -0700389}
390
Colin Crossca06ea32017-06-27 10:38:55 -0700391func artDefaultsFactory() android.Module {
Colin Cross6e511782016-09-13 13:41:03 -0700392 c := &codegenProperties{}
Colin Crossca06ea32017-06-27 10:38:55 -0700393 module := cc.DefaultsFactory(c)
Colin Crossf383ed82019-09-24 15:02:23 -0700394 android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticAndSharedLibrary) })
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700395
Colin Crossca06ea32017-06-27 10:38:55 -0700396 return module
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700397}
398
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100399func libartDefaultsFactory() android.Module {
400 c := &codegenProperties{}
401 module := cc.DefaultsFactory(c)
Colin Crossf383ed82019-09-24 15:02:23 -0700402 android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticAndSharedLibrary) })
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100403
404 return module
405}
406
Andreas Gampeec5ed062018-01-26 16:20:02 -0800407func libartStaticDefaultsFactory() android.Module {
408 c := &codegenProperties{}
409 module := cc.DefaultsFactory(c)
Colin Crossf383ed82019-09-24 15:02:23 -0700410 android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticLibrary) })
Andreas Gampeec5ed062018-01-26 16:20:02 -0800411
412 return module
413}
414
Colin Crossca06ea32017-06-27 10:38:55 -0700415func artLibrary() android.Module {
Paul Duffine78b50e2020-02-18 12:25:40 +0000416 module := cc.LibraryFactory()
Vladimir Marko74527972016-11-29 15:57:32 +0000417
Colin Crossf383ed82019-09-24 15:02:23 -0700418 installCodegenCustomizer(module, staticAndSharedLibrary)
Vladimir Marko74527972016-11-29 15:57:32 +0000419
David Srbecky1cf46a32020-06-22 15:39:00 +0100420 android.AddInstallHook(module, addTestcasesFile)
Vladimir Marko74527972016-11-29 15:57:32 +0000421 return module
422}
423
424func artStaticLibrary() android.Module {
Paul Duffine78b50e2020-02-18 12:25:40 +0000425 module := cc.LibraryStaticFactory()
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700426
Colin Crossf383ed82019-09-24 15:02:23 -0700427 installCodegenCustomizer(module, staticLibrary)
Colin Crossfe6064a2016-08-30 13:49:26 -0700428
Colin Crossca06ea32017-06-27 10:38:55 -0700429 return module
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700430}
431
Colin Crossca06ea32017-06-27 10:38:55 -0700432func artBinary() android.Module {
Paul Duffine78b50e2020-02-18 12:25:40 +0000433 module := cc.BinaryFactory()
Colin Cross123989f2016-09-07 14:12:50 -0700434
Colin Cross6e511782016-09-13 13:41:03 -0700435 android.AddLoadHook(module, customLinker)
436 android.AddLoadHook(module, prefer32Bit)
David Srbecky1cf46a32020-06-22 15:39:00 +0100437 android.AddInstallHook(module, addTestcasesFile)
Colin Crossca06ea32017-06-27 10:38:55 -0700438 return module
Colin Cross123989f2016-09-07 14:12:50 -0700439}
440
Colin Crossca06ea32017-06-27 10:38:55 -0700441func artTest() android.Module {
Paul Duffine78b50e2020-02-18 12:25:40 +0000442 module := cc.TestFactory()
Colin Crossc7376e02016-09-08 12:52:18 -0700443
Colin Crossf383ed82019-09-24 15:02:23 -0700444 installCodegenCustomizer(module, binary)
Colin Cross6e95dd52016-09-12 15:37:10 -0700445
Colin Cross6e511782016-09-13 13:41:03 -0700446 android.AddLoadHook(module, customLinker)
447 android.AddLoadHook(module, prefer32Bit)
Colin Cross6e95dd52016-09-12 15:37:10 -0700448 android.AddInstallHook(module, testInstall)
Colin Crossca06ea32017-06-27 10:38:55 -0700449 return module
Colin Crossc7376e02016-09-08 12:52:18 -0700450}
451
Colin Crossca06ea32017-06-27 10:38:55 -0700452func artTestLibrary() android.Module {
Paul Duffine78b50e2020-02-18 12:25:40 +0000453 module := cc.TestLibraryFactory()
Colin Crossafd3c9e2016-09-16 13:47:21 -0700454
Colin Crossf383ed82019-09-24 15:02:23 -0700455 installCodegenCustomizer(module, staticAndSharedLibrary)
Colin Crossafd3c9e2016-09-16 13:47:21 -0700456
457 android.AddLoadHook(module, prefer32Bit)
458 android.AddInstallHook(module, testInstall)
Colin Crossca06ea32017-06-27 10:38:55 -0700459 return module
Colin Crossafd3c9e2016-09-16 13:47:21 -0700460}