diff options
author | 2019-09-24 15:02:23 -0700 | |
---|---|---|
committer | 2019-10-02 21:39:34 +0000 | |
commit | f383ed8b60405f09996ac2be480df7b4effb8de0 (patch) | |
tree | 4e9fec4dd379349fb9d47c5bec9282f69a0016a7 | |
parent | 43fd2936af2f76f2e73765e3deaeefb0d5e39280 (diff) |
Hide static from cc_library_shared and vice versa
The static properties don't make sense for cc_library_shared
modules, and the shared properties don't make sense for
cc_library_static modules. Move them into separate property
structs so they can be added conditionally.
Test: m nothing
Change-Id: Ic3f95f588a05417dfd470d0e4e9d69c376250a11
-rw-r--r-- | build/art.go | 14 | ||||
-rw-r--r-- | build/codegen.go | 57 |
2 files changed, 51 insertions, 20 deletions
diff --git a/build/art.go b/build/art.go index e21e17638a..31de57fa98 100644 --- a/build/art.go +++ b/build/art.go @@ -360,7 +360,7 @@ func artDebugDefaultsFactory() android.Module { func artDefaultsFactory() android.Module { c := &codegenProperties{} module := cc.DefaultsFactory(c) - android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, true) }) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticAndSharedLibrary) }) return module } @@ -368,7 +368,7 @@ func artDefaultsFactory() android.Module { func libartDefaultsFactory() android.Module { c := &codegenProperties{} module := cc.DefaultsFactory(c) - android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, true) }) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticAndSharedLibrary) }) return module } @@ -376,7 +376,7 @@ func libartDefaultsFactory() android.Module { func libartStaticDefaultsFactory() android.Module { c := &codegenProperties{} module := cc.DefaultsFactory(c) - android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, true) }) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, staticLibrary) }) return module } @@ -385,7 +385,7 @@ func artLibrary() android.Module { m, _ := cc.NewLibrary(android.HostAndDeviceSupported) module := m.Init() - installCodegenCustomizer(module, true) + installCodegenCustomizer(module, staticAndSharedLibrary) return module } @@ -395,7 +395,7 @@ func artStaticLibrary() android.Module { library.BuildOnlyStatic() module := m.Init() - installCodegenCustomizer(module, true) + installCodegenCustomizer(module, staticLibrary) return module } @@ -413,7 +413,7 @@ func artTest() android.Module { test := cc.NewTest(android.HostAndDeviceSupported) module := test.Init() - installCodegenCustomizer(module, false) + installCodegenCustomizer(module, binary) android.AddLoadHook(module, customLinker) android.AddLoadHook(module, prefer32Bit) @@ -425,7 +425,7 @@ func artTestLibrary() android.Module { test := cc.NewTestLibrary(android.HostAndDeviceSupported) module := test.Init() - installCodegenCustomizer(module, false) + installCodegenCustomizer(module, staticAndSharedLibrary) android.AddLoadHook(module, prefer32Bit) android.AddInstallHook(module, testInstall) diff --git a/build/codegen.go b/build/codegen.go index cc967accb8..8e5ef1a609 100644 --- a/build/codegen.go +++ b/build/codegen.go @@ -24,7 +24,20 @@ import ( "strings" ) -func codegen(ctx android.LoadHookContext, c *codegenProperties, library bool) { +type moduleType struct { + library bool + static bool + shared bool +} + +var ( + staticLibrary = moduleType{true, true, false} + sharedLibrary = moduleType{true, false, true} + staticAndSharedLibrary = moduleType{true, true, true} + binary = moduleType{false, false, false} +) + +func codegen(ctx android.LoadHookContext, c *codegenProperties, t moduleType) { var hostArches, deviceArches []string e := envDefault(ctx, "ART_HOST_CODEGEN_ARCHS", "") @@ -92,28 +105,43 @@ func codegen(ctx android.LoadHookContext, c *codegenProperties, library bool) { } } - type libraryProps struct { + type sharedLibraryProps struct { Target struct { - Android *CodegenLibraryArchProperties - Host *CodegenLibraryArchProperties + Android *CodegenLibraryArchSharedProperties + Host *CodegenLibraryArchSharedProperties + } + } + + type staticLibraryProps struct { + Target struct { + Android *CodegenLibraryArchStaticProperties + Host *CodegenLibraryArchStaticProperties } } arch := getCodegenArchProperties(archName) cp := &commonProps{} - lp := &libraryProps{} + sharedLP := &sharedLibraryProps{} + staticLP := &staticLibraryProps{} if host { cp.Target.Host = &arch.CodegenCommonArchProperties - lp.Target.Host = &arch.CodegenLibraryArchProperties + sharedLP.Target.Host = &arch.CodegenLibraryArchSharedProperties + staticLP.Target.Host = &arch.CodegenLibraryArchStaticProperties } else { cp.Target.Android = &arch.CodegenCommonArchProperties - lp.Target.Android = &arch.CodegenLibraryArchProperties + sharedLP.Target.Android = &arch.CodegenLibraryArchSharedProperties + staticLP.Target.Android = &arch.CodegenLibraryArchStaticProperties } ctx.AppendProperties(cp) - if library { - ctx.AppendProperties(lp) + if t.library { + if t.static { + ctx.AppendProperties(staticLP) + } + if t.shared { + ctx.AppendProperties(sharedLP) + } } } @@ -142,10 +170,12 @@ type CodegenCommonArchProperties struct { Cppflags []string } -type CodegenLibraryArchProperties struct { +type CodegenLibraryArchStaticProperties struct { Static struct { Whole_static_libs []string } +} +type CodegenLibraryArchSharedProperties struct { Shared struct { Shared_libs []string Export_shared_lib_headers []string @@ -155,7 +185,8 @@ type CodegenLibraryArchProperties struct { type codegenArchProperties struct { CodegenSourceArchProperties CodegenCommonArchProperties - CodegenLibraryArchProperties + CodegenLibraryArchStaticProperties + CodegenLibraryArchSharedProperties } type codegenProperties struct { @@ -185,8 +216,8 @@ func defaultDeviceCodegenArches(ctx android.LoadHookContext) []string { return ret } -func installCodegenCustomizer(module android.Module, library bool) { +func installCodegenCustomizer(module android.Module, t moduleType) { c := &codegenProperties{} - android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, library) }) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, t) }) module.AddProperties(c) } |