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:
parent
6bdcc8ddd6
commit
c3e7fa65b4
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -144,20 +144,33 @@ func TestPrebuilts(t *testing.T) {
|
|||
t.Fatalf("failed to find module foo")
|
||||
}
|
||||
|
||||
var dependsOnSourceModule, dependsOnPrebuiltModule bool
|
||||
ctx.VisitDirectDeps(foo, func(m blueprint.Module) {
|
||||
if _, ok := m.(*sourceModule); ok {
|
||||
dependsOnSourceModule = true
|
||||
}
|
||||
if p, ok := m.(*prebuiltModule); ok {
|
||||
dependsOnPrebuiltModule = true
|
||||
if !p.Prebuilt().Properties.UsePrebuilt {
|
||||
t.Errorf("dependency on prebuilt module not marked used")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if test.prebuilt {
|
||||
if !foo.(*sourceModule).dependsOnPrebuiltModule {
|
||||
if !dependsOnPrebuiltModule {
|
||||
t.Errorf("doesn't depend on prebuilt module")
|
||||
}
|
||||
|
||||
if foo.(*sourceModule).dependsOnSourceModule {
|
||||
if dependsOnSourceModule {
|
||||
t.Errorf("depends on source module")
|
||||
}
|
||||
} else {
|
||||
if foo.(*sourceModule).dependsOnPrebuiltModule {
|
||||
if dependsOnPrebuiltModule {
|
||||
t.Errorf("depends on prebuilt module")
|
||||
}
|
||||
|
||||
if !foo.(*sourceModule).dependsOnSourceModule {
|
||||
if !dependsOnSourceModule {
|
||||
t.Errorf("doens't depend on source module")
|
||||
}
|
||||
}
|
||||
|
@ -209,14 +222,6 @@ func (s *sourceModule) DepsMutator(ctx BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
func (s *sourceModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
ctx.VisitDirectDeps(func(m blueprint.Module) {
|
||||
if _, ok := m.(*sourceModule); ok {
|
||||
s.dependsOnSourceModule = true
|
||||
}
|
||||
if _, ok := m.(*prebuiltModule); ok {
|
||||
s.dependsOnPrebuiltModule = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func findModule(ctx *blueprint.Context, name string) blueprint.Module {
|
||||
|
|
Loading…
Reference in New Issue