Merge "Extract zip_deps preparation work as a script" into main

This commit is contained in:
Treehugger Robot
2024-01-03 05:24:04 +00:00
committed by Gerrit Code Review

View File

@@ -17,6 +17,7 @@ package android
import ( import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"strings"
"github.com/google/blueprint" "github.com/google/blueprint"
) )
@@ -240,6 +241,9 @@ func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]Packa
// entries into the specified directory. // entries into the specified directory.
func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir WritablePath) (entries []string) { func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir WritablePath) (entries []string) {
seenDir := make(map[string]bool) seenDir := make(map[string]bool)
preparerPath := PathForModuleOut(ctx, "preparer.sh")
cmd := builder.Command().Tool(preparerPath)
var sb strings.Builder
for _, k := range SortedKeys(specs) { for _, k := range SortedKeys(specs) {
ps := specs[k] ps := specs[k]
destPath := filepath.Join(dir.String(), ps.relPathInPackage) destPath := filepath.Join(dir.String(), ps.relPathInPackage)
@@ -247,18 +251,21 @@ func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder,
entries = append(entries, ps.relPathInPackage) entries = append(entries, ps.relPathInPackage)
if _, ok := seenDir[destDir]; !ok { if _, ok := seenDir[destDir]; !ok {
seenDir[destDir] = true seenDir[destDir] = true
builder.Command().Text("mkdir").Flag("-p").Text(destDir) sb.WriteString(fmt.Sprintf("mkdir -p %s\n", destDir))
} }
if ps.symlinkTarget == "" { if ps.symlinkTarget == "" {
builder.Command().Text("cp").Input(ps.srcPath).Text(destPath) cmd.Implicit(ps.srcPath)
sb.WriteString(fmt.Sprintf("cp %s %s\n", ps.srcPath, destPath))
} else { } else {
builder.Command().Text("ln").Flag("-sf").Text(ps.symlinkTarget).Text(destPath) sb.WriteString(fmt.Sprintf("ln -sf %s %s\n", ps.symlinkTarget, destPath))
} }
if ps.executable { if ps.executable {
builder.Command().Text("chmod").Flag("a+x").Text(destPath) sb.WriteString(fmt.Sprintf("chmod a+x %s\n", destPath))
} }
} }
WriteExecutableFileRuleVerbatim(ctx, preparerPath, sb.String())
return entries return entries
} }