diff options
author | Justin Yun <justinyun@google.com> | 2023-04-11 18:20:07 +0900 |
---|---|---|
committer | Justin Yun <justinyun@google.com> | 2023-04-26 11:27:34 +0900 |
commit | 2b6b7af8f4c760860331352fedd10029b3a79928 (patch) | |
tree | 3533419cc315b8c96365def39c502d534de3ba82 /snapshot/snapshot.go | |
parent | 07d931980b4607ada6462c3794e90476f09dd81c (diff) | |
download | soong-2b6b7af8f4c760860331352fedd10029b3a79928.tar.gz |
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
Merged-In: I0c0427bb66f2c1fca322d5554aa66220a3b62fb3
Change-Id: I0c0427bb66f2c1fca322d5554aa66220a3b62fb3
(cherry picked from commit 1db9748805147a69792b2a1a556689253c5b82f6)
Diffstat (limited to 'snapshot/snapshot.go')
-rw-r--r-- | snapshot/snapshot.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index 206ecc947..c95a53774 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -26,6 +26,10 @@ import ( var pctx = android.NewPackageContext("android/soong/snapshot") +func init() { + pctx.Import("android/soong/android") +} + type SnapshotSingleton struct { // Name, e.g., "vendor", "recovery", "ramdisk". name string @@ -48,8 +52,18 @@ type SnapshotSingleton struct { Fake bool } +// The output files to be included in the snapshot. +type SnapshotPaths struct { + // All files to be included in the snapshot + OutputFiles android.Paths + + // Notice files of the snapshot output files + NoticeFiles android.Paths +} + // Interface of function to capture snapshot from each module -type GenerateSnapshotAction func(snapshot SnapshotSingleton, ctx android.SingletonContext, snapshotArchDir string) android.Paths +// Returns snapshot ouputs and notice files. +type GenerateSnapshotAction func(snapshot SnapshotSingleton, ctx android.SingletonContext, snapshotArchDir string) SnapshotPaths var snapshotActionList []GenerateSnapshotAction @@ -74,9 +88,19 @@ func (c *SnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) { snapshotDir = filepath.Join("fake", snapshotDir) } snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch()) + noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES") + installedNotices := make(map[string]bool) for _, f := range snapshotActionList { - snapshotOutputs = append(snapshotOutputs, f(*c, ctx, snapshotArchDir)...) + snapshotPaths := f(*c, ctx, snapshotArchDir) + snapshotOutputs = append(snapshotOutputs, snapshotPaths.OutputFiles...) + for _, notice := range snapshotPaths.NoticeFiles { + if _, ok := installedNotices[notice.String()]; !ok { + installedNotices[notice.String()] = true + snapshotOutputs = append(snapshotOutputs, CopyFileRule( + pctx, ctx, notice, filepath.Join(noticeDir, notice.String()))) + } + } } // All artifacts are ready. Sort them to normalize ninja and then zip. |