Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03b717d3 authored by Ivan Lozano's avatar Ivan Lozano
Browse files

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
parent c7eafa7a
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import (
	"fmt"
	"reflect"
	"runtime"
	"slices"
	"strings"

	"github.com/google/blueprint"
@@ -592,26 +593,16 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
	// Filter NativeBridge targets unless they are explicitly supported.
	// Skip creating native bridge variants for non-core modules.
	if os == Android && !(base.IsNativeBridgeSupported() && image == CoreVariation) {

		var targets []Target
		for _, t := range osTargets {
			if !t.NativeBridge {
				targets = append(targets, t)
			}
		}

		osTargets = targets
		osTargets = slices.DeleteFunc(slices.Clone(osTargets), func(t Target) bool {
			return bool(t.NativeBridge)
		})
	}

	// Filter HostCross targets if disabled.
	if base.HostSupported() && !base.HostCrossSupported() {
		var targets []Target
		for _, t := range osTargets {
			if !t.HostCross {
				targets = append(targets, t)
			}
		}
		osTargets = targets
		osTargets = slices.DeleteFunc(slices.Clone(osTargets), func(t Target) bool {
			return t.HostCross
		})
	}

	// only the primary arch in the ramdisk / vendor_ramdisk / recovery partition