Add ramdisk image sdk trait to cc_library_headers
Allows an sdk to require that a cc_library_headers module provides a ramdisk image variant for the prebuilt. Previously, "ramdisk_available: true" would be set in the generated prebuilt snapshot for any sdk member that specified "ramdisk_available: true" in the source module. This change will only add that setting to the snapshot if the ramdisk image variant trait was explicitly requested for a member. Bug: 195754365 Test: m nothing Change-Id: I21e0dd02d380beabf228a72c463fcc603c77d87f
This commit is contained in:
parent
a02157a4b7
commit
12a0a310a7
4 changed files with 26 additions and 0 deletions
|
@ -19,6 +19,7 @@ import "android/soong/android"
|
|||
// This file contains support for the image variant sdk traits.
|
||||
|
||||
func init() {
|
||||
android.RegisterSdkMemberTrait(ramdiskImageRequiredSdkTrait)
|
||||
android.RegisterSdkMemberTrait(recoveryImageRequiredSdkTrait)
|
||||
}
|
||||
|
||||
|
@ -26,6 +27,12 @@ type imageSdkTraitStruct struct {
|
|||
android.SdkMemberTraitBase
|
||||
}
|
||||
|
||||
var ramdiskImageRequiredSdkTrait android.SdkMemberTrait = &imageSdkTraitStruct{
|
||||
SdkMemberTraitBase: android.SdkMemberTraitBase{
|
||||
PropertyName: "ramdisk_image_required",
|
||||
},
|
||||
}
|
||||
|
||||
var recoveryImageRequiredSdkTrait android.SdkMemberTrait = &imageSdkTraitStruct{
|
||||
SdkMemberTraitBase: android.SdkMemberTraitBase{
|
||||
PropertyName: "recovery_image_required",
|
||||
|
|
|
@ -35,6 +35,7 @@ var headersLibrarySdkMemberType = &librarySdkMemberType{
|
|||
HostOsDependent: true,
|
||||
Traits: []android.SdkMemberTrait{
|
||||
nativeBridgeSdkTrait,
|
||||
ramdiskImageRequiredSdkTrait,
|
||||
recoveryImageRequiredSdkTrait,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -134,6 +134,16 @@ func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext
|
|||
targets: targets,
|
||||
})
|
||||
|
||||
// If required add additional dependencies on the image:ramdisk variants.
|
||||
if ctx.RequiresTrait(lib, ramdiskImageRequiredSdkTrait) {
|
||||
memberDependencies = append(memberDependencies, memberDependency{
|
||||
imageVariations: []blueprint.Variation{{Mutator: "image", Variation: android.RamdiskVariation}},
|
||||
// Only add a dependency on the first target as that is the only one which will have an
|
||||
// image:ramdisk variant.
|
||||
targets: targets[:1],
|
||||
})
|
||||
}
|
||||
|
||||
// If required add additional dependencies on the image:recovery variants.
|
||||
if ctx.RequiresTrait(lib, recoveryImageRequiredSdkTrait) {
|
||||
memberDependencies = append(memberDependencies, memberDependency{
|
||||
|
@ -199,6 +209,10 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext,
|
|||
pbm.AddProperty("native_bridge_supported", true)
|
||||
}
|
||||
|
||||
if ctx.RequiresTrait(ramdiskImageRequiredSdkTrait) {
|
||||
pbm.AddProperty("ramdisk_available", true)
|
||||
}
|
||||
|
||||
if ctx.RequiresTrait(recoveryImageRequiredSdkTrait) {
|
||||
pbm.AddProperty("recovery_available", true)
|
||||
}
|
||||
|
|
|
@ -2126,6 +2126,10 @@ myinclude/Test.h -> include/myinclude/Test.h
|
|||
)
|
||||
}
|
||||
|
||||
t.Run("ramdisk", func(t *testing.T) {
|
||||
testImageVariant(t, "ramdisk_available", "ramdisk_image_required")
|
||||
})
|
||||
|
||||
t.Run("recovery", func(t *testing.T) {
|
||||
testImageVariant(t, "recovery_available", "recovery_image_required")
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue