Merge changes I046d75db,Ie13817dc am: d2aa190bdc am: f2c86c8c76

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2058908

Change-Id: Id2e528bb65a943ea59e9b74d936d961aee6e125f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross
2022-04-12 00:08:09 +00:00
committed by Automerger Merge Worker
5 changed files with 76 additions and 42 deletions

View File

@@ -202,8 +202,6 @@ var prepareForApexTest = android.GroupFixturePreparers(
"myapex.apks": nil,
"frameworks/base/api/current.txt": nil,
"framework/aidl/a.aidl": nil,
"build/make/core/proguard.flags": nil,
"build/make/core/proguard_basic_keeps.flags": nil,
"dummy.txt": nil,
"baz": nil,
"bar/baz": nil,

View File

@@ -638,7 +638,21 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
certificates := processMainCert(a.ModuleBase, a.getCertString(ctx), certificateDeps, ctx)
// This can be reached with an empty certificate list if AllowMissingDependencies is set
// and the certificate property for this module is a module reference to a missing module.
if len(certificates) > 0 {
a.certificate = certificates[0]
} else {
if !ctx.Config().AllowMissingDependencies() && len(ctx.GetMissingDependencies()) > 0 {
panic("Should only get here if AllowMissingDependencies set and there are missing dependencies")
}
// Set a certificate to avoid panics later when accessing it.
a.certificate = Certificate{
Key: android.PathForModuleOut(ctx, "missing.pk8"),
Pem: android.PathForModuleOut(ctx, "missing.pem"),
}
}
// Build a final signed app package.
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")

View File

@@ -2948,3 +2948,24 @@ func TestTargetSdkVersionManifestFixer(t *testing.T) {
android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
}
}
func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestWithAllowMissingDependencies,
android.PrepareForTestWithAndroidMk,
).RunTestWithBp(t, `
android_app {
name: "foo",
srcs: ["a.java"],
certificate: ":missing_certificate",
sdk_version: "current",
}`)
foo := result.ModuleForTests("foo", "android_common")
fooApk := foo.Output("foo.apk")
if fooApk.Rule != android.ErrorRule {
t.Fatalf("expected ErrorRule for foo.apk, got %s", fooApk.Rule.String())
}
android.AssertStringDoesContain(t, "expected error rule message", fooApk.Args["error"], "missing dependencies: missing_certificate\n")
}

View File

@@ -70,6 +70,10 @@ var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixtu
defaultJavaDir + "/framework/aidl": nil,
// Needed for various deps defined in GatherRequiredDepsForTest()
defaultJavaDir + "/a.java": nil,
// Needed for R8 rules on apps
"build/make/core/proguard.flags": nil,
"build/make/core/proguard_basic_keeps.flags": nil,
}.AddToFixture(),
// The java default module definitions.
android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),

View File

@@ -98,9 +98,6 @@ func test(t *testing.T, bp string) *android.TestResult {
"build/soong/scripts/jar-wrapper.sh": nil,
"build/make/core/proguard.flags": nil,
"build/make/core/proguard_basic_keeps.flags": nil,
"jdk8/jre/lib/jce.jar": nil,
"jdk8/jre/lib/rt.jar": nil,
"jdk8/lib/tools.jar": nil,