Add recovery image sdk trait to cc_library_headers

Allows an sdk to require that a cc_library_headers module provides a
recovery image variant for the prebuilt.

Previously, "recovery_available: true" would be set in the generated
prebuilt snapshot for any sdk member that specified
"recovery_available: true" in the source module. This change will only
add that setting to the snapshot if the recovery image variant trait
was explicitly requested for a member.

Bug: 195754365
Test: m nothing
Change-Id: I7d79ccdec843127f7852d82b4b163021e30a79a7
This commit is contained in:
Paul Duffin
2021-09-06 10:28:34 +01:00
parent b42fa67a47
commit 6369622f8d
5 changed files with 98 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
package sdk
import (
"fmt"
"testing"
"android/soong/android"
@@ -1771,7 +1772,6 @@ cc_prebuilt_library {
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
recovery_available: true,
vendor_available: true,
stl: "none",
compile_multilib: "both",
@@ -1806,7 +1806,6 @@ cc_prebuilt_library {
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
installable: false,
recovery_available: true,
vendor_available: true,
stl: "none",
compile_multilib: "both",
@@ -2081,6 +2080,57 @@ func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *t
`)
}
func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
testImageVariant := func(t *testing.T, property, trait string) {
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
ccTestFs.AddToFixture(),
).RunTestWithBp(t, fmt.Sprintf(`
sdk {
name: "mysdk",
native_header_libs: ["mynativeheaders"],
traits: {
%s: ["mynativeheaders"],
},
}
cc_library_headers {
name: "mynativeheaders",
export_include_dirs: ["myinclude"],
stl: "none",
system_shared_libs: [],
%s: true,
}
`, trait, property))
CheckSnapshot(t, result, "mysdk", "",
checkUnversionedAndroidBpContents(fmt.Sprintf(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
%s: true,
stl: "none",
compile_multilib: "both",
system_shared_libs: [],
export_include_dirs: ["include/myinclude"],
}
`, property)),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
`),
)
}
t.Run("recovery", func(t *testing.T) {
testImageVariant(t, "recovery_available", "recovery_image_required")
})
}
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
result := testSdkWithCc(t, `
sdk {