diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-12 13:49:36 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-12 13:49:36 +0000 |
commit | d1fd06f1f308844f33ec36edad0f89db9fa3bf2d (patch) | |
tree | 2c5e59cc5ae051d5af7ad536482ae11a497b9f2b | |
parent | 6f1b69ce41b6208b648135273944d1a5f6c52d27 (diff) | |
parent | e42d92f4c1eff825fe57846c2177e108794584b1 (diff) | |
download | soong-android12-mainline-wifi-release.tar.gz |
Snap for 8441503 from e42d92f4c1eff825fe57846c2177e108794584b1 to mainline-wifi-releaseandroid-mainline-12.0.0_r126aml_wif_311811030android12-mainline-wifi-release
Change-Id: Ic084c21c50a677379264938a7ac668fda31282e2
-rw-r--r-- | apex/testing.go | 1 | ||||
-rw-r--r-- | java/androidmk.go | 4 | ||||
-rwxr-xr-x | java/app.go | 3 | ||||
-rw-r--r-- | java/app_builder.go | 12 | ||||
-rw-r--r-- | java/testing.go | 2 | ||||
-rw-r--r-- | sdk/testing.go | 23 | ||||
-rw-r--r-- | sdk/update.go | 7 |
7 files changed, 49 insertions, 3 deletions
diff --git a/apex/testing.go b/apex/testing.go index 337c86210..69bd73e5d 100644 --- a/apex/testing.go +++ b/apex/testing.go @@ -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, diff --git a/java/androidmk.go b/java/androidmk.go index 04357e066..43214e586 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -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()) + } }, }, }} diff --git a/java/app.go b/java/app.go index 06967690b..cdbea2e42 100755 --- a/java/app.go +++ b/java/app.go @@ -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) { diff --git a/java/app_builder.go b/java/app_builder.go index 4a18dcada..bafc98054 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -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]) } diff --git a/java/testing.go b/java/testing.go index d5c464dd8..243e5e849 100644 --- a/java/testing.go +++ b/java/testing.go @@ -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(), ) diff --git a/sdk/testing.go b/sdk/testing.go index 294f1a57d..062f2000e 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -25,6 +25,8 @@ import ( "android/soong/cc" "android/soong/genrule" "android/soong/java" + + "github.com/google/blueprint/proptools" ) // Prepare for running an sdk test with an apex. @@ -81,6 +83,11 @@ var prepareForSdkTest = android.GroupFixturePreparers( } }), + // Add a build number file. + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildNumberFile = proptools.StringPtr(BUILD_NUMBER_FILE) + }), + // Make sure that every test provides all the source files. android.PrepareForTestDisallowNonExistentPaths, android.MockFS{ @@ -143,6 +150,8 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) copyRules := &strings.Builder{} otherCopyRules := &strings.Builder{} snapshotDirPrefix := sdk.builderForTests.snapshotDir.String() + "/" + + seenBuildNumberFile := false for _, bp := range buildParams { switch bp.Rule.String() { case android.Cp.String(): @@ -152,8 +161,14 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) src := android.NormalizePathForTesting(bp.Input) // We differentiate between copy rules for the snapshot, and copy rules for the install file. if strings.HasPrefix(output.String(), snapshotDirPrefix) { - // Get source relative to build directory. - _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest) + // Don't include the build-number.txt file in the copy rules as that would break lots of + // tests, just verify that it is copied here as it should appear in every snapshot. + if output.Base() == BUILD_NUMBER_FILE { + seenBuildNumberFile = true + } else { + // Get source relative to build directory. + _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest) + } info.snapshotContents = append(info.snapshotContents, dest) } else { _, _ = fmt.Fprintf(otherCopyRules, "%s -> %s\n", src, dest) @@ -189,6 +204,10 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) } } + if !seenBuildNumberFile { + panic(fmt.Sprintf("Every snapshot must include the %s file", BUILD_NUMBER_FILE)) + } + info.copyRules = copyRules.String() info.otherCopyRules = otherCopyRules.String() diff --git a/sdk/update.go b/sdk/update.go index d9c57c375..a3d94ed86 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -242,6 +242,10 @@ func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAwa return append(variants, newVariant) } +// BUILD_NUMBER_FILE is the name of the file in the snapshot zip that will contain the number of +// the build from which the snapshot was produced. +const BUILD_NUMBER_FILE = "snapshot-creation-build-number.txt" + // SDK directory structure // <sdk_root>/ // Android.bp : definition of a 'sdk' module is here. This is a hand-made one. @@ -432,6 +436,9 @@ be unnecessary as every module in the sdk already has its own licenses property. bp.build(pctx, ctx, nil) + // Copy the build number file into the snapshot. + builder.CopyToSnapshot(ctx.Config().BuildNumberFile(ctx), BUILD_NUMBER_FILE) + filesToZip := builder.filesToZip // zip them all |