Revert "Do not consider disabled prebuilt variants."
This reverts commit 235e2fdbd3
.
Reason for revert: <build break>
Bug: 161315642
Change-Id: Ie741252dc1d0749591f141c71c3d59ce45f0234f
This commit is contained in:
parent
235e2fdbd3
commit
6ffbe57270
|
@ -225,7 +225,7 @@ func PrebuiltRenameMutator(ctx BottomUpMutatorContext) {
|
|||
// PrebuiltSourceDepsMutator adds dependencies to the prebuilt module from the
|
||||
// corresponding source module, if one exists for the same variant.
|
||||
func PrebuiltSourceDepsMutator(ctx BottomUpMutatorContext) {
|
||||
if m, ok := ctx.Module().(PrebuiltInterface); ok && m.Enabled() && m.Prebuilt() != nil {
|
||||
if m, ok := ctx.Module().(PrebuiltInterface); ok && m.Prebuilt() != nil {
|
||||
p := m.Prebuilt()
|
||||
if !p.properties.PrebuiltRenamedToSource {
|
||||
name := m.base().BaseModuleName()
|
||||
|
|
|
@ -22,10 +22,9 @@ import (
|
|||
)
|
||||
|
||||
var prebuiltsTests = []struct {
|
||||
name string
|
||||
replaceBp bool // modules is added to default bp boilerplate if false.
|
||||
modules string
|
||||
prebuilt []OsType
|
||||
name string
|
||||
modules string
|
||||
prebuilt []OsClass
|
||||
}{
|
||||
{
|
||||
name: "no prebuilt",
|
||||
|
@ -43,7 +42,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: false,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
prebuilt: []OsClass{Device, Host},
|
||||
},
|
||||
{
|
||||
name: "no source prebuilt preferred",
|
||||
|
@ -53,7 +52,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
prebuilt: []OsClass{Device, Host},
|
||||
},
|
||||
{
|
||||
name: "prebuilt not preferred",
|
||||
|
@ -81,7 +80,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
prebuilt: []OsClass{Device, Host},
|
||||
},
|
||||
{
|
||||
name: "prebuilt no file not preferred",
|
||||
|
@ -121,7 +120,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: true,
|
||||
srcs: [":fg"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
prebuilt: []OsClass{Device, Host},
|
||||
},
|
||||
{
|
||||
name: "prebuilt module for device only",
|
||||
|
@ -136,7 +135,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android},
|
||||
prebuilt: []OsClass{Device},
|
||||
},
|
||||
{
|
||||
name: "prebuilt file for host only",
|
||||
|
@ -154,7 +153,7 @@ var prebuiltsTests = []struct {
|
|||
},
|
||||
},
|
||||
}`,
|
||||
prebuilt: []OsType{BuildOs},
|
||||
prebuilt: []OsClass{Host},
|
||||
},
|
||||
{
|
||||
name: "prebuilt override not preferred",
|
||||
|
@ -192,72 +191,7 @@ var prebuiltsTests = []struct {
|
|||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
},
|
||||
{
|
||||
name: "prebuilt including default-disabled OS",
|
||||
replaceBp: true,
|
||||
modules: `
|
||||
source {
|
||||
name: "foo",
|
||||
deps: [":bar"],
|
||||
target: {
|
||||
windows: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
source {
|
||||
name: "bar",
|
||||
target: {
|
||||
windows: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
target: {
|
||||
windows: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs, Windows},
|
||||
},
|
||||
{
|
||||
name: "fall back to source for default-disabled OS",
|
||||
replaceBp: true,
|
||||
modules: `
|
||||
source {
|
||||
name: "foo",
|
||||
deps: [":bar"],
|
||||
target: {
|
||||
windows: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
source {
|
||||
name: "bar",
|
||||
target: {
|
||||
windows: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
prebuilt: []OsClass{Device, Host},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -269,25 +203,14 @@ func TestPrebuilts(t *testing.T) {
|
|||
|
||||
for _, test := range prebuiltsTests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
bp := test.modules
|
||||
if !test.replaceBp {
|
||||
bp = bp + `
|
||||
source {
|
||||
name: "foo",
|
||||
deps: [":bar"],
|
||||
}`
|
||||
}
|
||||
bp := `
|
||||
source {
|
||||
name: "foo",
|
||||
deps: [":bar"],
|
||||
}
|
||||
` + test.modules
|
||||
config := TestArchConfig(buildDir, nil, bp, fs)
|
||||
|
||||
// Add windows to the target list to test the logic when a variant is
|
||||
// disabled by default.
|
||||
if !Windows.DefaultDisabled {
|
||||
t.Errorf("windows is assumed to be disabled by default")
|
||||
}
|
||||
config.config.Targets[Windows] = []Target{
|
||||
{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
||||
}
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
registerTestPrebuiltBuildComponents(ctx)
|
||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||
|
@ -300,7 +223,7 @@ func TestPrebuilts(t *testing.T) {
|
|||
|
||||
for _, variant := range ctx.ModuleVariantsForTests("foo") {
|
||||
foo := ctx.ModuleForTests("foo", variant)
|
||||
t.Run(foo.Module().Target().Os.String(), func(t *testing.T) {
|
||||
t.Run(foo.Module().Target().Os.Class.String(), func(t *testing.T) {
|
||||
var dependsOnSourceModule, dependsOnPrebuiltModule bool
|
||||
ctx.VisitDirectDeps(foo.Module(), func(m blueprint.Module) {
|
||||
if _, ok := m.(*sourceModule); ok {
|
||||
|
@ -314,38 +237,26 @@ func TestPrebuilts(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
moduleIsDisabled := !foo.Module().Enabled()
|
||||
deps := foo.Module().(*sourceModule).deps
|
||||
if moduleIsDisabled {
|
||||
if len(deps) > 0 {
|
||||
t.Errorf("disabled module got deps: %v", deps)
|
||||
}
|
||||
} else {
|
||||
if len(deps) != 1 {
|
||||
t.Errorf("deps does not have single path, but is %v", deps)
|
||||
}
|
||||
if deps == nil || len(deps) != 1 {
|
||||
t.Errorf("deps does not have single path, but is %v", deps)
|
||||
}
|
||||
|
||||
var usingSourceFile, usingPrebuiltFile bool
|
||||
if len(deps) > 0 && deps[0].String() == "source_file" {
|
||||
if deps[0].String() == "source_file" {
|
||||
usingSourceFile = true
|
||||
}
|
||||
if len(deps) > 0 && deps[0].String() == "prebuilt_file" {
|
||||
if deps[0].String() == "prebuilt_file" {
|
||||
usingPrebuiltFile = true
|
||||
}
|
||||
|
||||
prebuilt := false
|
||||
for _, os := range test.prebuilt {
|
||||
if os == foo.Module().Target().Os {
|
||||
if os == foo.Module().Target().Os.Class {
|
||||
prebuilt = true
|
||||
}
|
||||
}
|
||||
|
||||
if prebuilt {
|
||||
if moduleIsDisabled {
|
||||
t.Errorf("dependent module for prebuilt is disabled")
|
||||
}
|
||||
|
||||
if !dependsOnPrebuiltModule {
|
||||
t.Errorf("doesn't depend on prebuilt module")
|
||||
}
|
||||
|
@ -359,7 +270,7 @@ func TestPrebuilts(t *testing.T) {
|
|||
if usingSourceFile {
|
||||
t.Errorf("using source_file")
|
||||
}
|
||||
} else if !moduleIsDisabled {
|
||||
} else {
|
||||
if dependsOnPrebuiltModule {
|
||||
t.Errorf("depends on prebuilt module")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue