Surface Java APIs Used By APK-only Modules.
Previously we were only generating used-by API-coverage for APEX modules.
This change adds support for APK-only modules such as NetworkStack and DocumentsUI.
Bug: b/216313756
Forrest Run: https://android-build.googleplex.com/builds/abtd/run/L10800000953846781
Test: TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86 ./vendor/google/build/build_unbundled_coverage_mainline_module.sh -j16
Change-Id: Id17e4a55c2a52e9903632a654e778f8d54982dfc
Merged-In: Id17e4a55c2a52e9903632a654e778f8d54982dfc
(cherry picked from commit 56d75785bd
)
This commit is contained in:
@@ -24,7 +24,6 @@ var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers(
|
|||||||
android.MockFS{
|
android.MockFS{
|
||||||
// Needed by apex.
|
// Needed by apex.
|
||||||
"system/core/rootdir/etc/public.libraries.android.txt": nil,
|
"system/core/rootdir/etc/public.libraries.android.txt": nil,
|
||||||
"build/soong/scripts/gen_java_usedby_apex.sh": nil,
|
|
||||||
"build/soong/scripts/gen_ndk_backedby_apex.sh": nil,
|
"build/soong/scripts/gen_ndk_backedby_apex.sh": nil,
|
||||||
// Needed by prebuilt_apex.
|
// Needed by prebuilt_apex.
|
||||||
"build/soong/scripts/unpack-prebuilt-apex.sh": nil,
|
"build/soong/scripts/unpack-prebuilt-apex.sh": nil,
|
||||||
|
@@ -409,7 +409,15 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
|
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
||||||
|
func(w io.Writer, name, prefix, moduleDir string) {
|
||||||
|
if app.javaApiUsedByOutputFile.String() != "" {
|
||||||
|
fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
|
||||||
|
app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) getOverriddenPackages() []string {
|
func (a *AndroidApp) getOverriddenPackages() []string {
|
||||||
|
@@ -169,6 +169,8 @@ type AndroidApp struct {
|
|||||||
overriddenManifestPackageName string
|
overriddenManifestPackageName string
|
||||||
|
|
||||||
android.ApexBundleDepsInfo
|
android.ApexBundleDepsInfo
|
||||||
|
|
||||||
|
javaApiUsedByOutputFile android.ModuleOutPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) IsInstallable() bool {
|
func (a *AndroidApp) IsInstallable() bool {
|
||||||
@@ -277,6 +279,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
|
|||||||
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
a.checkAppSdkVersions(ctx)
|
a.checkAppSdkVersions(ctx)
|
||||||
a.generateAndroidBuildActions(ctx)
|
a.generateAndroidBuildActions(ctx)
|
||||||
|
a.generateJavaUsedByApex(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
||||||
|
@@ -258,6 +258,18 @@ func TransformJniLibsToJar(ctx android.ModuleContext, outputFile android.Writabl
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidApp) generateJavaUsedByApex(ctx android.ModuleContext) {
|
||||||
|
javaApiUsedByOutputFile := android.PathForModuleOut(ctx, a.installApkName+"_using.xml")
|
||||||
|
javaUsedByRule := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
javaUsedByRule.Command().
|
||||||
|
Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")).
|
||||||
|
BuiltTool("dexdeps").
|
||||||
|
Output(javaApiUsedByOutputFile).
|
||||||
|
Input(a.Library.Module.outputFile)
|
||||||
|
javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex")
|
||||||
|
a.javaApiUsedByOutputFile = javaApiUsedByOutputFile
|
||||||
|
}
|
||||||
|
|
||||||
func targetToJniDir(target android.Target) string {
|
func targetToJniDir(target android.Target) string {
|
||||||
return filepath.Join("lib", target.Arch.Abi[0])
|
return filepath.Join("lib", target.Arch.Abi[0])
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,8 @@ var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers(
|
|||||||
"build/soong/java/lint_defaults.txt": nil,
|
"build/soong/java/lint_defaults.txt": nil,
|
||||||
// Needed for apps that do not provide their own.
|
// Needed for apps that do not provide their own.
|
||||||
"build/make/target/product/security": nil,
|
"build/make/target/product/security": nil,
|
||||||
|
// Required to generate Java used-by API coverage
|
||||||
|
"build/soong/scripts/gen_java_usedby_apex.sh": nil,
|
||||||
}.AddToFixture(),
|
}.AddToFixture(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user