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
|
// PrebuiltSourceDepsMutator adds dependencies to the prebuilt module from the
|
||||||
// corresponding source module, if one exists for the same variant.
|
// corresponding source module, if one exists for the same variant.
|
||||||
func PrebuiltSourceDepsMutator(ctx BottomUpMutatorContext) {
|
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()
|
p := m.Prebuilt()
|
||||||
if !p.properties.PrebuiltRenamedToSource {
|
if !p.properties.PrebuiltRenamedToSource {
|
||||||
name := m.base().BaseModuleName()
|
name := m.base().BaseModuleName()
|
||||||
|
|
|
@ -23,9 +23,8 @@ import (
|
||||||
|
|
||||||
var prebuiltsTests = []struct {
|
var prebuiltsTests = []struct {
|
||||||
name string
|
name string
|
||||||
replaceBp bool // modules is added to default bp boilerplate if false.
|
|
||||||
modules string
|
modules string
|
||||||
prebuilt []OsType
|
prebuilt []OsClass
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no prebuilt",
|
name: "no prebuilt",
|
||||||
|
@ -43,7 +42,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: false,
|
prefer: false,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: []OsClass{Device, Host},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "no source prebuilt preferred",
|
name: "no source prebuilt preferred",
|
||||||
|
@ -53,7 +52,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: true,
|
prefer: true,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: []OsClass{Device, Host},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt not preferred",
|
name: "prebuilt not preferred",
|
||||||
|
@ -81,7 +80,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: true,
|
prefer: true,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: []OsClass{Device, Host},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt no file not preferred",
|
name: "prebuilt no file not preferred",
|
||||||
|
@ -121,7 +120,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: true,
|
prefer: true,
|
||||||
srcs: [":fg"],
|
srcs: [":fg"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: []OsClass{Device, Host},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt module for device only",
|
name: "prebuilt module for device only",
|
||||||
|
@ -136,7 +135,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: true,
|
prefer: true,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android},
|
prebuilt: []OsClass{Device},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt file for host only",
|
name: "prebuilt file for host only",
|
||||||
|
@ -154,7 +153,7 @@ var prebuiltsTests = []struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{BuildOs},
|
prebuilt: []OsClass{Host},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt override not preferred",
|
name: "prebuilt override not preferred",
|
||||||
|
@ -192,72 +191,7 @@ var prebuiltsTests = []struct {
|
||||||
prefer: true,
|
prefer: true,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: []OsClass{Device, Host},
|
||||||
},
|
|
||||||
{
|
|
||||||
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},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,25 +203,14 @@ func TestPrebuilts(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range prebuiltsTests {
|
for _, test := range prebuiltsTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
bp := test.modules
|
bp := `
|
||||||
if !test.replaceBp {
|
|
||||||
bp = bp + `
|
|
||||||
source {
|
source {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
deps: [":bar"],
|
deps: [":bar"],
|
||||||
}`
|
|
||||||
}
|
}
|
||||||
|
` + test.modules
|
||||||
config := TestArchConfig(buildDir, nil, bp, fs)
|
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()
|
ctx := NewTestArchContext()
|
||||||
registerTestPrebuiltBuildComponents(ctx)
|
registerTestPrebuiltBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||||
|
@ -300,7 +223,7 @@ func TestPrebuilts(t *testing.T) {
|
||||||
|
|
||||||
for _, variant := range ctx.ModuleVariantsForTests("foo") {
|
for _, variant := range ctx.ModuleVariantsForTests("foo") {
|
||||||
foo := ctx.ModuleForTests("foo", variant)
|
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
|
var dependsOnSourceModule, dependsOnPrebuiltModule bool
|
||||||
ctx.VisitDirectDeps(foo.Module(), func(m blueprint.Module) {
|
ctx.VisitDirectDeps(foo.Module(), func(m blueprint.Module) {
|
||||||
if _, ok := m.(*sourceModule); ok {
|
if _, ok := m.(*sourceModule); ok {
|
||||||
|
@ -314,38 +237,26 @@ func TestPrebuilts(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
moduleIsDisabled := !foo.Module().Enabled()
|
|
||||||
deps := foo.Module().(*sourceModule).deps
|
deps := foo.Module().(*sourceModule).deps
|
||||||
if moduleIsDisabled {
|
if deps == nil || len(deps) != 1 {
|
||||||
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)
|
t.Errorf("deps does not have single path, but is %v", deps)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var usingSourceFile, usingPrebuiltFile bool
|
var usingSourceFile, usingPrebuiltFile bool
|
||||||
if len(deps) > 0 && deps[0].String() == "source_file" {
|
if deps[0].String() == "source_file" {
|
||||||
usingSourceFile = true
|
usingSourceFile = true
|
||||||
}
|
}
|
||||||
if len(deps) > 0 && deps[0].String() == "prebuilt_file" {
|
if deps[0].String() == "prebuilt_file" {
|
||||||
usingPrebuiltFile = true
|
usingPrebuiltFile = true
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt := false
|
prebuilt := false
|
||||||
for _, os := range test.prebuilt {
|
for _, os := range test.prebuilt {
|
||||||
if os == foo.Module().Target().Os {
|
if os == foo.Module().Target().Os.Class {
|
||||||
prebuilt = true
|
prebuilt = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if prebuilt {
|
if prebuilt {
|
||||||
if moduleIsDisabled {
|
|
||||||
t.Errorf("dependent module for prebuilt is disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !dependsOnPrebuiltModule {
|
if !dependsOnPrebuiltModule {
|
||||||
t.Errorf("doesn't depend on prebuilt module")
|
t.Errorf("doesn't depend on prebuilt module")
|
||||||
}
|
}
|
||||||
|
@ -359,7 +270,7 @@ func TestPrebuilts(t *testing.T) {
|
||||||
if usingSourceFile {
|
if usingSourceFile {
|
||||||
t.Errorf("using source_file")
|
t.Errorf("using source_file")
|
||||||
}
|
}
|
||||||
} else if !moduleIsDisabled {
|
} else {
|
||||||
if dependsOnPrebuiltModule {
|
if dependsOnPrebuiltModule {
|
||||||
t.Errorf("depends on prebuilt module")
|
t.Errorf("depends on prebuilt module")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue