Support preprocessed prebuilt tests in androidmk
Adds support to translate app prebuilt tests to android_test_import and LOCAL_REPLACE_PREBUILT_APK_INSTALLED to preprocessed property. Test: androidmk_test.go, bpfix_test.go Bug: 155412211 Change-Id: I77c07c684125adf228ba91911998823a68b3a65d
This commit is contained in:
@@ -40,6 +40,10 @@ type variableAssignmentContext struct {
|
|||||||
append bool
|
append bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var trueValue = &bpparser.Bool{
|
||||||
|
Value: true,
|
||||||
|
}
|
||||||
|
|
||||||
var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
||||||
// custom functions
|
// custom functions
|
||||||
"LOCAL_32_BIT_ONLY": local32BitOnly,
|
"LOCAL_32_BIT_ONLY": local32BitOnly,
|
||||||
@@ -60,6 +64,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
|||||||
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
|
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
|
||||||
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
|
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
|
||||||
"LOCAL_MODULE_PATH": prebuiltModulePath,
|
"LOCAL_MODULE_PATH": prebuiltModulePath,
|
||||||
|
"LOCAL_REPLACE_PREBUILT_APK_INSTALLED": prebuiltPreprocessed,
|
||||||
|
|
||||||
// composite functions
|
// composite functions
|
||||||
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
||||||
@@ -495,10 +500,6 @@ func hostOs(ctx variableAssignmentContext) error {
|
|||||||
Value: false,
|
Value: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
trueValue := &bpparser.Bool{
|
|
||||||
Value: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if inList("windows") {
|
if inList("windows") {
|
||||||
err = setVariable(ctx.file, ctx.append, "target.windows", "enabled", trueValue, true)
|
err = setVariable(ctx.file, ctx.append, "target.windows", "enabled", trueValue, true)
|
||||||
}
|
}
|
||||||
@@ -704,6 +705,11 @@ func ldflags(ctx variableAssignmentContext) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prebuiltPreprocessed(ctx variableAssignmentContext) error {
|
||||||
|
ctx.mkvalue = ctx.mkvalue.Clone()
|
||||||
|
return setVariable(ctx.file, false, ctx.prefix, "preprocessed", trueValue, true)
|
||||||
|
}
|
||||||
|
|
||||||
func cflags(ctx variableAssignmentContext) error {
|
func cflags(ctx variableAssignmentContext) error {
|
||||||
// The Soong replacement for CFLAGS doesn't need the same extra escaped quotes that were present in Make
|
// The Soong replacement for CFLAGS doesn't need the same extra escaped quotes that were present in Make
|
||||||
ctx.mkvalue = ctx.mkvalue.Clone()
|
ctx.mkvalue = ctx.mkvalue.Clone()
|
||||||
|
@@ -1339,6 +1339,31 @@ android_app_import {
|
|||||||
apk: "foo.apk",
|
apk: "foo.apk",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "android_test_import prebuilt",
|
||||||
|
in: `
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := foo
|
||||||
|
LOCAL_SRC_FILES := foo.apk
|
||||||
|
LOCAL_MODULE_CLASS := APPS
|
||||||
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
LOCAL_MODULE_SUFFIX := .apk
|
||||||
|
LOCAL_CERTIFICATE := PRESIGNED
|
||||||
|
LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/foo.apk
|
||||||
|
LOCAL_COMPATIBILITY_SUITE := cts
|
||||||
|
include $(BUILD_PREBUILT)
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
android_test_import {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["foo.apk"],
|
||||||
|
|
||||||
|
certificate: "PRESIGNED",
|
||||||
|
preprocessed: true,
|
||||||
|
test_suites: ["cts"],
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -408,6 +408,8 @@ func rewriteTestModuleTypes(f *Fixer) error {
|
|||||||
switch mod.Type {
|
switch mod.Type {
|
||||||
case "android_app":
|
case "android_app":
|
||||||
mod.Type = "android_test"
|
mod.Type = "android_test"
|
||||||
|
case "android_app_import":
|
||||||
|
mod.Type = "android_test_import"
|
||||||
case "java_library", "java_library_installable":
|
case "java_library", "java_library_installable":
|
||||||
mod.Type = "java_test"
|
mod.Type = "java_test"
|
||||||
case "java_library_host":
|
case "java_library_host":
|
||||||
@@ -951,7 +953,8 @@ func removeTags(mod *parser.Module, buf []byte, patchlist *parser.PatchList) err
|
|||||||
case strings.Contains(mod.Type, "cc_test"),
|
case strings.Contains(mod.Type, "cc_test"),
|
||||||
strings.Contains(mod.Type, "cc_library_static"),
|
strings.Contains(mod.Type, "cc_library_static"),
|
||||||
strings.Contains(mod.Type, "java_test"),
|
strings.Contains(mod.Type, "java_test"),
|
||||||
mod.Type == "android_test":
|
mod.Type == "android_test",
|
||||||
|
mod.Type == "android_test_import":
|
||||||
continue
|
continue
|
||||||
case strings.Contains(mod.Type, "cc_lib"):
|
case strings.Contains(mod.Type, "cc_lib"):
|
||||||
replaceStr += `// WARNING: Module tags are not supported in Soong.
|
replaceStr += `// WARNING: Module tags are not supported in Soong.
|
||||||
|
Reference in New Issue
Block a user