Use shared variant of dep for packaging
For native modules that have both static and shared variants (e.g.
cc_library), the deps mutator of android_filesystem would always create
a dep to the static variant. This is likely due to the fact that
`AddFarVariationDependencies` creates a dependency on the first variant
of the dep which matches the requested variations. `static` appears
before `shared` in linkMutator, and therefore android_filesystem would
always create a dep to the static variant.
This CL uses `OtherModuleFarDependencyVariantExists` to create a dep to
the shared variant. If a cc_library is listed in `PRODUCT_PACKAGES`, it
always means the shared variant.
Test: go test./filesystem
Test: diff in kati install files of vendor/ before and after this CL
https://diff.googleplex.com/#key=qrY73chVkwff
Change-Id: Iea9d6fde199ef95d43da2c041e2f84e5a7951285
diff --git a/android/packaging.go b/android/packaging.go
index d615871..b505964 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -377,7 +377,17 @@
if p.IgnoreMissingDependencies && !ctx.OtherModuleExists(dep) {
continue
}
- ctx.AddFarVariationDependencies(t.Variations(), depTag, dep)
+ targetVariation := t.Variations()
+ sharedVariation := blueprint.Variation{
+ Mutator: "link",
+ Variation: "shared",
+ }
+ // If a shared variation exists, use that. Static variants do not provide any standalone files
+ // for packaging.
+ if ctx.OtherModuleFarDependencyVariantExists([]blueprint.Variation{sharedVariation}, dep) {
+ targetVariation = append(targetVariation, sharedVariation)
+ }
+ ctx.AddFarVariationDependencies(targetVariation, depTag, dep)
}
}
}