diff options
Diffstat (limited to 'build/codegen.go')
-rw-r--r-- | build/codegen.go | 57 |
1 files changed, 44 insertions, 13 deletions
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) } |