diff options
author | 2020-11-10 12:27:45 -0800 | |
---|---|---|
committer | 2020-12-11 19:54:16 +0000 | |
commit | c20dc8533e0ed41ba3d708e85515980fff04c9f2 (patch) | |
tree | fe6fb7c2513fbc2cdb63ac3c6adaef93c9ab533a /java/aar.go | |
parent | d3b30670f2846ebe0a84dfc6bf7bc8a8c38ed110 (diff) |
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
Diffstat (limited to 'java/aar.go')
-rw-r--r-- | java/aar.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/java/aar.go b/java/aar.go index 3b6b34e27..3750f72ba 100644 --- a/java/aar.go +++ b/java/aar.go @@ -17,6 +17,7 @@ package java import ( "fmt" "path/filepath" + "strconv" "strings" "android/soong/android" @@ -192,22 +193,31 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, rroDirs = append(rroDirs, resRRODirs...) } - var assetFiles android.Paths - for _, dir := range assetDirs { - assetFiles = append(assetFiles, androidResourceGlob(ctx, dir)...) + var assetDeps android.Paths + for i, dir := range assetDirs { + // 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() if a.noticeFile.Valid() { 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()) linkDeps = append(linkDeps, manifestPath) linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A ")) - linkDeps = append(linkDeps, assetFiles...) + linkDeps = append(linkDeps, assetDeps...) // SDK version flags minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersionString(ctx) |