diff options
Diffstat (limited to 'build/codegen.go')
-rw-r--r-- | build/codegen.go | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/build/codegen.go b/build/codegen.go index fde9420039..ba6f2142c9 100644 --- a/build/codegen.go +++ b/build/codegen.go @@ -22,11 +22,11 @@ import ( "android/soong/android" "sort" "strings" -) -func (a *codegenCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) { - c := &a.codegenProperties.Codegen + "github.com/google/blueprint" +) +func codegen(ctx android.LoadHookContext, c *codegenProperties, library bool) { var hostArches, deviceArches []string e := envDefault(ctx, "ART_HOST_CODEGEN_ARCHS", "") @@ -43,54 +43,77 @@ func (a *codegenCustomizer) CustomizeProperties(ctx android.CustomizePropertiesC deviceArches = strings.Split(e, " ") } - type props struct { - Target struct { - Android *codegenArchProperties - Host *codegenArchProperties + addCodegenArchProperties := func(host bool, archName string) { + type props struct { + Target struct { + Android *CodegenCommonArchProperties + Host *CodegenCommonArchProperties + } } - } - addCodegenArchProperties := func(p *props, hod **codegenArchProperties, arch string) { - switch arch { + type libraryProps struct { + Target struct { + Android *CodegenLibraryArchProperties + Host *CodegenLibraryArchProperties + } + } + + var arch *codegenArchProperties + switch archName { case "arm": - *hod = &c.Arm + arch = &c.Codegen.Arm case "arm64": - *hod = &c.Arm64 + arch = &c.Codegen.Arm64 case "mips": - *hod = &c.Mips + arch = &c.Codegen.Mips case "mips64": - *hod = &c.Mips64 + arch = &c.Codegen.Mips64 case "x86": - *hod = &c.X86 + arch = &c.Codegen.X86 case "x86_64": - *hod = &c.X86_64 + arch = &c.Codegen.X86_64 default: - ctx.ModuleErrorf("Unknown codegen architecture %q", arch) + ctx.ModuleErrorf("Unknown codegen architecture %q", archName) return } + + p := &props{} + l := &libraryProps{} + if host { + p.Target.Host = &arch.CodegenCommonArchProperties + l.Target.Host = &arch.CodegenLibraryArchProperties + } else { + p.Target.Android = &arch.CodegenCommonArchProperties + l.Target.Android = &arch.CodegenLibraryArchProperties + } + ctx.AppendProperties(p) + if library { + ctx.AppendProperties(l) + } } - for _, a := range deviceArches { - p := &props{} - addCodegenArchProperties(p, &p.Target.Android, a) + for _, arch := range deviceArches { + addCodegenArchProperties(false, arch) if ctx.Failed() { return } } - for _, a := range hostArches { - p := &props{} - addCodegenArchProperties(p, &p.Target.Host, a) + for _, arch := range hostArches { + addCodegenArchProperties(true, arch) if ctx.Failed() { return } } } -type codegenArchProperties struct { +type CodegenCommonArchProperties struct { Srcs []string Cflags []string +} + +type CodegenLibraryArchProperties struct { Static struct { Whole_static_libs []string } @@ -99,6 +122,11 @@ type codegenArchProperties struct { } } +type codegenArchProperties struct { + CodegenCommonArchProperties + CodegenLibraryArchProperties +} + type codegenProperties struct { Codegen struct { Arm, Arm64, Mips, Mips64, X86, X86_64 codegenArchProperties @@ -106,10 +134,11 @@ type codegenProperties struct { } type codegenCustomizer struct { + library bool codegenProperties codegenProperties } -func defaultDeviceCodegenArches(ctx android.CustomizePropertiesContext) []string { +func defaultDeviceCodegenArches(ctx android.LoadHookContext) []string { arches := make(map[string]bool) for _, a := range ctx.DeviceConfig().Arches() { s := a.ArchType.String() @@ -129,3 +158,11 @@ func defaultDeviceCodegenArches(ctx android.CustomizePropertiesContext) []string sort.Strings(ret) return ret } + +func installCodegenCustomizer(module blueprint.Module, props []interface{}, library bool) []interface{} { + c := &codegenProperties{} + android.AddLoadHook(module, func(ctx android.LoadHookContext) { codegen(ctx, c, library) }) + props = append(props, c) + + return props +} |