diff options
Diffstat (limited to 'build/art.go')
-rw-r--r-- | build/art.go | 85 |
1 files changed, 59 insertions, 26 deletions
diff --git a/build/art.go b/build/art.go index f694505fb4..ba5521a9ae 100644 --- a/build/art.go +++ b/build/art.go @@ -19,6 +19,7 @@ import ( "android/soong/android" "android/soong/cc" "fmt" + "sync" "github.com/google/blueprint" ) @@ -71,12 +72,6 @@ func globalFlags(ctx android.BaseContext) ([]string, []string) { cflags = append(cflags, "-fstack-protector") } - // Are additional statically-linked ART host binaries - // (dex2oats, oatdumps, etc.) getting built? - if envTrue(ctx, "ART_BUILD_HOST_STATIC") { - cflags = append(cflags, "-DART_BUILD_HOST_STATIC=1") - } - return cflags, asflags } @@ -108,6 +103,11 @@ func deviceFlags(ctx android.BaseContext) []string { func hostFlags(ctx android.BaseContext) []string { var cflags []string hostFrameSizeLimit := 1736 + if len(ctx.AConfig().SanitizeHost()) > 0 { + // art/test/137-cfi/cfi.cc + // error: stack frame size of 1944 bytes in function 'Java_Main_unwindInProcess' + hostFrameSizeLimit = 6400 + } cflags = append(cflags, fmt.Sprintf("-Wframe-larger-than=%d", hostFrameSizeLimit), fmt.Sprintf("-DART_FRAME_SIZE_LIMIT=%d", hostFrameSizeLimit), @@ -122,7 +122,7 @@ func hostFlags(ctx android.BaseContext) []string { return cflags } -func (a *artGlobalDefaults) CustomizeProperties(ctx android.CustomizePropertiesContext) { +func globalDefaults(ctx android.LoadHookContext) { type props struct { Target struct { Android struct { @@ -143,9 +143,7 @@ func (a *artGlobalDefaults) CustomizeProperties(ctx android.CustomizePropertiesC ctx.AppendProperties(p) } -type artGlobalDefaults struct{} - -func (a *artCustomLinkerCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) { +func customLinker(ctx android.LoadHookContext) { linker := envDefault(ctx, "CUSTOM_TARGET_LINKER", "") if linker != "" { type props struct { @@ -158,9 +156,7 @@ func (a *artCustomLinkerCustomizer) CustomizeProperties(ctx android.CustomizePro } } -type artCustomLinkerCustomizer struct{} - -func (a *artPrefer32BitCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) { +func prefer32Bit(ctx android.LoadHookContext) { if envTrue(ctx, "HOST_PREFER_32_BIT") { type props struct { Target struct { @@ -176,28 +172,53 @@ func (a *artPrefer32BitCustomizer) CustomizeProperties(ctx android.CustomizeProp } } -type artPrefer32BitCustomizer struct{} +func testMap(config android.Config) map[string][]string { + return config.Once("artTests", func() interface{} { + return make(map[string][]string) + }).(map[string][]string) +} + +func testInstall(ctx android.InstallHookContext) { + testMap := testMap(ctx.AConfig()) + + var name string + if ctx.Host() { + name = "host_" + } else { + name = "device_" + } + name += ctx.Arch().ArchType.String() + "_" + ctx.ModuleName() + + artTestMutex.Lock() + defer artTestMutex.Unlock() + + tests := testMap[name] + tests = append(tests, ctx.Path().RelPathString()) + testMap[name] = tests +} + +var artTestMutex sync.Mutex func init() { soong.RegisterModuleType("art_cc_library", artLibrary) soong.RegisterModuleType("art_cc_binary", artBinary) soong.RegisterModuleType("art_cc_test", artTest) + soong.RegisterModuleType("art_cc_test_library", artTestLibrary) soong.RegisterModuleType("art_cc_defaults", artDefaultsFactory) soong.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory) } func artGlobalDefaultsFactory() (blueprint.Module, []interface{}) { - c := &artGlobalDefaults{} module, props := artDefaultsFactory() - android.AddCustomizer(module.(android.Module), c) + android.AddLoadHook(module, globalDefaults) return module, props } func artDefaultsFactory() (blueprint.Module, []interface{}) { - c := &codegenCustomizer{} - module, props := cc.DefaultsFactory(&c.codegenProperties) - android.AddCustomizer(module.(android.Module), c) + c := &codegenProperties{} + module, props := cc.DefaultsFactory(c) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, true) }) return module, props } @@ -206,9 +227,7 @@ func artLibrary() (blueprint.Module, []interface{}) { library, _ := cc.NewLibrary(android.HostAndDeviceSupported, true, true) module, props := library.Init() - c := &codegenCustomizer{} - android.AddCustomizer(library, c) - props = append(props, &c.codegenProperties) + props = installCodegenCustomizer(module, props, true) return module, props } @@ -217,8 +236,8 @@ func artBinary() (blueprint.Module, []interface{}) { binary, _ := cc.NewBinary(android.HostAndDeviceSupported) module, props := binary.Init() - android.AddCustomizer(binary, &artCustomLinkerCustomizer{}) - android.AddCustomizer(binary, &artPrefer32BitCustomizer{}) + android.AddLoadHook(module, customLinker) + android.AddLoadHook(module, prefer32Bit) return module, props } @@ -226,8 +245,22 @@ func artTest() (blueprint.Module, []interface{}) { test := cc.NewTest(android.HostAndDeviceSupported) module, props := test.Init() - android.AddCustomizer(test, &artCustomLinkerCustomizer{}) - android.AddCustomizer(test, &artPrefer32BitCustomizer{}) + props = installCodegenCustomizer(module, props, false) + + android.AddLoadHook(module, customLinker) + android.AddLoadHook(module, prefer32Bit) + android.AddInstallHook(module, testInstall) + return module, props +} + +func artTestLibrary() (blueprint.Module, []interface{}) { + test := cc.NewTestLibrary(android.HostAndDeviceSupported) + module, props := test.Init() + + props = installCodegenCustomizer(module, props, false) + + android.AddLoadHook(module, prefer32Bit) + android.AddInstallHook(module, testInstall) return module, props } |