Handle license conversions in androidmk

1. Support license conversions in the androidmk tool. More details can be
found at go/license-androidmk;
2. As usage examples, locally this functionality has been applied to
aosp/1881088 and aosp/1869664;

Bug: 202964622
Test: m androidmk
Test: manually ran androidmk <typical Android.mk files>
Test: TreeHugger
Change-Id: I7d5013d25ad8961e997109d0378f20f5085e0ecf
This commit is contained in:
Yuntao Xu
2021-10-13 10:47:54 -07:00
parent 92a89ed1c5
commit 214cdaf1d4
4 changed files with 616 additions and 17 deletions

View File

@@ -58,6 +58,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
"LOCAL_MODULE_STEM": stem,
"LOCAL_MODULE_HOST_OS": hostOs,
"LOCAL_RESOURCE_DIR": localizePathList("resource_dirs"),
"LOCAL_NOTICE_FILE": localizePathList("android_license_files"),
"LOCAL_SANITIZE": sanitize(""),
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
"LOCAL_STRIP_MODULE": strip(),
@@ -111,7 +112,6 @@ func init() {
"LOCAL_PROTOC_OPTIMIZE_TYPE": "proto.type",
"LOCAL_MODULE_OWNER": "owner",
"LOCAL_RENDERSCRIPT_TARGET_API": "renderscript.target_api",
"LOCAL_NOTICE_FILE": "notice",
"LOCAL_JAVA_LANGUAGE_VERSION": "java_version",
"LOCAL_INSTRUMENTATION_FOR": "instrumentation_for",
"LOCAL_MANIFEST_FILE": "manifest",
@@ -185,6 +185,12 @@ func init() {
"LOCAL_JACK_COVERAGE_EXCLUDE_FILTER": "jacoco.exclude_filter",
"LOCAL_FULL_LIBS_MANIFEST_FILES": "additional_manifests",
// will be rewrite later to "license_kinds:" by byfix
"LOCAL_LICENSE_KINDS": "android_license_kinds",
// will be removed later by byfix
// TODO: does this property matter in the license module?
"LOCAL_LICENSE_CONDITIONS": "android_license_conditions",
})
addStandardProperties(bpparser.BoolType,

View File

@@ -1516,7 +1516,8 @@ android_app {
],
}
`,
}, {
},
{
desc: "Obsolete LOCAL_MODULE_PATH",
in: `
include $(CLEAR_VARS)
@@ -1532,7 +1533,37 @@ android_app {
name: "foo",
}
`},
`,
},
{
desc: "LOCAL_LICENSE_KINDS, LOCAL_LICENSE_CONDITIONS, LOCAL_NOTICE_FILE",
// TODO(b/205615944): When valid "android_license_files" exists, the test requires an Android.mk
// file (and an Android.bp file is required as well if the license files locates outside the current
// directory). So plan to use a mock file system to mock the Android.mk and Android.bp files.
in: `
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_LICENSE_KINDS := license_kind
LOCAL_LICENSE_CONDITIONS := license_condition
LOCAL_NOTICE_FILE := license_notice
include $(BUILD_PACKAGE)
`,
expected: `
package {
// See: http://go/android-license-faq
default_applicable_licenses: [
"Android-Apache-2.0",
],
}
android_app {
name: "foo",
// ANDROIDMK TRANSLATION ERROR: Only $(LOCAL_PATH)/.. values are allowed
// LOCAL_NOTICE_FILE := license_notice
}
`,
},
}
func TestEndToEnd(t *testing.T) {