Add support for native bridge trait
Adds a native bridge trait that if required will cause a cc_library_header module to generate a cc_prebuilt_library_headers with native_bridge_supported: true. It will fail if the cc_library_header's native bridge variant would produce native bridge specific properties, distinct from the other architecture variants, in the generated cc_prebuilt_library_headers. Bug: 195754365 Test: m nothing Change-Id: I282fbb9095de6c6af57cca4eb4260e2c6c2da8cc
This commit is contained in:
@@ -75,8 +75,33 @@ type librarySdkMemberType struct {
|
||||
}
|
||||
|
||||
func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := ctx.MultiTargets()
|
||||
// The base set of targets which does not include native bridge targets.
|
||||
defaultTargets := ctx.MultiTargets()
|
||||
|
||||
// The lazily created list of native bridge targets.
|
||||
var includeNativeBridgeTargets []android.Target
|
||||
|
||||
for _, lib := range names {
|
||||
targets := defaultTargets
|
||||
|
||||
// If native bridge support is required in the sdk snapshot then add native bridge targets to
|
||||
// the basic list of targets that are required.
|
||||
nativeBridgeSupport := ctx.RequiresTrait(lib, nativeBridgeSdkTrait)
|
||||
if nativeBridgeSupport && ctx.Device() {
|
||||
// If not already computed then compute the list of native bridge targets.
|
||||
if includeNativeBridgeTargets == nil {
|
||||
includeNativeBridgeTargets = append([]android.Target{}, defaultTargets...)
|
||||
allAndroidTargets := ctx.Config().Targets[android.Android]
|
||||
for _, possibleNativeBridgeTarget := range allAndroidTargets {
|
||||
if possibleNativeBridgeTarget.NativeBridge == android.NativeBridgeEnabled {
|
||||
includeNativeBridgeTargets = append(includeNativeBridgeTargets, possibleNativeBridgeTarget)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include the native bridge targets as well.
|
||||
targets = includeNativeBridgeTargets
|
||||
}
|
||||
for _, target := range targets {
|
||||
name, version := StubsLibNameAndVersion(lib)
|
||||
if version == "" {
|
||||
@@ -122,6 +147,10 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext,
|
||||
|
||||
ccModule := member.Variants()[0].(*Module)
|
||||
|
||||
if ctx.RequiresTrait(nativeBridgeSdkTrait) {
|
||||
pbm.AddProperty("native_bridge_supported", true)
|
||||
}
|
||||
|
||||
if proptools.Bool(ccModule.Properties.Recovery_available) {
|
||||
pbm.AddProperty("recovery_available", true)
|
||||
}
|
||||
@@ -436,7 +465,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte
|
||||
exportedIncludeDirs, exportedGeneratedIncludeDirs := android.FilterPathListPredicate(
|
||||
exportedInfo.IncludeDirs, isGeneratedHeaderDirectory)
|
||||
|
||||
p.archSubDir = ccModule.Target().Arch.ArchType.String()
|
||||
target := ccModule.Target()
|
||||
p.archSubDir = target.Arch.ArchType.String()
|
||||
if target.NativeBridge == android.NativeBridgeEnabled {
|
||||
p.archSubDir += "_native_bridge"
|
||||
}
|
||||
|
||||
// Make sure that the include directories are unique.
|
||||
p.ExportedIncludeDirs = android.FirstUniquePaths(exportedIncludeDirs)
|
||||
|
Reference in New Issue
Block a user