Merge changes I046d75db,Ie13817dc am: d2aa190bdc

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

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

View File

@@ -174,44 +174,42 @@ var prepareForApexTest = android.GroupFixturePreparers(
"system/sepolicy/apex/otherapex-file_contexts": nil,
"system/sepolicy/apex/com.android.vndk-file_contexts": nil,
"system/sepolicy/apex/com.android.vndk.current-file_contexts": nil,
"mylib.cpp": nil,
"mytest.cpp": nil,
"mytest1.cpp": nil,
"mytest2.cpp": nil,
"mytest3.cpp": nil,
"myprebuilt": nil,
"my_include": nil,
"foo/bar/MyClass.java": nil,
"prebuilt.jar": nil,
"prebuilt.so": nil,
"vendor/foo/devkeys/test.x509.pem": nil,
"vendor/foo/devkeys/test.pk8": nil,
"testkey.x509.pem": nil,
"testkey.pk8": nil,
"testkey.override.x509.pem": nil,
"testkey.override.pk8": nil,
"vendor/foo/devkeys/testkey.avbpubkey": nil,
"vendor/foo/devkeys/testkey.pem": nil,
"NOTICE": nil,
"custom_notice": nil,
"custom_notice_for_static_lib": nil,
"testkey2.avbpubkey": nil,
"testkey2.pem": nil,
"myapex-arm64.apex": nil,
"myapex-arm.apex": nil,
"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,
"testdata/baz": nil,
"AppSet.apks": nil,
"foo.rs": nil,
"libfoo.jar": nil,
"libbar.jar": nil,
"mylib.cpp": nil,
"mytest.cpp": nil,
"mytest1.cpp": nil,
"mytest2.cpp": nil,
"mytest3.cpp": nil,
"myprebuilt": nil,
"my_include": nil,
"foo/bar/MyClass.java": nil,
"prebuilt.jar": nil,
"prebuilt.so": nil,
"vendor/foo/devkeys/test.x509.pem": nil,
"vendor/foo/devkeys/test.pk8": nil,
"testkey.x509.pem": nil,
"testkey.pk8": nil,
"testkey.override.x509.pem": nil,
"testkey.override.pk8": nil,
"vendor/foo/devkeys/testkey.avbpubkey": nil,
"vendor/foo/devkeys/testkey.pem": nil,
"NOTICE": nil,
"custom_notice": nil,
"custom_notice_for_static_lib": nil,
"testkey2.avbpubkey": nil,
"testkey2.pem": nil,
"myapex-arm64.apex": nil,
"myapex-arm.apex": nil,
"myapex.apks": nil,
"frameworks/base/api/current.txt": nil,
"framework/aidl/a.aidl": nil,
"dummy.txt": nil,
"baz": nil,
"bar/baz": nil,
"testdata/baz": nil,
"AppSet.apks": nil,
"foo.rs": nil,
"libfoo.jar": nil,
"libbar.jar": nil,
},
),

View File

@@ -638,7 +638,21 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
certificates := processMainCert(a.ModuleBase, a.getCertString(ctx), certificateDeps, ctx)
a.certificate = certificates[0]
// 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,