Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5892457a authored by Matt Banda's avatar Matt Banda
Browse files

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 56d75785)
parent 11cca671
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers(
	android.MockFS{
		// Needed by apex.
		"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,
		// Needed by prebuilt_apex.
		"build/soong/scripts/unpack-prebuilt-apex.sh": nil,
+4 −0
Original line number Diff line number Diff line
@@ -423,6 +423,10 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
					fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
						app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
				}
				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())
				}
			},
		},
	}}
+3 −0
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ type AndroidApp struct {
	overriddenManifestPackageName string

	android.ApexBundleDepsInfo

	javaApiUsedByOutputFile android.ModuleOutPath
}

func (a *AndroidApp) IsInstallable() bool {
@@ -275,6 +277,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	a.checkAppSdkVersions(ctx)
	a.generateAndroidBuildActions(ctx)
	a.generateJavaUsedByApex(ctx)
}

func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
+12 −0
Original line number Diff line number Diff line
@@ -254,6 +254,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 {
	return filepath.Join("lib", target.Arch.Abi[0])
}
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers(
		"build/soong/java/lint_defaults.txt": nil,
		// Needed for apps that do not provide their own.
		"build/make/target/product/security": nil,
		// Required to generate Java used-by API coverage
		"build/soong/scripts/gen_java_usedby_apex.sh": nil,
	}.AddToFixture(),
)