Merge "Lineage properties support module references."

This commit is contained in:
Jaewoong Jung 2021-03-11 00:59:32 +00:00 committed by Gerrit Code Review
commit 6df5e0307d
6 changed files with 73 additions and 5 deletions

View file

@ -118,6 +118,13 @@ func fieldsByIndex(v reflect.Value, index []int, values *[]reflect.Value) {
*values = append(*values, v.Index(i).Field(index[0])) *values = append(*values, v.Index(i).Field(index[0]))
} }
} else { } else {
// Dereference it if it's a pointer.
if v.Kind() == reflect.Ptr {
if v.IsNil() {
return
}
v = v.Elem()
}
*values = append(*values, v.Field(index[0])) *values = append(*values, v.Field(index[0]))
} }
return return

View file

@ -26,6 +26,9 @@ type pathDepsMutatorTestModule struct {
Bar []string `android:"path,arch_variant"` Bar []string `android:"path,arch_variant"`
Baz *string `android:"path"` Baz *string `android:"path"`
Qux string Qux string
V *struct {
W string `android:"path"`
}
} }
// A second property struct with a duplicate property name // A second property struct with a duplicate property name
@ -94,8 +97,11 @@ func TestPathDepsMutator(t *testing.T) {
], ],
}, },
], ],
v: {
w: ":w",
},
}`, }`,
deps: []string{"a", "b", "c", "x", "y", "z"}, deps: []string{"a", "b", "c", "w", "x", "y", "z"},
}, },
{ {
name: "arch variant", name: "arch variant",
@ -135,6 +141,10 @@ func TestPathDepsMutator(t *testing.T) {
name: "d", name: "d",
} }
filegroup {
name: "w",
}
filegroup { filegroup {
name: "x", name: "x",
} }

View file

@ -122,8 +122,8 @@ type overridableAppProperties struct {
// or an android_app_certificate module name in the form ":module". // or an android_app_certificate module name in the form ":module".
Certificate *string Certificate *string
// Name of the signing certificate lineage file. // Name of the signing certificate lineage file or filegroup module.
Lineage *string Lineage *string `android:"path"`
// the package name of this app. The package name in the manifest file is used if one was not given. // the package name of this app. The package name in the manifest file is used if one was not given.
Package_name *string Package_name *string

View file

@ -74,8 +74,8 @@ type AndroidAppImportProperties struct {
// be set for presigned modules. // be set for presigned modules.
Presigned *bool Presigned *bool
// Name of the signing certificate lineage file. // Name of the signing certificate lineage file or filegroup module.
Lineage *string Lineage *string `android:"path"`
// Sign with the default system dev certificate. Must be used judiciously. Most imported apps // Sign with the default system dev certificate. Must be used judiciously. Most imported apps
// need to either specify a specific certificate or be presigned. // need to either specify a specific certificate or be presigned.

View file

@ -138,6 +138,32 @@ func TestAndroidAppImport_SigningLineage(t *testing.T) {
} }
} }
func TestAndroidAppImport_SigningLineageFilegroup(t *testing.T) {
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
apk: "prebuilts/apk/app.apk",
certificate: "platform",
lineage: ":lineage_bin",
}
filegroup {
name: "lineage_bin",
srcs: ["lineage.bin"],
}
`)
variant := ctx.ModuleForTests("foo", "android_common")
signedApk := variant.Output("signed/foo.apk")
// Check cert signing lineage flag.
signingFlag := signedApk.Args["flags"]
expected := "--lineage lineage.bin"
if expected != signingFlag {
t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected, signingFlag)
}
}
func TestAndroidAppImport_DefaultDevCert(t *testing.T) { func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
ctx, _ := testJava(t, ` ctx, _ := testJava(t, `
android_app_import { android_app_import {

View file

@ -1576,6 +1576,31 @@ func TestCertificates(t *testing.T) {
expectedLineage: "--lineage lineage.bin", expectedLineage: "--lineage lineage.bin",
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
}, },
{
name: "lineage from filegroup",
bp: `
android_app {
name: "foo",
srcs: ["a.java"],
certificate: ":new_certificate",
lineage: ":lineage_bin",
sdk_version: "current",
}
android_app_certificate {
name: "new_certificate",
certificate: "cert/new_cert",
}
filegroup {
name: "lineage_bin",
srcs: ["lineage.bin"],
}
`,
certificateOverride: "",
expectedLineage: "--lineage lineage.bin",
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
},
} }
for _, test := range testCases { for _, test := range testCases {