Fix host snapshot dependency cycle

Test: m host-snapshot
Bug: 216351382
Change-Id: Iaa8b7e8373fab0db931cbe7a6328c2adca27d95b
This commit is contained in:
Rob Seymour 2022-01-31 20:33:52 +00:00
parent 7afffe6af0
commit 0800ef7007

View file

@ -58,7 +58,7 @@ type hostSnapshot struct {
android.ModuleBase android.ModuleBase
android.PackagingBase android.PackagingBase
zipFile android.OptionalPath outputFile android.OutputPath
installDir android.InstallPath installDir android.InstallPath
} }
@ -141,7 +141,7 @@ func (f *hostSnapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Create a zip file for the binaries, and a zip of the meta data, then merge zips // Create a zip file for the binaries, and a zip of the meta data, then merge zips
depsZipFile := android.PathForModuleOut(ctx, f.Name()+"_deps.zip").OutputPath depsZipFile := android.PathForModuleOut(ctx, f.Name()+"_deps.zip").OutputPath
modsZipFile := android.PathForModuleOut(ctx, f.Name()+"_mods.zip").OutputPath modsZipFile := android.PathForModuleOut(ctx, f.Name()+"_mods.zip").OutputPath
outputFile := android.PathForModuleOut(ctx, f.installFileName()).OutputPath f.outputFile = android.PathForModuleOut(ctx, f.installFileName()).OutputPath
f.installDir = android.PathForModuleInstall(ctx) f.installDir = android.PathForModuleInstall(ctx)
@ -158,26 +158,21 @@ func (f *hostSnapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
builder.Command(). builder.Command().
BuiltTool("merge_zips"). BuiltTool("merge_zips").
Output(outputFile). Output(f.outputFile).
Input(metaZipFile). Input(metaZipFile).
Input(modsZipFile) Input(modsZipFile)
builder.Build("manifest", fmt.Sprintf("Adding manifest %s", f.installFileName())) builder.Build("manifest", fmt.Sprintf("Adding manifest %s", f.installFileName()))
zip := ctx.InstallFile(f.installDir, f.installFileName(), outputFile) ctx.InstallFile(f.installDir, f.installFileName(), f.outputFile)
f.zipFile = android.OptionalPathForPath(zip)
} }
// Implements android.AndroidMkEntriesProvider // Implements android.AndroidMkEntriesProvider
func (f *hostSnapshot) AndroidMkEntries() []android.AndroidMkEntries { func (f *hostSnapshot) AndroidMkEntries() []android.AndroidMkEntries {
if !f.zipFile.Valid() {
return []android.AndroidMkEntries{}
}
return []android.AndroidMkEntries{android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC", Class: "ETC",
OutputFile: f.zipFile, OutputFile: android.OptionalPathForPath(f.outputFile),
DistFiles: android.MakeDefaultDistFiles(f.zipFile.Path()), DistFiles: android.MakeDefaultDistFiles(f.outputFile),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", f.installDir.String()) entries.SetString("LOCAL_MODULE_PATH", f.installDir.String())