Make it possible to specify separate rules for native_bridge case
This change make it possible to specify separate rules for native-bridge case and non-native-bridge case. Bug: http://b/153609531 Test: build 4arch product Change-Id: I60145bbb9c94318f14af3cabd9f5960fc9ee62de Merged-In: I60145bbb9c94318f14af3cabd9f5960fc9ee62de
This commit is contained in:
@@ -1070,6 +1070,7 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
|
|||||||
"Not_windows",
|
"Not_windows",
|
||||||
"Arm_on_x86",
|
"Arm_on_x86",
|
||||||
"Arm_on_x86_64",
|
"Arm_on_x86_64",
|
||||||
|
"Native_bridge",
|
||||||
}
|
}
|
||||||
for _, os := range OsTypeList {
|
for _, os := range OsTypeList {
|
||||||
targets = append(targets, os.Field)
|
targets = append(targets, os.Field)
|
||||||
@@ -1457,6 +1458,11 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
prefix := "target.arm_on_x86_64"
|
prefix := "target.arm_on_x86_64"
|
||||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user