Allow excluding specific overlay sub-directories
This change allows PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS to refer to subdirectories of directories in PRODUCT_PACKAGE_OVERLAYS, e.g.: PRODUCT_PACKAGE_OVERLAYS := foo/overlay PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS := foo/overlay/packages/apps/HelloWorld Bug: 118823052 Test: m nothing (soong tests) Change-Id: Ic9f89c11d023ea1b4f6f2f6683d94c81aa7b8a1b
This commit is contained in:
@@ -44,10 +44,6 @@ func androidResourceGlob(ctx android.ModuleContext, dir android.Path) android.Pa
|
|||||||
type overlayGlobResult struct {
|
type overlayGlobResult struct {
|
||||||
dir string
|
dir string
|
||||||
paths android.DirectorySortedPaths
|
paths android.DirectorySortedPaths
|
||||||
|
|
||||||
// Set to true of the product has selected that values in this overlay should not be moved to
|
|
||||||
// Runtime Resource Overlay (RRO) packages.
|
|
||||||
excludeFromRRO bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const overlayDataKey = "overlayDataKey"
|
const overlayDataKey = "overlayDataKey"
|
||||||
@@ -69,10 +65,11 @@ func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) (res []glo
|
|||||||
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
|
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
|
||||||
if len(files) > 0 {
|
if len(files) > 0 {
|
||||||
overlayModuleDir := android.PathForSource(ctx, data.dir, dir.String())
|
overlayModuleDir := android.PathForSource(ctx, data.dir, dir.String())
|
||||||
|
|
||||||
// If enforce RRO is enabled for this module and this overlay is not in the
|
// If enforce RRO is enabled for this module and this overlay is not in the
|
||||||
// exclusion list, ignore the overlay. The list of ignored overlays will be
|
// exclusion list, ignore the overlay. The list of ignored overlays will be
|
||||||
// passed to Make to be turned into an RRO package.
|
// passed to Make to be turned into an RRO package.
|
||||||
if rroEnabled && !data.excludeFromRRO {
|
if rroEnabled && !ctx.Config().EnforceRROExcludedOverlay(overlayModuleDir.String()) {
|
||||||
rroDirs = append(rroDirs, overlayModuleDir)
|
rroDirs = append(rroDirs, overlayModuleDir)
|
||||||
} else {
|
} else {
|
||||||
res = append(res, globbedResourceDir{
|
res = append(res, globbedResourceDir{
|
||||||
@@ -102,10 +99,6 @@ func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
var result overlayGlobResult
|
var result overlayGlobResult
|
||||||
result.dir = overlay
|
result.dir = overlay
|
||||||
|
|
||||||
// Mark overlays that will not have Runtime Resource Overlays enforced on them
|
|
||||||
// based on the product config
|
|
||||||
result.excludeFromRRO = ctx.Config().EnforceRROExcludedOverlay(overlay)
|
|
||||||
|
|
||||||
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), androidResourceIgnoreFilenames)
|
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), androidResourceIgnoreFilenames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Errorf("failed to glob resource dir %q: %s", overlay, err.Error())
|
ctx.Errorf("failed to glob resource dir %q: %s", overlay, err.Error())
|
||||||
|
@@ -149,9 +149,13 @@ var testEnforceRROTests = []struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "enforce RRO on all",
|
name: "enforce RRO on all",
|
||||||
enforceRROTargets: []string{"*"},
|
enforceRROTargets: []string{"*"},
|
||||||
enforceRROExcludedOverlays: []string{"device/vendor/blah/static_overlay"},
|
enforceRROExcludedOverlays: []string{
|
||||||
|
// Excluding specific apps/res directories also allowed.
|
||||||
|
"device/vendor/blah/static_overlay/foo",
|
||||||
|
"device/vendor/blah/static_overlay/bar/res",
|
||||||
|
},
|
||||||
overlayFiles: map[string][]string{
|
overlayFiles: map[string][]string{
|
||||||
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
||||||
"bar": []string{"device/vendor/blah/static_overlay/bar/res/values/strings.xml"},
|
"bar": []string{"device/vendor/blah/static_overlay/bar/res/values/strings.xml"},
|
||||||
@@ -208,11 +212,12 @@ func TestEnforceRRO(t *testing.T) {
|
|||||||
|
|
||||||
getOverlays := func(moduleName string) ([]string, []string) {
|
getOverlays := func(moduleName string) ([]string, []string) {
|
||||||
module := ctx.ModuleForTests(moduleName, "android_common")
|
module := ctx.ModuleForTests(moduleName, "android_common")
|
||||||
overlayCompiledPaths := module.Output("aapt2/overlay.list").Inputs.Strings()
|
overlayFile := module.MaybeOutput("aapt2/overlay.list")
|
||||||
|
|
||||||
var overlayFiles []string
|
var overlayFiles []string
|
||||||
for _, o := range overlayCompiledPaths {
|
if overlayFile.Rule != nil {
|
||||||
overlayFiles = append(overlayFiles, module.Output(o).Inputs.Strings()...)
|
for _, o := range overlayFile.Inputs.Strings() {
|
||||||
|
overlayFiles = append(overlayFiles, module.Output(o).Inputs.Strings()...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rroDirs := module.Module().(*AndroidApp).rroDirs.Strings()
|
rroDirs := module.Module().(*AndroidApp).rroDirs.Strings()
|
||||||
|
Reference in New Issue
Block a user