Remove asset dir glob files
I'm rewriting how globs work in soong to make them compatible with hash-based ninja implementations. As part of this, I'm removing this unnecessary usage of globs to make them simpler. In this case, since we're already globbing the directory at analysis time and causing soong to rerun, we can ensure the aapt2 action also reruns by putting a hash of the glob results onto the command line. Bug: 364749114 Test: m framework-res, touch frameworks/base/core/res/assets/test1.txt, m framework-res rebuilt framework-res.apk, rm frameworks/base/core/res/assets/test1.txt, m framework-res rebuilt framework-res.apk again Change-Id: I4f666367a9a0fd0dfa42dc51ef3a788a02b41747
This commit is contained in:
@@ -16,7 +16,6 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/bootstrap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -120,8 +119,3 @@ func init() {
|
|||||||
return ctx.Config().RBEWrapper()
|
return ctx.Config().RBEWrapper()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobToListFileRule creates a rule that writes a list of files matching a pattern to a file.
|
|
||||||
func GlobToListFileRule(ctx ModuleContext, pattern string, excludes []string, file WritablePath) {
|
|
||||||
bootstrap.GlobFile(ctx.blueprintModuleContext(), pattern, excludes, file.String())
|
|
||||||
}
|
|
||||||
|
17
java/aar.go
17
java/aar.go
@@ -15,10 +15,10 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -236,18 +236,20 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte
|
|||||||
rroDirs = append(rroDirs, resRRODirs...)
|
rroDirs = append(rroDirs, resRRODirs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assetDirsHasher := sha256.New()
|
||||||
var assetDeps android.Paths
|
var assetDeps android.Paths
|
||||||
for i, dir := range assetDirs {
|
for _, dir := range assetDirs {
|
||||||
// Add a dependency on every file in the asset directory. This ensures the aapt2
|
// Add a dependency on every file in the asset directory. This ensures the aapt2
|
||||||
// rule will be rerun if one of the files in the asset directory is modified.
|
// rule will be rerun if one of the files in the asset directory is modified.
|
||||||
assetDeps = append(assetDeps, androidResourceGlob(ctx, dir)...)
|
dirContents := androidResourceGlob(ctx, dir)
|
||||||
|
assetDeps = append(assetDeps, dirContents...)
|
||||||
|
|
||||||
// Add a dependency on a file that contains a list of all the files in the asset directory.
|
// Add a hash of all the files in the asset directory to the command line.
|
||||||
// This ensures the aapt2 rule will be run if a file is removed from the asset directory,
|
// This ensures the aapt2 rule will be run if a file is removed from the asset directory,
|
||||||
// or a file is added whose timestamp is older than the output of aapt2.
|
// or a file is added whose timestamp is older than the output of aapt2.
|
||||||
assetFileListFile := android.PathForModuleOut(ctx, "asset_dir_globs", strconv.Itoa(i)+".glob")
|
for _, path := range dirContents.Strings() {
|
||||||
androidResourceGlobList(ctx, dir, assetFileListFile)
|
assetDirsHasher.Write([]byte(path))
|
||||||
assetDeps = append(assetDeps, assetFileListFile)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assetDirStrings := assetDirs.Strings()
|
assetDirStrings := assetDirs.Strings()
|
||||||
@@ -282,6 +284,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte
|
|||||||
linkDeps = append(linkDeps, manifestPath)
|
linkDeps = append(linkDeps, manifestPath)
|
||||||
|
|
||||||
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A "))
|
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A "))
|
||||||
|
linkFlags = append(linkFlags, fmt.Sprintf("$$(: %x)", assetDirsHasher.Sum(nil)))
|
||||||
linkDeps = append(linkDeps, assetDeps...)
|
linkDeps = append(linkDeps, assetDeps...)
|
||||||
|
|
||||||
// Returns the effective version for {min|target}_sdk_version
|
// Returns the effective version for {min|target}_sdk_version
|
||||||
|
@@ -39,15 +39,6 @@ func androidResourceGlob(ctx android.EarlyModuleContext, dir android.Path) andro
|
|||||||
return ctx.GlobFiles(filepath.Join(dir.String(), "**/*"), androidResourceIgnoreFilenames)
|
return ctx.GlobFiles(filepath.Join(dir.String(), "**/*"), androidResourceIgnoreFilenames)
|
||||||
}
|
}
|
||||||
|
|
||||||
// androidResourceGlobList creates a rule to write the list of files in the given directory, using
|
|
||||||
// the standard exclusion patterns for Android resources, to the given output file.
|
|
||||||
func androidResourceGlobList(ctx android.ModuleContext, dir android.Path,
|
|
||||||
fileListFile android.WritablePath) {
|
|
||||||
|
|
||||||
android.GlobToListFileRule(ctx, filepath.Join(dir.String(), "**/*"),
|
|
||||||
androidResourceIgnoreFilenames, fileListFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
type overlayType int
|
type overlayType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user