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
diff --git a/build/art.go b/build/art.go
index e21e176..31de57f 100644
--- a/build/art.go
+++ b/build/art.go
@@ -360,7 +360,7 @@
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 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 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 @@
m, _ := cc.NewLibrary(android.HostAndDeviceSupported)
module := m.Init()
- installCodegenCustomizer(module, true)
+ installCodegenCustomizer(module, staticAndSharedLibrary)
return module
}
@@ -395,7 +395,7 @@
library.BuildOnlyStatic()
module := m.Init()
- installCodegenCustomizer(module, true)
+ installCodegenCustomizer(module, staticLibrary)
return module
}
@@ -413,7 +413,7 @@
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 @@
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 cc967ac..8e5ef1a 100644
--- a/build/codegen.go
+++ b/build/codegen.go
@@ -24,7 +24,20 @@
"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 @@
}
}
- 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 @@
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 codegenArchProperties struct {
CodegenSourceArchProperties
CodegenCommonArchProperties
- CodegenLibraryArchProperties
+ CodegenLibraryArchStaticProperties
+ CodegenLibraryArchSharedProperties
}
type codegenProperties struct {
@@ -185,8 +216,8 @@
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)
}