Include license information for vendor and host snapshots
In addition to the license text files, include license kinds
information to json file. Also, use the original paths of license
text files that are copied to NOTICE_FILES directory.
This will be used when generating snapshots from the snapshot build.
Bug: 271539873
Test: m vendor-snapshot
Change-Id: I0c0427bb66f2c1fca322d5554aa66220a3b62fb3
diff --git a/snapshot/host_snapshot.go b/snapshot/host_snapshot.go
index 9793218..edcc163 100644
--- a/snapshot/host_snapshot.go
+++ b/snapshot/host_snapshot.go
@@ -96,6 +96,7 @@
var jsonData []SnapshotJsonFlags
var metaPaths android.Paths
+ installedNotices := make(map[string]bool)
metaZipFile := android.PathForModuleOut(ctx, fileName).OutputPath
// Create JSON file based on the direct dependencies
@@ -104,12 +105,14 @@
if desc != nil {
jsonData = append(jsonData, *desc)
}
- if len(dep.EffectiveLicenseFiles()) > 0 {
- noticeFile := android.PathForModuleOut(ctx, "NOTICE_FILES", dep.Name()+".txt").OutputPath
- android.CatFileRule(ctx, dep.EffectiveLicenseFiles(), noticeFile)
- metaPaths = append(metaPaths, noticeFile)
+ for _, notice := range dep.EffectiveLicenseFiles() {
+ if _, ok := installedNotices[notice.String()]; !ok {
+ installedNotices[notice.String()] = true
+ noticeOut := android.PathForModuleOut(ctx, "NOTICE_FILES", notice.String()).OutputPath
+ CopyFileToOutputPathRule(pctx, ctx, notice, noticeOut)
+ metaPaths = append(metaPaths, noticeOut)
+ }
}
-
})
// Sort notice paths and json data for repeatble build
sort.Slice(jsonData, func(i, j int) bool {
@@ -220,8 +223,7 @@
}
if path.Valid() && path.String() != "" {
- return &SnapshotJsonFlags{
- ModuleName: m.Name(),
+ props := &SnapshotJsonFlags{
ModuleStemName: moduleStem,
Filename: path.String(),
Required: append(m.HostRequiredModuleNames(), m.RequiredModuleNames()...),
@@ -229,6 +231,8 @@
RustProcMacro: procMacro,
CrateName: crateName,
}
+ props.InitBaseSnapshotProps(m)
+ return props
}
return nil
}