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/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)
 }