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:
parent
3f82e2426e
commit
6e85e4c2bc
3 changed files with 57 additions and 23 deletions
|
@ -40,26 +40,31 @@ type variableAssignmentContext struct {
|
|||
append bool
|
||||
}
|
||||
|
||||
var trueValue = &bpparser.Bool{
|
||||
Value: true,
|
||||
}
|
||||
|
||||
var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
||||
// custom functions
|
||||
"LOCAL_32_BIT_ONLY": local32BitOnly,
|
||||
"LOCAL_AIDL_INCLUDES": localAidlIncludes,
|
||||
"LOCAL_ASSET_DIR": localizePathList("asset_dirs"),
|
||||
"LOCAL_C_INCLUDES": localIncludeDirs,
|
||||
"LOCAL_EXPORT_C_INCLUDE_DIRS": exportIncludeDirs,
|
||||
"LOCAL_JARJAR_RULES": localizePath("jarjar_rules"),
|
||||
"LOCAL_LDFLAGS": ldflags,
|
||||
"LOCAL_MODULE_CLASS": prebuiltClass,
|
||||
"LOCAL_MODULE_STEM": stem,
|
||||
"LOCAL_MODULE_HOST_OS": hostOs,
|
||||
"LOCAL_RESOURCE_DIR": localizePathList("resource_dirs"),
|
||||
"LOCAL_SANITIZE": sanitize(""),
|
||||
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
||||
"LOCAL_STRIP_MODULE": strip(),
|
||||
"LOCAL_CFLAGS": cflags,
|
||||
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
|
||||
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
|
||||
"LOCAL_MODULE_PATH": prebuiltModulePath,
|
||||
"LOCAL_32_BIT_ONLY": local32BitOnly,
|
||||
"LOCAL_AIDL_INCLUDES": localAidlIncludes,
|
||||
"LOCAL_ASSET_DIR": localizePathList("asset_dirs"),
|
||||
"LOCAL_C_INCLUDES": localIncludeDirs,
|
||||
"LOCAL_EXPORT_C_INCLUDE_DIRS": exportIncludeDirs,
|
||||
"LOCAL_JARJAR_RULES": localizePath("jarjar_rules"),
|
||||
"LOCAL_LDFLAGS": ldflags,
|
||||
"LOCAL_MODULE_CLASS": prebuiltClass,
|
||||
"LOCAL_MODULE_STEM": stem,
|
||||
"LOCAL_MODULE_HOST_OS": hostOs,
|
||||
"LOCAL_RESOURCE_DIR": localizePathList("resource_dirs"),
|
||||
"LOCAL_SANITIZE": sanitize(""),
|
||||
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
||||
"LOCAL_STRIP_MODULE": strip(),
|
||||
"LOCAL_CFLAGS": cflags,
|
||||
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
|
||||
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
|
||||
"LOCAL_MODULE_PATH": prebuiltModulePath,
|
||||
"LOCAL_REPLACE_PREBUILT_APK_INSTALLED": prebuiltPreprocessed,
|
||||
|
||||
// composite functions
|
||||
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
||||
|
@ -495,10 +500,6 @@ func hostOs(ctx variableAssignmentContext) error {
|
|||
Value: false,
|
||||
}
|
||||
|
||||
trueValue := &bpparser.Bool{
|
||||
Value: true,
|
||||
}
|
||||
|
||||
if inList("windows") {
|
||||
err = setVariable(ctx.file, ctx.append, "target.windows", "enabled", trueValue, true)
|
||||
}
|
||||
|
@ -704,6 +705,11 @@ func ldflags(ctx variableAssignmentContext) error {
|
|||
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 {
|
||||
// The Soong replacement for CFLAGS doesn't need the same extra escaped quotes that were present in Make
|
||||
ctx.mkvalue = ctx.mkvalue.Clone()
|
||||
|
|
|
@ -1339,6 +1339,31 @@ android_app_import {
|
|||
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 {
|
||||
case "android_app":
|
||||
mod.Type = "android_test"
|
||||
case "android_app_import":
|
||||
mod.Type = "android_test_import"
|
||||
case "java_library", "java_library_installable":
|
||||
mod.Type = "java_test"
|
||||
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"),
|
||||
strings.Contains(mod.Type, "cc_library_static"),
|
||||
strings.Contains(mod.Type, "java_test"),
|
||||
mod.Type == "android_test":
|
||||
mod.Type == "android_test",
|
||||
mod.Type == "android_test_import":
|
||||
continue
|
||||
case strings.Contains(mod.Type, "cc_lib"):
|
||||
replaceStr += `// WARNING: Module tags are not supported in Soong.
|
||||
|
|
Loading…
Reference in a new issue