ndk_library depends on the correct arch variant of cc_library_headers
Previously before aosp/3249712, ndk_library was assumed to depend only
on ndk_headers, which do not have any variants.
As ndk_library can now depend on cc_library_headers which has many
variants for arch, sdk, and more, the previous assumption no longer
holds.
Therefore, when ndk_library makes a dependency to its
export_lib_headers, it now uses either AddFarVariationDependency with
(for ndk_headers) or AddVariationDependency (for others) depending on
which module type it depends on.
Bug: 357711733
Test: build with https://r.android.com/q/topic:%22no-cpp-in-ndk-2%22
Change-Id: Id0957e82736bd458e15674ffc45ca32b1e3a7250
diff --git a/cc/cc.go b/cc/cc.go
index 947dc1a..eee2d61 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2507,8 +2507,14 @@
}
if c.isNDKStubLibrary() {
- // ndk_headers do not have any variations
- actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
+ variationExists := actx.OtherModuleDependencyVariantExists(nil, lib)
+ if variationExists {
+ actx.AddVariationDependencies(nil, depTag, lib)
+ } else {
+ // dependencies to ndk_headers fall here as ndk_headers do not have
+ // any variants.
+ actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
+ }
} else if c.IsStubs() && !c.isImportedApiLibrary() {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
depTag, lib)