Separate device and product overlays
This change adds book-keeping of whether an overlay came from DEVICE_PACKAGE_OVERLAYS or PRODUCT_PACKAGE_OVERLAYS. This is later used when writing the output to soong_app_prebuilt.mk, to use either LOCAL_SOONG_[DEVICE|PRODUCT]_RRO_PACKAGES depending on the original source. This change is intended to be a noop on its own, but allows a follow-up make change to customize the location of the auto-generated RRO packages. Bug: 127758779 Test: verify noop on presubmit targets Change-Id: Ib24fe1d05be132c360dd6966f7c83968c9939f77
This commit is contained in:
@@ -211,9 +211,11 @@ func TestAndroidResources(t *testing.T) {
|
||||
"foo": {
|
||||
buildDir + "/.intermediates/lib2/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib3/android_common/package-res.apk",
|
||||
"foo/res/res/values/strings.xml",
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/foo/res/values/strings.xml",
|
||||
"product/vendor/blah/overlay/foo/res/values/strings.xml",
|
||||
},
|
||||
"bar": {
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml",
|
||||
@@ -244,6 +246,7 @@ func TestAndroidResources(t *testing.T) {
|
||||
"foo": {
|
||||
buildDir + "/.intermediates/lib2/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib3/android_common/package-res.apk",
|
||||
"foo/res/res/values/strings.xml",
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml",
|
||||
},
|
||||
@@ -260,9 +263,10 @@ func TestAndroidResources(t *testing.T) {
|
||||
|
||||
rroDirs: map[string][]string{
|
||||
"foo": {
|
||||
"device/vendor/blah/overlay/foo/res",
|
||||
"device:device/vendor/blah/overlay/foo/res",
|
||||
// Enforce RRO on "foo" could imply RRO on static dependencies, but for now it doesn't.
|
||||
// "device/vendor/blah/overlay/lib/res",
|
||||
"product:product/vendor/blah/overlay/foo/res",
|
||||
},
|
||||
"bar": nil,
|
||||
"lib": nil,
|
||||
@@ -286,6 +290,7 @@ func TestAndroidResources(t *testing.T) {
|
||||
"foo": {
|
||||
buildDir + "/.intermediates/lib2/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib/android_common/package-res.apk",
|
||||
buildDir + "/.intermediates/lib3/android_common/package-res.apk",
|
||||
"foo/res/res/values/strings.xml",
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml",
|
||||
},
|
||||
@@ -297,21 +302,27 @@ func TestAndroidResources(t *testing.T) {
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": {
|
||||
"device/vendor/blah/overlay/foo/res",
|
||||
"device/vendor/blah/overlay/lib/res",
|
||||
"device:device/vendor/blah/overlay/foo/res",
|
||||
"product:product/vendor/blah/overlay/foo/res",
|
||||
// Lib dep comes after the direct deps
|
||||
"device:device/vendor/blah/overlay/lib/res",
|
||||
},
|
||||
"bar": {"device/vendor/blah/overlay/bar/res"},
|
||||
"lib": {"device/vendor/blah/overlay/lib/res"},
|
||||
"bar": {"device:device/vendor/blah/overlay/bar/res"},
|
||||
"lib": {"device:device/vendor/blah/overlay/lib/res"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
resourceOverlays := []string{
|
||||
deviceResourceOverlays := []string{
|
||||
"device/vendor/blah/overlay",
|
||||
"device/vendor/blah/overlay2",
|
||||
"device/vendor/blah/static_overlay",
|
||||
}
|
||||
|
||||
productResourceOverlays := []string{
|
||||
"product/vendor/blah/overlay",
|
||||
}
|
||||
|
||||
fs := map[string][]byte{
|
||||
"foo/res/res/values/strings.xml": nil,
|
||||
"bar/res/res/values/strings.xml": nil,
|
||||
@@ -323,13 +334,14 @@ func TestAndroidResources(t *testing.T) {
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml": nil,
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml": nil,
|
||||
"device/vendor/blah/overlay2/res/values/strings.xml": nil,
|
||||
"product/vendor/blah/overlay/foo/res/values/strings.xml": nil,
|
||||
}
|
||||
|
||||
bp := `
|
||||
android_app {
|
||||
name: "foo",
|
||||
resource_dirs: ["foo/res"],
|
||||
static_libs: ["lib"],
|
||||
static_libs: ["lib", "lib3"],
|
||||
}
|
||||
|
||||
android_app {
|
||||
@@ -347,12 +359,19 @@ func TestAndroidResources(t *testing.T) {
|
||||
name: "lib2",
|
||||
resource_dirs: ["lib2/res"],
|
||||
}
|
||||
|
||||
// This library has the same resources as lib (should not lead to dupe RROs)
|
||||
android_library {
|
||||
name: "lib3",
|
||||
resource_dirs: ["lib/res"]
|
||||
}
|
||||
`
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
config := testConfig(nil)
|
||||
config.TestProductVariables.ResourceOverlays = resourceOverlays
|
||||
config.TestProductVariables.DeviceResourceOverlays = deviceResourceOverlays
|
||||
config.TestProductVariables.ProductResourceOverlays = productResourceOverlays
|
||||
if testCase.enforceRROTargets != nil {
|
||||
config.TestProductVariables.EnforceRROTargets = testCase.enforceRROTargets
|
||||
}
|
||||
@@ -389,7 +408,17 @@ func TestAndroidResources(t *testing.T) {
|
||||
overlayFiles = resourceListToFiles(module, overlayList.Inputs.Strings())
|
||||
}
|
||||
|
||||
rroDirs = module.Module().(AndroidLibraryDependency).ExportedRRODirs().Strings()
|
||||
for _, d := range module.Module().(AndroidLibraryDependency).ExportedRRODirs() {
|
||||
var prefix string
|
||||
if d.overlayType == device {
|
||||
prefix = "device:"
|
||||
} else if d.overlayType == product {
|
||||
prefix = "product:"
|
||||
} else {
|
||||
t.Fatalf("Unexpected overlayType %d", d.overlayType)
|
||||
}
|
||||
rroDirs = append(rroDirs, prefix+d.path.String())
|
||||
}
|
||||
|
||||
return resourceFiles, overlayFiles, rroDirs
|
||||
}
|
||||
|
Reference in New Issue
Block a user