Merge "Make it possible to specify separate rules for native_bridge case"
This commit is contained in:
commit
bf488e10e8
2 changed files with 91 additions and 0 deletions
|
@ -1026,6 +1026,7 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
|
|||
"Not_windows",
|
||||
"Arm_on_x86",
|
||||
"Arm_on_x86_64",
|
||||
"Native_bridge",
|
||||
}
|
||||
for _, os := range OsTypeList {
|
||||
targets = append(targets, os.Field)
|
||||
|
@ -1413,6 +1414,11 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||
prefix := "target.arm_on_x86_64"
|
||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||
}
|
||||
if os == Android && m.Target().NativeBridge == NativeBridgeEnabled {
|
||||
field := "Native_bridge"
|
||||
prefix := "target.native_bridge"
|
||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,3 +383,88 @@ func TestArchMutator(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestArchMutatorNativeBridge(t *testing.T) {
|
||||
bp := `
|
||||
// This module is only enabled for x86.
|
||||
module {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
// This module is enabled for x86 and arm (via native bridge).
|
||||
module {
|
||||
name: "bar",
|
||||
native_bridge_supported: true,
|
||||
}
|
||||
|
||||
// This module is enabled for arm (native_bridge) only.
|
||||
module {
|
||||
name: "baz",
|
||||
native_bridge_supported: true,
|
||||
enabled: false,
|
||||
target: {
|
||||
native_bridge: {
|
||||
enabled: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
config func(Config)
|
||||
fooVariants []string
|
||||
barVariants []string
|
||||
bazVariants []string
|
||||
}{
|
||||
{
|
||||
name: "normal",
|
||||
config: nil,
|
||||
fooVariants: []string{"android_x86_64_silvermont", "android_x86_silvermont"},
|
||||
barVariants: []string{"android_x86_64_silvermont", "android_native_bridge_arm64_armv8-a", "android_x86_silvermont", "android_native_bridge_arm_armv7-a-neon"},
|
||||
bazVariants: []string{"android_native_bridge_arm64_armv8-a", "android_native_bridge_arm_armv7-a-neon"},
|
||||
},
|
||||
}
|
||||
|
||||
enabledVariants := func(ctx *TestContext, name string) []string {
|
||||
var ret []string
|
||||
variants := ctx.ModuleVariantsForTests(name)
|
||||
for _, variant := range variants {
|
||||
m := ctx.ModuleForTests(name, variant)
|
||||
if m.Module().Enabled() {
|
||||
ret = append(ret, variant)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
config := TestArchConfigNativeBridge(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx.RegisterModuleType("module", archTestModuleFactory)
|
||||
ctx.Register(config)
|
||||
if tt.config != nil {
|
||||
tt.config(config)
|
||||
}
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
FailIfErrored(t, errs)
|
||||
|
||||
if g, w := enabledVariants(ctx, "foo"), tt.fooVariants; !reflect.DeepEqual(w, g) {
|
||||
t.Errorf("want foo variants:\n%q\ngot:\n%q\n", w, g)
|
||||
}
|
||||
|
||||
if g, w := enabledVariants(ctx, "bar"), tt.barVariants; !reflect.DeepEqual(w, g) {
|
||||
t.Errorf("want bar variants:\n%q\ngot:\n%q\n", w, g)
|
||||
}
|
||||
|
||||
if g, w := enabledVariants(ctx, "baz"), tt.bazVariants; !reflect.DeepEqual(w, g) {
|
||||
t.Errorf("want qux variants:\n%q\ngot:\n%q\n", w, g)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue