Loading android/module.go +3 −0 Original line number Diff line number Diff line Loading @@ -3163,6 +3163,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e symlinkTarget: "", executable: executable, effectiveLicenseFiles: &licenseFiles, partition: fullInstallPath.partition, } m.packagingSpecs = append(m.packagingSpecs, spec) return spec Loading Loading @@ -3280,6 +3281,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src srcPath: nil, symlinkTarget: relPath, executable: false, partition: fullInstallPath.partition, }) return fullInstallPath Loading Loading @@ -3320,6 +3322,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str srcPath: nil, symlinkTarget: absPath, executable: false, partition: fullInstallPath.partition, }) return fullInstallPath Loading android/packaging.go +16 −8 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ type PackagingSpec struct { executable bool effectiveLicenseFiles *Paths partition string } // Get file name of installed package Loading Loading @@ -67,6 +69,10 @@ func (p *PackagingSpec) EffectiveLicenseFiles() Paths { return *p.effectiveLicenseFiles } func (p *PackagingSpec) Partition() string { return p.partition } type PackageModule interface { Module packagingBase() *PackagingBase Loading @@ -76,11 +82,14 @@ type PackageModule interface { // be copied to a zip in CopyDepsToZip, `depTag` should implement PackagingItem marker interface. AddDeps(ctx BottomUpMutatorContext, depTag blueprint.DependencyTag) // GatherPackagingSpecs gathers PackagingSpecs of transitive dependencies. GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec // CopyDepsToZip zips the built artifacts of the dependencies into the given zip file and // returns zip entries in it. This is expected to be called in GenerateAndroidBuildActions, // followed by a build rule that unzips it and creates the final output (img, zip, tar.gz, // etc.) from the extracted files CopyDepsToZip(ctx ModuleContext, zipOut WritablePath) []string CopyDepsToZip(ctx ModuleContext, specs map[string]PackagingSpec, zipOut WritablePath) []string } // PackagingBase provides basic functionality for packaging dependencies. A module is expected to Loading Loading @@ -211,7 +220,7 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep } } // Returns transitive PackagingSpecs from deps // See PackageModule.GatherPackagingSpecs func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec { m := make(map[string]PackagingSpec) ctx.VisitDirectDeps(func(child Module) { Loading @@ -229,10 +238,10 @@ func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]Packa // CopySpecsToDir is a helper that will add commands to the rule builder to copy the PackagingSpec // entries into the specified directory. func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, m map[string]PackagingSpec, dir ModuleOutPath) (entries []string) { func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir ModuleOutPath) (entries []string) { seenDir := make(map[string]bool) for _, k := range SortedStringKeys(m) { ps := m[k] for _, k := range SortedStringKeys(specs) { ps := specs[k] destPath := dir.Join(ctx, ps.relPathInPackage).String() destDir := filepath.Dir(destPath) entries = append(entries, ps.relPathInPackage) Loading @@ -254,14 +263,13 @@ func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, } // See PackageModule.CopyDepsToZip func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, zipOut WritablePath) (entries []string) { m := p.GatherPackagingSpecs(ctx) func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, specs map[string]PackagingSpec, zipOut WritablePath) (entries []string) { builder := NewRuleBuilder(pctx, ctx) dir := PathForModuleOut(ctx, ".zip") builder.Command().Text("rm").Flag("-rf").Text(dir.String()) builder.Command().Text("mkdir").Flag("-p").Text(dir.String()) entries = p.CopySpecsToDir(ctx, builder, m, dir) entries = p.CopySpecsToDir(ctx, builder, specs, dir) builder.Command(). BuiltTool("soong_zip"). Loading android/packaging_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ func (m *packageTestModule) DepsMutator(ctx BottomUpMutatorContext) { func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) { zipFile := PathForModuleOut(ctx, "myzip.zip") m.entries = m.CopyDepsToZip(ctx, zipFile) m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile) } func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) { Loading filesystem/filesystem.go +2 −2 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ func (f *filesystem) buildRootZip(ctx android.ModuleContext) android.OutputPath func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath { depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) depsBase := proptools.StringDefault(f.properties.Base_dir, ".") Loading Loading @@ -345,7 +345,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) } depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) depsBase := proptools.StringDefault(f.properties.Base_dir, ".") Loading snapshot/host_snapshot.go +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ func (f *hostSnapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) { f.installDir = android.PathForModuleInstall(ctx) f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) builder.Command(). Loading Loading
android/module.go +3 −0 Original line number Diff line number Diff line Loading @@ -3163,6 +3163,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e symlinkTarget: "", executable: executable, effectiveLicenseFiles: &licenseFiles, partition: fullInstallPath.partition, } m.packagingSpecs = append(m.packagingSpecs, spec) return spec Loading Loading @@ -3280,6 +3281,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src srcPath: nil, symlinkTarget: relPath, executable: false, partition: fullInstallPath.partition, }) return fullInstallPath Loading Loading @@ -3320,6 +3322,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str srcPath: nil, symlinkTarget: absPath, executable: false, partition: fullInstallPath.partition, }) return fullInstallPath Loading
android/packaging.go +16 −8 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ type PackagingSpec struct { executable bool effectiveLicenseFiles *Paths partition string } // Get file name of installed package Loading Loading @@ -67,6 +69,10 @@ func (p *PackagingSpec) EffectiveLicenseFiles() Paths { return *p.effectiveLicenseFiles } func (p *PackagingSpec) Partition() string { return p.partition } type PackageModule interface { Module packagingBase() *PackagingBase Loading @@ -76,11 +82,14 @@ type PackageModule interface { // be copied to a zip in CopyDepsToZip, `depTag` should implement PackagingItem marker interface. AddDeps(ctx BottomUpMutatorContext, depTag blueprint.DependencyTag) // GatherPackagingSpecs gathers PackagingSpecs of transitive dependencies. GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec // CopyDepsToZip zips the built artifacts of the dependencies into the given zip file and // returns zip entries in it. This is expected to be called in GenerateAndroidBuildActions, // followed by a build rule that unzips it and creates the final output (img, zip, tar.gz, // etc.) from the extracted files CopyDepsToZip(ctx ModuleContext, zipOut WritablePath) []string CopyDepsToZip(ctx ModuleContext, specs map[string]PackagingSpec, zipOut WritablePath) []string } // PackagingBase provides basic functionality for packaging dependencies. A module is expected to Loading Loading @@ -211,7 +220,7 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep } } // Returns transitive PackagingSpecs from deps // See PackageModule.GatherPackagingSpecs func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]PackagingSpec { m := make(map[string]PackagingSpec) ctx.VisitDirectDeps(func(child Module) { Loading @@ -229,10 +238,10 @@ func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]Packa // CopySpecsToDir is a helper that will add commands to the rule builder to copy the PackagingSpec // entries into the specified directory. func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, m map[string]PackagingSpec, dir ModuleOutPath) (entries []string) { func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir ModuleOutPath) (entries []string) { seenDir := make(map[string]bool) for _, k := range SortedStringKeys(m) { ps := m[k] for _, k := range SortedStringKeys(specs) { ps := specs[k] destPath := dir.Join(ctx, ps.relPathInPackage).String() destDir := filepath.Dir(destPath) entries = append(entries, ps.relPathInPackage) Loading @@ -254,14 +263,13 @@ func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, } // See PackageModule.CopyDepsToZip func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, zipOut WritablePath) (entries []string) { m := p.GatherPackagingSpecs(ctx) func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, specs map[string]PackagingSpec, zipOut WritablePath) (entries []string) { builder := NewRuleBuilder(pctx, ctx) dir := PathForModuleOut(ctx, ".zip") builder.Command().Text("rm").Flag("-rf").Text(dir.String()) builder.Command().Text("mkdir").Flag("-p").Text(dir.String()) entries = p.CopySpecsToDir(ctx, builder, m, dir) entries = p.CopySpecsToDir(ctx, builder, specs, dir) builder.Command(). BuiltTool("soong_zip"). Loading
android/packaging_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ func (m *packageTestModule) DepsMutator(ctx BottomUpMutatorContext) { func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) { zipFile := PathForModuleOut(ctx, "myzip.zip") m.entries = m.CopyDepsToZip(ctx, zipFile) m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile) } func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) { Loading
filesystem/filesystem.go +2 −2 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ func (f *filesystem) buildRootZip(ctx android.ModuleContext) android.OutputPath func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath { depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) depsBase := proptools.StringDefault(f.properties.Base_dir, ".") Loading Loading @@ -345,7 +345,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) } depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) depsBase := proptools.StringDefault(f.properties.Base_dir, ".") Loading
snapshot/host_snapshot.go +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ func (f *hostSnapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) { f.installDir = android.PathForModuleInstall(ctx) f.CopyDepsToZip(ctx, depsZipFile) f.CopyDepsToZip(ctx, f.GatherPackagingSpecs(ctx), depsZipFile) builder := android.NewRuleBuilder(pctx, ctx) builder.Command(). Loading