Add BUILD_CTS_* to androidmk
Bug: 122617736 Test: new unit tests Change-Id: Ibce6b4bbe49015a1ca6cf88cd43badc6b5cc078e
This commit is contained in:
parent
adf980bf91
commit
e9622a33c3
4 changed files with 181 additions and 0 deletions
|
@ -803,6 +803,11 @@ var moduleTypes = map[string]string{
|
|||
"BUILD_HOST_JAVA_LIBRARY": "java_library_host",
|
||||
"BUILD_HOST_DALVIK_JAVA_LIBRARY": "java_library_host_dalvik",
|
||||
"BUILD_PACKAGE": "android_app",
|
||||
|
||||
"BUILD_CTS_SUPPORT_PACKAGE": "cts_support_package", // will be rewritten to android_test by bpfix
|
||||
"BUILD_CTS_PACKAGE": "cts_package", // will be rewritten to android_test by bpfix
|
||||
"BUILD_CTS_TARGET_JAVA_LIBRARY": "cts_target_java_library", // will be rewritten to java_library by bpfix
|
||||
"BUILD_CTS_HOST_JAVA_LIBRARY": "cts_host_java_library", // will be rewritten to java_library_host by bpfix
|
||||
}
|
||||
|
||||
var prebuiltTypes = map[string]string{
|
||||
|
|
|
@ -750,6 +750,61 @@ cc_library_shared {
|
|||
keep_symbols: true,
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "BUILD_CTS_SUPPORT_PACKAGE",
|
||||
in: `
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_PACKAGE_NAME := FooTest
|
||||
LOCAL_COMPATIBILITY_SUITE := cts
|
||||
include $(BUILD_CTS_SUPPORT_PACKAGE)
|
||||
`,
|
||||
expected: `
|
||||
android_test {
|
||||
name: "FooTest",
|
||||
defaults: ["cts_support_defaults"],
|
||||
test_suites: ["cts"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "BUILD_CTS_PACKAGE",
|
||||
in: `
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_PACKAGE_NAME := FooTest
|
||||
LOCAL_COMPATIBILITY_SUITE := cts
|
||||
include $(BUILD_CTS_PACKAGE)
|
||||
`,
|
||||
expected: `
|
||||
android_test {
|
||||
name: "FooTest",
|
||||
defaults: ["cts_defaults"],
|
||||
test_suites: ["cts"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "BUILD_CTS_*_JAVA_LIBRARY",
|
||||
in: `
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := foolib
|
||||
include $(BUILD_CTS_TARGET_JAVA_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := foolib-host
|
||||
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
|
||||
`,
|
||||
expected: `
|
||||
java_library {
|
||||
name: "foolib",
|
||||
defaults: ["cts_defaults"],
|
||||
}
|
||||
|
||||
java_library_host {
|
||||
name: "foolib-host",
|
||||
defaults: ["cts_defaults"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ var fixSteps = []fixStep{
|
|||
name: "rewriteIncorrectAndroidmkPrebuilts",
|
||||
fix: rewriteIncorrectAndroidmkPrebuilts,
|
||||
},
|
||||
{
|
||||
name: "rewriteCtsModuleTypes",
|
||||
fix: rewriteCtsModuleTypes,
|
||||
},
|
||||
{
|
||||
name: "rewriteIncorrectAndroidmkAndroidLibraries",
|
||||
fix: rewriteIncorrectAndroidmkAndroidLibraries,
|
||||
|
@ -237,6 +241,52 @@ func rewriteIncorrectAndroidmkPrebuilts(f *Fixer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func rewriteCtsModuleTypes(f *Fixer) error {
|
||||
for _, def := range f.tree.Defs {
|
||||
mod, ok := def.(*parser.Module)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if mod.Type != "cts_support_package" && mod.Type != "cts_package" &&
|
||||
mod.Type != "cts_target_java_library" &&
|
||||
mod.Type != "cts_host_java_library" {
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
var defStr string
|
||||
switch mod.Type {
|
||||
case "cts_support_package":
|
||||
mod.Type = "android_test"
|
||||
defStr = "cts_support_defaults"
|
||||
case "cts_package":
|
||||
mod.Type = "android_test"
|
||||
defStr = "cts_defaults"
|
||||
case "cts_target_java_library":
|
||||
mod.Type = "java_library"
|
||||
defStr = "cts_defaults"
|
||||
case "cts_host_java_library":
|
||||
mod.Type = "java_library_host"
|
||||
defStr = "cts_defaults"
|
||||
}
|
||||
|
||||
defaults := &parser.Property{
|
||||
Name: "defaults",
|
||||
Value: &parser.List{
|
||||
Values: []parser.Expression{
|
||||
&parser.String{
|
||||
Value: defStr,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
mod.Properties = append(mod.Properties, defaults)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func rewriteIncorrectAndroidmkAndroidLibraries(f *Fixer) error {
|
||||
for _, def := range f.tree.Defs {
|
||||
mod, ok := def.(*parser.Module)
|
||||
|
|
|
@ -621,3 +621,74 @@ func TestRewritePrebuilts(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteCtsModuleTypes(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
out string
|
||||
}{
|
||||
{
|
||||
name: "cts_support_package",
|
||||
in: `
|
||||
cts_support_package {
|
||||
name: "foo",
|
||||
}
|
||||
`,
|
||||
out: `
|
||||
android_test {
|
||||
name: "foo",
|
||||
defaults: ["cts_support_defaults"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "cts_package",
|
||||
in: `
|
||||
cts_package {
|
||||
name: "foo",
|
||||
}
|
||||
`,
|
||||
out: `
|
||||
android_test {
|
||||
name: "foo",
|
||||
defaults: ["cts_defaults"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "cts_target_java_library",
|
||||
in: `
|
||||
cts_target_java_library {
|
||||
name: "foo",
|
||||
}
|
||||
`,
|
||||
out: `
|
||||
java_library {
|
||||
name: "foo",
|
||||
defaults: ["cts_defaults"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "cts_host_java_library",
|
||||
in: `
|
||||
cts_host_java_library {
|
||||
name: "foo",
|
||||
}
|
||||
`,
|
||||
out: `
|
||||
java_library_host {
|
||||
name: "foo",
|
||||
defaults: ["cts_defaults"],
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
runPass(t, test.in, test.out, rewriteCtsModuleTypes)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue