Add some comments for VNDK / vendor snapshots

Also some files are refactored:

- snapshot_prebuilt.go is separated from vendor_snapshot.go. Now
vendor_snapshot.go contains snapshot generation codes, while
snapshot_prebuilt.go contains module definition codes.

- Some helper functions are moved from snapshot_utils.go to util.go.

- Some ambiguous names of types and functions are renamed.

We still can add more detailed comments about the snapshots. They are to
be uploaded in follow-up changes, to avoid making this change too big.

Bug: 173474311
Test: generate vndk and vendor snapshot
Change-Id: I18fa837ccdf44a042b7a78e5c3df25fd2de96d95
This commit is contained in:
Inseob Kim
2020-12-02 13:14:28 +09:00
parent 13850821b2
commit de5744a199
7 changed files with 997 additions and 854 deletions

View File

@@ -125,3 +125,52 @@ func makeSymlinkCmd(linkDirOnDevice string, linkName string, target string) stri
return "mkdir -p " + dir + " && " +
"ln -sf " + target + " " + filepath.Join(dir, linkName)
}
func copyFileRule(ctx android.SingletonContext, path android.Path, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: path,
Output: outPath,
Description: "copy " + path.String() + " -> " + out,
Args: map[string]string{
"cpFlags": "-f -L",
},
})
return outPath
}
func combineNoticesRule(ctx android.SingletonContext, paths android.Paths, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
ctx.Build(pctx, android.BuildParams{
Rule: android.Cat,
Inputs: paths,
Output: outPath,
Description: "combine notices for " + out,
})
return outPath
}
func writeStringToFileRule(ctx android.SingletonContext, content, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
android.WriteFileRule(ctx, outPath, content)
return outPath
}
// Dump a map to a list file as:
//
// {key1} {value1}
// {key2} {value2}
// ...
func installMapListFileRule(ctx android.SingletonContext, m map[string]string, path string) android.OutputPath {
var txtBuilder strings.Builder
for idx, k := range android.SortedStringKeys(m) {
if idx > 0 {
txtBuilder.WriteString("\n")
}
txtBuilder.WriteString(k)
txtBuilder.WriteString(" ")
txtBuilder.WriteString(m[k])
}
return writeStringToFileRule(ctx, txtBuilder.String(), path)
}