Add libs properties to runtime_resource_overlay.
Test: app_test.go Test: Converted an existing RRO module. Bug: 148788111 Change-Id: I723c7175760da019d38893e54f236c45f4c973ea
This commit is contained in:
parent
b4d816e0c4
commit
ca095d786a
|
@ -1345,6 +1345,12 @@ type RuntimeResourceOverlayProperties struct {
|
|||
// if not blank, set the minimum version of the sdk that the compiled artifacts will run against.
|
||||
// Defaults to sdk_version if not set.
|
||||
Min_sdk_version *string
|
||||
|
||||
// list of android_library modules whose resources are extracted and linked against statically
|
||||
Static_libs []string
|
||||
|
||||
// list of android_app modules whose resources are extracted and linked against
|
||||
Resource_libs []string
|
||||
}
|
||||
|
||||
func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
@ -1357,6 +1363,9 @@ func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext)
|
|||
if cert != "" {
|
||||
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
||||
}
|
||||
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, r.properties.Static_libs...)
|
||||
ctx.AddVariationDependencies(nil, libTag, r.properties.Resource_libs...)
|
||||
}
|
||||
|
||||
func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
|
|
@ -2342,11 +2342,17 @@ func checkAapt2LinkFlag(t *testing.T, aapt2Flags, flagName, expectedValue string
|
|||
}
|
||||
|
||||
func TestRuntimeResourceOverlay(t *testing.T) {
|
||||
ctx, config := testJava(t, `
|
||||
fs := map[string][]byte{
|
||||
"baz/res/res/values/strings.xml": nil,
|
||||
"bar/res/res/values/strings.xml": nil,
|
||||
}
|
||||
bp := `
|
||||
runtime_resource_overlay {
|
||||
name: "foo",
|
||||
certificate: "platform",
|
||||
product_specific: true,
|
||||
static_libs: ["bar"],
|
||||
resource_libs: ["baz"],
|
||||
aaptflags: ["--keep-raw-values"],
|
||||
}
|
||||
|
||||
|
@ -2356,7 +2362,21 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
|||
product_specific: true,
|
||||
theme: "faza",
|
||||
}
|
||||
`)
|
||||
|
||||
android_library {
|
||||
name: "bar",
|
||||
resource_dirs: ["bar/res"],
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "baz",
|
||||
sdk_version: "current",
|
||||
resource_dirs: ["baz/res"],
|
||||
}
|
||||
`
|
||||
config := testAppConfig(nil, bp, fs)
|
||||
ctx := testContext()
|
||||
run(t, ctx, config)
|
||||
|
||||
m := ctx.ModuleForTests("foo", "android_common")
|
||||
|
||||
|
@ -2368,6 +2388,19 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
|||
t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check overlay.list output for static_libs dependency.
|
||||
overlayList := m.Output("aapt2/overlay.list").Inputs.Strings()
|
||||
staticLibPackage := buildDir + "/.intermediates/bar/android_common/package-res.apk"
|
||||
if !inList(staticLibPackage, overlayList) {
|
||||
t.Errorf("Stactic lib res package %q missing in overlay list: %q", staticLibPackage, overlayList)
|
||||
}
|
||||
|
||||
// Check AAPT2 link flags for resource_libs dependency.
|
||||
resourceLibFlag := "-I " + buildDir + "/.intermediates/baz/android_common/package-res.apk"
|
||||
if !strings.Contains(aapt2Flags, resourceLibFlag) {
|
||||
t.Errorf("Resource lib flag %q missing in aapt2 link flags: %q", resourceLibFlag, aapt2Flags)
|
||||
}
|
||||
|
||||
// Check cert signing flag.
|
||||
signedApk := m.Output("signed/foo.apk")
|
||||
signingFlag := signedApk.Args["certificates"]
|
||||
|
|
Loading…
Reference in New Issue