diff options
author | 2022-04-01 02:05:36 +0000 | |
---|---|---|
committer | 2022-04-01 14:10:53 +0000 | |
commit | 77807b3c277723161a193aea2a9df1e464448c3d (patch) | |
tree | aa4308c05738ee38894901471f83e52c11746ba8 /java/app.go | |
parent | 2a5c090c31bf6152f9e5954273c06cd34a21092e (diff) |
Revert "Build notice files from license metadata."
This reverts commit 43c2dcaef609c4a268bfab6c95ed924af4ead6b1.
Reason for revert: suspect build break
Bug: 227682036
Test: TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true vendor/google/build/mainline_modules_bundles.sh -j97
Change-Id: Ibfb8b4fefc264f52f32ba661c269a9cd625d800a
Diffstat (limited to 'java/app.go')
-rwxr-xr-x | java/app.go | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/java/app.go b/java/app.go index 5b1daa412..8728df6d7 100755 --- a/java/app.go +++ b/java/app.go @@ -19,6 +19,7 @@ package java import ( "path/filepath" + "sort" "strings" "github.com/google/blueprint" @@ -163,6 +164,8 @@ type AndroidApp struct { additionalAaptFlags []string + noticeOutputs android.NoticeOutputs + overriddenManifestPackageName string android.ApexBundleDepsInfo @@ -520,6 +523,53 @@ func (a *AndroidApp) JNISymbolsInstalls(installPath string) android.RuleBuilderI return jniSymbols } +func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext) { + // Collect NOTICE files from all dependencies. + seenModules := make(map[android.Module]bool) + noticePathSet := make(map[android.Path]bool) + + ctx.WalkDeps(func(child android.Module, parent android.Module) bool { + // Have we already seen this? + if _, ok := seenModules[child]; ok { + return false + } + seenModules[child] = true + + // Skip host modules. + if child.Target().Os.Class == android.Host { + return false + } + + paths := child.(android.Module).NoticeFiles() + if len(paths) > 0 { + for _, path := range paths { + noticePathSet[path] = true + } + } + return true + }) + + // If the app has one, add it too. + if len(a.NoticeFiles()) > 0 { + for _, path := range a.NoticeFiles() { + noticePathSet[path] = true + } + } + + if len(noticePathSet) == 0 { + return + } + var noticePaths []android.Path + for path := range noticePathSet { + noticePaths = append(noticePaths, path) + } + sort.Slice(noticePaths, func(i, j int) bool { + return noticePaths[i].String() < noticePaths[j].String() + }) + + a.noticeOutputs = android.BuildNoticeOutput(ctx, a.installDir, a.installApkName+".apk", noticePaths) +} + // Reads and prepends a main cert from the default cert dir if it hasn't been set already, i.e. it // isn't a cert module reference. Also checks and enforces system cert restriction if applicable. func processMainCert(m android.ModuleBase, certPropValue string, certificates []Certificate, ctx android.ModuleContext) []Certificate { @@ -586,10 +636,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { } a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir) - noticeFile := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz") - android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, noticeFile) + a.noticeBuildActions(ctx) if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") { - a.aapt.noticeFile = android.OptionalPathForPath(noticeFile) + a.aapt.noticeFile = a.noticeOutputs.HtmlGzOutput } a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) |