Dedup generating xml file for java_sdk_library
Permission XML file for java_sdk_library is generated by
java_sdk_library itself now.
And, build rule is switched to android.WriteFile since "echo -e" is
not supported from build server. (-e is printed to output)
Bug: 145474221
Test: m com.android.cronet and check its permissions xml file
also, m org.chromium.net.cronet.xml (created dynamically)
Change-Id: Iffb119151c49bc4fe6c4386fa267cca193f37dbc
diff --git a/apex/apex.go b/apex/apex.go
index e0ee1ea..48957c2 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1024,12 +1024,12 @@
}
filesInfo = append(filesInfo, af)
- pf := sdkLib.PermissionFile()
- if pf == nil {
+ pf, _ := sdkLib.OutputFiles(".xml")
+ if len(pf) != 1 {
ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
return false
}
- filesInfo = append(filesInfo, newApexFile(ctx, pf, pf.Base(), "etc/permissions", etc, nil))
+ filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 97600b6..a16e317 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3288,8 +3288,8 @@
"etc/permissions/foo.xml",
})
// Permission XML should point to the activated path of impl jar of java_sdk_library
- genXMLCommand := ctx.ModuleForTests("foo", "android_common_myapex").Output("foo.xml").RuleParams.Command
- ensureContains(t, genXMLCommand, `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
+ xml := ctx.ModuleForTests("foo", "android_common_myapex").Output("foo.xml")
+ ensureContains(t, xml.Args["content"], `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
}
func TestRejectNonInstallableJavaLibrary(t *testing.T) {