Fix installing prebuilts with no source module

Prebuilts that were not overriding a source module would never
get UsePrebuilt set, which would cause SkipInstall() to be called,
and prevent the module from being exported to make.

Test: prebuilt_test.go
Change-Id: Ib09300efff26f09245331e9919ae2db82b0c3625
This commit is contained in:
Colin Cross
2017-03-17 13:14:32 -07:00
parent 6bdcc8ddd6
commit c3e7fa65b4
2 changed files with 26 additions and 16 deletions

View File

@@ -76,10 +76,15 @@ func prebuiltMutator(ctx BottomUpMutatorContext) {
}
}
// PrebuiltSelectModuleMutator marks prebuilts that are overriding source modules, and disables
// installing the source module.
// PrebuiltSelectModuleMutator marks prebuilts that are used, either overriding source modules or
// because the source module doesn't exist. It also disables installing overridden source modules.
func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
if s, ok := ctx.Module().(Module); ok {
if m, ok := ctx.Module().(PrebuiltInterface); ok && m.Prebuilt() != nil {
p := m.Prebuilt()
if !p.Properties.SourceExists {
p.Properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
}
} else if s, ok := ctx.Module().(Module); ok {
ctx.VisitDirectDeps(func(m blueprint.Module) {
if ctx.OtherModuleDependencyTag(m) == prebuiltDepTag {
p := m.(PrebuiltInterface).Prebuilt()
@@ -121,5 +126,5 @@ func (p *Prebuilt) usePrebuilt(ctx TopDownMutatorContext, source Module) bool {
return true
}
return !source.Enabled()
return source == nil || !source.Enabled()
}