Add dependency to list of asset files
We had a dependency on each file in the asset directories, but that wouldn't cause aapt2 to run if a file was removed. Add a dependency on a file that contains the list of files in the asset directories. Fixes: 172867096 Test: m CarrierConfig && rm packages/apps/CarrierConfig/assets/carrier_config_no_sim.xml && m CarrierConfig Change-Id: I35f3b85355fa890a3e95eaa6458a21466b6930e4
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
_ "github.com/google/blueprint/bootstrap"
|
"github.com/google/blueprint/bootstrap"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -200,3 +200,8 @@ func ContentFromFileRuleForTests(t *testing.T, params TestingBuildParams) string
|
|||||||
|
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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())
|
||||||
|
}
|
||||||
|
@@ -331,6 +331,8 @@ type BaseContext interface {
|
|||||||
type ModuleContext interface {
|
type ModuleContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
|
|
||||||
|
blueprintModuleContext() blueprint.ModuleContext
|
||||||
|
|
||||||
// Deprecated: use ModuleContext.Build instead.
|
// Deprecated: use ModuleContext.Build instead.
|
||||||
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
||||||
|
|
||||||
@@ -2544,6 +2546,10 @@ func (m *moduleContext) CheckbuildFile(srcPath Path) {
|
|||||||
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {
|
||||||
|
return m.bp
|
||||||
|
}
|
||||||
|
|
||||||
// SrcIsModule decodes module references in the format ":name" into the module name, or empty string if the input
|
// SrcIsModule decodes module references in the format ":name" into the module name, or empty string if the input
|
||||||
// was not a module reference.
|
// was not a module reference.
|
||||||
func SrcIsModule(s string) (module string) {
|
func SrcIsModule(s string) (module string) {
|
||||||
|
20
java/aar.go
20
java/aar.go
@@ -17,6 +17,7 @@ package java
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -192,22 +193,31 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext,
|
|||||||
rroDirs = append(rroDirs, resRRODirs...)
|
rroDirs = append(rroDirs, resRRODirs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
var assetFiles android.Paths
|
var assetDeps android.Paths
|
||||||
for _, dir := range assetDirs {
|
for i, dir := range assetDirs {
|
||||||
assetFiles = append(assetFiles, androidResourceGlob(ctx, dir)...)
|
// 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.
|
||||||
|
assetDeps = append(assetDeps, androidResourceGlob(ctx, dir)...)
|
||||||
|
|
||||||
|
// Add a dependency on a file that contains a list of all the files in 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.
|
||||||
|
assetFileListFile := android.PathForModuleOut(ctx, "asset_dir_globs", strconv.Itoa(i)+".glob")
|
||||||
|
androidResourceGlobList(ctx, dir, assetFileListFile)
|
||||||
|
assetDeps = append(assetDeps, assetFileListFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
assetDirStrings := assetDirs.Strings()
|
assetDirStrings := assetDirs.Strings()
|
||||||
if a.noticeFile.Valid() {
|
if a.noticeFile.Valid() {
|
||||||
assetDirStrings = append(assetDirStrings, filepath.Dir(a.noticeFile.Path().String()))
|
assetDirStrings = append(assetDirStrings, filepath.Dir(a.noticeFile.Path().String()))
|
||||||
assetFiles = append(assetFiles, a.noticeFile.Path())
|
assetDeps = append(assetDeps, a.noticeFile.Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
linkFlags = append(linkFlags, "--manifest "+manifestPath.String())
|
linkFlags = append(linkFlags, "--manifest "+manifestPath.String())
|
||||||
linkDeps = append(linkDeps, manifestPath)
|
linkDeps = append(linkDeps, manifestPath)
|
||||||
|
|
||||||
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A "))
|
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A "))
|
||||||
linkDeps = append(linkDeps, assetFiles...)
|
linkDeps = append(linkDeps, assetDeps...)
|
||||||
|
|
||||||
// SDK version flags
|
// SDK version flags
|
||||||
minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersionString(ctx)
|
minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersionString(ctx)
|
||||||
|
@@ -38,10 +38,21 @@ var androidResourceIgnoreFilenames = []string{
|
|||||||
"*~",
|
"*~",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// androidResourceGlob returns the list of files in the given directory, using the standard
|
||||||
|
// exclusion patterns for Android resources.
|
||||||
func androidResourceGlob(ctx android.ModuleContext, dir android.Path) android.Paths {
|
func androidResourceGlob(ctx android.ModuleContext, dir android.Path) android.Paths {
|
||||||
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