summaryrefslogtreecommitdiff
path: root/build/codegen.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2016-09-12 15:37:10 -0700
committer Colin Cross <ccross@android.com> 2016-09-15 12:27:06 -0700
commit6e95dd56e43b3a29fb8360bd94e31cd2eaab1d3d (patch)
treec536c5588f8a96f4559ca00921c7852a82558ea5 /build/codegen.go
parent6b22aa5106e60545119b9eeaceaa9f87ee597305 (diff)
Convert art gtests to Android.bp
This splits the compilation and running of the art gtests into two separate locations. The tests are now compiled in multiple Android.bp modules in each directory. art.go collects the installed locations of each test and exports it as make variables. art/build/Android.gtest.mk converts the list into the rules to run the tests. This has a few changes in behavior: - The rules to build tests are now always defined, and will build as part of mmma art or make checkbuild. - Host tests are no longer installed into out/host/linux-x86/bin, they are in out/host/linux-x86/nativetest[64]/<module name>/<test name> - Target tests are now in /data/nativetest[64]/art/<arch>/<module name>/<test name> Test: mmma -j art Test: m -j test-art-host Test: m -j test-art-target Change-Id: Iabcd99d43890e6b693688422b07a283c3226a496
Diffstat (limited to 'build/codegen.go')
-rw-r--r--build/codegen.go83
1 files changed, 61 insertions, 22 deletions
diff --git a/build/codegen.go b/build/codegen.go
index d98ca4fd4f..ba6f2142c9 100644
--- a/build/codegen.go
+++ b/build/codegen.go
@@ -22,9 +22,11 @@ import (
"android/soong/android"
"sort"
"strings"
+
+ "github.com/google/blueprint"
)
-func codegen(ctx android.LoadHookContext, c *codegenProperties) {
+func codegen(ctx android.LoadHookContext, c *codegenProperties, library bool) {
var hostArches, deviceArches []string
e := envDefault(ctx, "ART_HOST_CODEGEN_ARCHS", "")
@@ -41,54 +43,77 @@ func codegen(ctx android.LoadHookContext, c *codegenProperties) {
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.Codegen.Arm
+ arch = &c.Codegen.Arm
case "arm64":
- *hod = &c.Codegen.Arm64
+ arch = &c.Codegen.Arm64
case "mips":
- *hod = &c.Codegen.Mips
+ arch = &c.Codegen.Mips
case "mips64":
- *hod = &c.Codegen.Mips64
+ arch = &c.Codegen.Mips64
case "x86":
- *hod = &c.Codegen.X86
+ arch = &c.Codegen.X86
case "x86_64":
- *hod = &c.Codegen.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
}
@@ -97,6 +122,11 @@ type codegenArchProperties struct {
}
}
+type codegenArchProperties struct {
+ CodegenCommonArchProperties
+ CodegenLibraryArchProperties
+}
+
type codegenProperties struct {
Codegen struct {
Arm, Arm64, Mips, Mips64, X86, X86_64 codegenArchProperties
@@ -104,6 +134,7 @@ type codegenProperties struct {
}
type codegenCustomizer struct {
+ library bool
codegenProperties codegenProperties
}
@@ -127,3 +158,11 @@ func defaultDeviceCodegenArches(ctx android.LoadHookContext) []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
+}