Revert "Reimplement verify_uses_libraries.sh in manifest_check.py."
Revert submission 1614807-uses-libs-47
Reason for revert: broken build 7215516 on git_sc-dev \
on aosp_blueline-userdebug
Reverted Changes:
Id1b66e4f3:Reimplement verify_uses_libraries.sh in manifest_c...
I386aa1a37:Reimplement verify_uses_libraries.sh in manifest_c...
Bug: 183010666
Change-Id: I4c2d4e1c7d865dabf31339d1a5f6aea09fdcd8ac
Test: treehugger
diff --git a/java/app.go b/java/app.go
index 3ef31d5..59f823e 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1281,13 +1281,10 @@
u.usesLibraryProperties.Enforce_uses_libs = &enforce
}
-// verifyUsesLibraries checks the <uses-library> tags in the manifest against the ones specified
-// in the `uses_libs`/`optional_uses_libs` properties. The input can be either an XML manifest, or
-// an APK with the manifest embedded in it (manifest_check will know which one it is by the file
-// extension: APKs are supposed to end with '.apk').
-func (u *usesLibrary) verifyUsesLibraries(ctx android.ModuleContext, inputFile android.Path,
- outputFile android.WritablePath) {
-
+// verifyUsesLibrariesManifest checks the <uses-library> tags in an AndroidManifest.xml against the ones specified
+// in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the manifest.
+func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path {
+ outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
statusFile := dexpreopt.UsesLibrariesStatusFile(ctx)
// Disable verify_uses_libraries check if dexpreopt is globally disabled. Without dexpreopt the
@@ -1295,19 +1292,15 @@
// non-linux build platforms where dexpreopt is generally disabled (the check may fail due to
// various unrelated reasons, such as a failure to get manifest from an APK).
if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
- return
+ return manifest
}
rule := android.NewRuleBuilder(pctx, ctx)
cmd := rule.Command().BuiltTool("manifest_check").
Flag("--enforce-uses-libraries").
- Input(inputFile).
+ Input(manifest).
FlagWithOutput("--enforce-uses-libraries-status ", statusFile).
- FlagWithInput("--aapt ", ctx.Config().HostToolPath(ctx, "aapt"))
-
- if outputFile != nil {
- cmd.FlagWithOutput("-o ", outputFile)
- }
+ FlagWithOutput("-o ", outputFile)
if dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck {
cmd.Flag("--enforce-uses-libraries-relax")
@@ -1322,20 +1315,35 @@
}
rule.Build("verify_uses_libraries", "verify <uses-library>")
-}
-// verifyUsesLibrariesManifest checks the <uses-library> tags in an AndroidManifest.xml against
-// the build system and returns the path to a copy of the manifest.
-func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path {
- outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
- u.verifyUsesLibraries(ctx, manifest, outputFile)
return outputFile
}
-// verifyUsesLibrariesAPK checks the <uses-library> tags in the manifest of an APK against the build
-// system and returns the path to a copy of the APK.
+// verifyUsesLibrariesAPK checks the <uses-library> tags in the manifest of an APK against the ones specified
+// in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the APK.
func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path) android.Path {
- u.verifyUsesLibraries(ctx, apk, nil) // for APKs manifest_check does not write output file
outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base())
+ statusFile := dexpreopt.UsesLibrariesStatusFile(ctx)
+
+ // Disable verify_uses_libraries check if dexpreopt is globally disabled. Without dexpreopt the
+ // check is not necessary, and although it is good to have, it is difficult to maintain on
+ // non-linux build platforms where dexpreopt is generally disabled (the check may fail due to
+ // various unrelated reasons, such as a failure to get manifest from an APK).
+ if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
+ return apk
+ }
+
+ rule := android.NewRuleBuilder(pctx, ctx)
+ aapt := ctx.Config().HostToolPath(ctx, "aapt")
+ rule.Command().
+ Textf("aapt_binary=%s", aapt.String()).Implicit(aapt).
+ Textf(`uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Uses_libs, " ")).
+ Textf(`optional_uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Optional_uses_libs, " ")).
+ Textf(`relax_check="%t"`, dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck).
+ Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk).Output(statusFile)
+ rule.Command().Text("cp -f").Input(apk).Output(outputFile)
+
+ rule.Build("verify_uses_libraries", "verify <uses-library>")
+
return outputFile
}