summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
authorJose Galmes <jgalmes@google.com>2021-05-26 21:16:52 -0700
committerBill Peckham <bpeckham@google.com>2021-05-27 11:52:45 -0700
commit9520948508ef82cbf5f6010ee06397cda74c65fc (patch)
treea987616b8e3c32a7ece2ef6d73a397a68aa5d0ea /cc
parent7ee8da081b687cca38c1f02aadbdec8f51cf96ef (diff)
Fix duplicate variations when using the VSDK.
When using the VSDK there can be multiple variations of the same module for core, product, vendor, recovery. If two or more of those variations exist, a suffix must be added to the variation to avoid duplicate modules with the same name. Bug: 188717568 Test: m -j nothing Change-Id: Ifd8fa5590a8e225a97c2a8e3110d5d5f20beb50d (cherry picked from commit 7fdc336b9fb47ba6f740bc9108a180d9808b4cdb)
Diffstat (limited to 'cc')
-rw-r--r--cc/snapshot_prebuilt.go54
1 files changed, 41 insertions, 13 deletions
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index 26f95791b..98827500a 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -455,30 +455,49 @@ func (p *baseSnapshotDecorator) snapshotAndroidMkSuffix() string {
return p.baseProperties.Androidmk_suffix
}
-func (p *baseSnapshotDecorator) setSnapshotAndroidMkSuffix(ctx android.ModuleContext) {
- coreVariations := append(ctx.Target().Variations(), blueprint.Variation{
+func (p *baseSnapshotDecorator) setSnapshotAndroidMkSuffix(ctx android.ModuleContext, variant string) {
+ // If there are any 2 or more variations among {core, product, vendor, recovery}
+ // we have to add the androidmk suffix to avoid duplicate modules with the same
+ // name.
+ variations := append(ctx.Target().Variations(), blueprint.Variation{
Mutator: "image",
Variation: android.CoreVariation})
- if ctx.OtherModuleFarDependencyVariantExists(coreVariations, ctx.Module().(*Module).BaseModuleName()) {
+ if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(*Module).BaseModuleName()) {
p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix()
return
}
- // If there is no matching core variation, there could still be a
- // product variation, for example if a module is product specific and
- // vendor available. In that case, we also want to add the androidmk
- // suffix.
-
- productVariations := append(ctx.Target().Variations(), blueprint.Variation{
+ variations = append(ctx.Target().Variations(), blueprint.Variation{
Mutator: "image",
Variation: ProductVariationPrefix + ctx.DeviceConfig().PlatformVndkVersion()})
- if ctx.OtherModuleFarDependencyVariantExists(productVariations, ctx.Module().(*Module).BaseModuleName()) {
+ if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(*Module).BaseModuleName()) {
p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix()
return
}
+ images := []snapshotImage{vendorSnapshotImageSingleton, recoverySnapshotImageSingleton}
+
+ for _, image := range images {
+ if p.image == image {
+ continue
+ }
+ variations = append(ctx.Target().Variations(), blueprint.Variation{
+ Mutator: "image",
+ Variation: image.imageVariantName(ctx.DeviceConfig())})
+
+ if ctx.OtherModuleFarDependencyVariantExists(variations,
+ ctx.Module().(*Module).BaseModuleName()+
+ getSnapshotNameSuffix(
+ image.moduleNameSuffix()+variant,
+ p.version(),
+ ctx.DeviceConfig().Arches()[0].ArchType.String())) {
+ p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix()
+ return
+ }
+ }
+
p.baseProperties.Androidmk_suffix = ""
}
@@ -568,7 +587,16 @@ func (p *snapshotLibraryDecorator) matchesWithDevice(config android.DeviceConfig
// As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are
// done by normal library decorator, e.g. exporting flags.
func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
- p.setSnapshotAndroidMkSuffix(ctx)
+ var variant string
+ if p.shared() {
+ variant = snapshotSharedSuffix
+ } else if p.static() {
+ variant = snapshotStaticSuffix
+ } else {
+ variant = snapshotHeaderSuffix
+ }
+
+ p.setSnapshotAndroidMkSuffix(ctx, variant)
if p.header() {
return p.libraryDecorator.link(ctx, flags, deps, objs)
@@ -786,7 +814,7 @@ func (p *snapshotBinaryDecorator) matchesWithDevice(config android.DeviceConfig)
// cc modules' link functions are to link compiled objects into final binaries.
// As snapshots are prebuilts, this just returns the prebuilt binary
func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
- p.setSnapshotAndroidMkSuffix(ctx)
+ p.setSnapshotAndroidMkSuffix(ctx, snapshotBinarySuffix)
if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil
@@ -881,7 +909,7 @@ func (p *snapshotObjectLinker) matchesWithDevice(config android.DeviceConfig) bo
// cc modules' link functions are to link compiled objects into final binaries.
// As snapshots are prebuilts, this just returns the prebuilt binary
func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
- p.setSnapshotAndroidMkSuffix(ctx)
+ p.setSnapshotAndroidMkSuffix(ctx, snapshotObjectSuffix)
if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil