Build notice files from license metadata. am: 43c2dcaef6 am: 6f7de5b1a9 am: cbcf8d9b05

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2047886

Change-Id: I6a76eee6321538b70c331a2e2a9cb1e5b644ac04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Bob Badour
2022-03-31 23:13:51 +00:00
committed by Automerger Merge Worker
10 changed files with 28 additions and 638 deletions

View File

@@ -396,10 +396,6 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
}
a.writeRequiredModules(w, moduleNames)
if a.mergedNotices.Merged.Valid() {
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
}
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
if apexType == imageApex {

View File

@@ -414,8 +414,8 @@ type apexBundle struct {
// Processed file_contexts files
fileContexts android.WritablePath
// Struct holding the merged notice file paths in different formats
mergedNotices android.NoticeOutputs
// Path to notice file in html.gz format.
htmlGzNotice android.WritablePath
// The built APEX file. This is the main product.
// Could be .apex or .capex
@@ -487,11 +487,10 @@ const (
// for each of the files in case when the APEX is flattened.
type apexFile struct {
// buildFile is put in the installDir inside the APEX.
builtFile android.Path
noticeFiles android.Paths
installDir string
customStem string
symlinks []string // additional symlinks
builtFile android.Path
installDir string
customStem string
symlinks []string // additional symlinks
// Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk
// module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex
@@ -528,7 +527,6 @@ func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidM
module: module,
}
if module != nil {
ret.noticeFiles = module.NoticeFiles()
ret.moduleDir = ctx.OtherModuleDir(module)
ret.requiredModuleNames = module.RequiredModuleNames()
ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()

View File

@@ -591,15 +591,6 @@ func TestBasicApex(t *testing.T) {
t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds)
}
mergeNoticesRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("mergeNoticesRule")
noticeInputs := mergeNoticesRule.Inputs.Strings()
if len(noticeInputs) != 3 {
t.Errorf("number of input notice files: expected = 3, actual = %q", len(noticeInputs))
}
ensureListContains(t, noticeInputs, "NOTICE")
ensureListContains(t, noticeInputs, "custom_notice")
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex")
ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib")

View File

@@ -305,32 +305,6 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output
return output.OutputPath
}
// buildNoticeFiles creates a buile rule for aggregating notice files from the modules that
// contributes to this APEX. The notice files are merged into a big notice file.
func (a *apexBundle) buildNoticeFiles(ctx android.ModuleContext, apexFileName string) android.NoticeOutputs {
var noticeFiles android.Paths
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
if externalDep {
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
}
noticeFiles = append(noticeFiles, to.NoticeFiles()...)
return true
})
// TODO(jiyong): why do we need this? WalkPayloadDeps should have already covered this.
for _, fi := range a.filesInfo {
noticeFiles = append(noticeFiles, fi.noticeFiles...)
}
if len(noticeFiles) == 0 {
return android.NoticeOutputs{}
}
return android.BuildNoticeOutput(ctx, a.installDir, apexFileName, android.SortedUniquePaths(noticeFiles))
}
// buildInstalledFilesFile creates a build rule for the installed-files.txt file where the list of
// files included in this APEX is shown. The text file is dist'ed so that people can see what's
// included in the APEX without actually downloading and extracting it.
@@ -642,12 +616,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
optFlags = append(optFlags, "--logging_parent ", a.overridableProperties.Logging_parent)
}
a.mergedNotices = a.buildNoticeFiles(ctx, a.Name()+suffix)
if a.mergedNotices.HtmlGzOutput.Valid() {
// If there's a NOTICE file, embed it as an asset file in the APEX.
implicitInputs = append(implicitInputs, a.mergedNotices.HtmlGzOutput.Path())
optFlags = append(optFlags, "--assets_dir "+filepath.Dir(a.mergedNotices.HtmlGzOutput.String()))
}
// Create a NOTICE file, and embed it as an asset file in the APEX.
a.htmlGzNotice = android.PathForModuleOut(ctx, "NOTICE/NOTICES.html.gz")
android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, a.htmlGzNotice)
implicitInputs = append(implicitInputs, a.htmlGzNotice)
optFlags = append(optFlags, "--assets_dir "+filepath.Dir(a.htmlGzNotice.String()))
if (moduleMinSdkVersion.GreaterThan(android.SdkVersion_Android10) && !a.shouldGenerateHashtree()) && !compressionEnabled {
// Apexes which are supposed to be installed in builtin dirs(/system, etc)