android: Use slices.DeleteFunc for filtering

Clean-up two filters in arch.go by using slices.DeleteFunc

Bug: 353739440
Test: m blueprint_tests
Change-Id: I3738bb7961830e2c287257cceb64194f048514d3
This commit is contained in:
Ivan Lozano
2024-07-18 15:13:50 +00:00
parent c7eafa7a41
commit 03b717d3f1

View File

@@ -19,6 +19,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"runtime" "runtime"
"slices"
"strings" "strings"
"github.com/google/blueprint" "github.com/google/blueprint"
@@ -592,26 +593,16 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
// Filter NativeBridge targets unless they are explicitly supported. // Filter NativeBridge targets unless they are explicitly supported.
// Skip creating native bridge variants for non-core modules. // Skip creating native bridge variants for non-core modules.
if os == Android && !(base.IsNativeBridgeSupported() && image == CoreVariation) { if os == Android && !(base.IsNativeBridgeSupported() && image == CoreVariation) {
osTargets = slices.DeleteFunc(slices.Clone(osTargets), func(t Target) bool {
var targets []Target return bool(t.NativeBridge)
for _, t := range osTargets { })
if !t.NativeBridge {
targets = append(targets, t)
}
}
osTargets = targets
} }
// Filter HostCross targets if disabled. // Filter HostCross targets if disabled.
if base.HostSupported() && !base.HostCrossSupported() { if base.HostSupported() && !base.HostCrossSupported() {
var targets []Target osTargets = slices.DeleteFunc(slices.Clone(osTargets), func(t Target) bool {
for _, t := range osTargets { return t.HostCross
if !t.HostCross { })
targets = append(targets, t)
}
}
osTargets = targets
} }
// only the primary arch in the ramdisk / vendor_ramdisk / recovery partition // only the primary arch in the ramdisk / vendor_ramdisk / recovery partition