Merge "Add libs properties to runtime_resource_overlay." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1883126573
@@ -1345,6 +1345,12 @@ type RuntimeResourceOverlayProperties struct {
|
|||||||
// if not blank, set the minimum version of the sdk that the compiled artifacts will run against.
|
// if not blank, set the minimum version of the sdk that the compiled artifacts will run against.
|
||||||
// Defaults to sdk_version if not set.
|
// Defaults to sdk_version if not set.
|
||||||
Min_sdk_version *string
|
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) {
|
func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -1357,6 +1363,9 @@ func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext)
|
|||||||
if cert != "" {
|
if cert != "" {
|
||||||
ctx.AddDependency(ctx.Module(), certificateTag, 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) {
|
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) {
|
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 {
|
runtime_resource_overlay {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
certificate: "platform",
|
certificate: "platform",
|
||||||
product_specific: true,
|
product_specific: true,
|
||||||
|
static_libs: ["bar"],
|
||||||
|
resource_libs: ["baz"],
|
||||||
aaptflags: ["--keep-raw-values"],
|
aaptflags: ["--keep-raw-values"],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2356,7 +2362,21 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
|||||||
product_specific: true,
|
product_specific: true,
|
||||||
theme: "faza",
|
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")
|
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)
|
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.
|
// Check cert signing flag.
|
||||||
signedApk := m.Output("signed/foo.apk")
|
signedApk := m.Output("signed/foo.apk")
|
||||||
signingFlag := signedApk.Args["certificates"]
|
signingFlag := signedApk.Args["certificates"]
|
||||||
|
Reference in New Issue
Block a user