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

Commit fb0c16e9 authored by Colin Cross's avatar Colin Cross
Browse files

Move imageMutator before archMutator

Run the imageMutator between osMutator and archMutator so that
different arch variants can be set for the different partitions.

Bug: 142286466
Test: m checkbuild
Change-Id: I65d05714b75aa462bf9816da60fdc2deda4de593
Merged-In: I65d05714b75aa462bf9816da60fdc2deda4de593
(cherry picked from commit 9c8f6875)
parent bd062430
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -822,7 +822,7 @@ func archMutator(mctx BottomUpMutatorContext) {

	os := base.commonProperties.CompileOS
	osTargets := mctx.Config().Targets[os]

	image := base.commonProperties.ImageVariation
	// Filter NativeBridge targets unless they are explicitly supported
	if os == Android && !Bool(base.commonProperties.Native_bridge_supported) {
		var targets []Target
@@ -859,6 +859,12 @@ func archMutator(mctx BottomUpMutatorContext) {
		}
	}

	if image == RecoveryVariation {
		primaryArch := mctx.Config().DevicePrimaryArchType()
		targets = filterToArch(targets, primaryArch)
		multiTargets = filterToArch(multiTargets, primaryArch)
	}

	if len(targets) == 0 {
		base.commonProperties.Enabled = boolPtr(false)
		return
@@ -907,6 +913,16 @@ func decodeMultilib(base *ModuleBase, class OsClass) (multilib, extraMultilib st
	}
}

func filterToArch(targets []Target, arch ArchType) []Target {
	for i := 0; i < len(targets); i++ {
		if targets[i].Arch.ArchType != arch {
			targets = append(targets[:i], targets[i+1:]...)
			i--
		}
	}
	return targets
}

// createArchType takes a reflect.Type that is either a struct or a pointer to a struct, and returns a list of
// reflect.Type that contains the arch-variant properties inside structs for each architecture, os, target, multilib,
// etc.
+8 −6
Original line number Diff line number Diff line
@@ -1005,6 +1005,7 @@ func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
	return baseModuleContext{
		BaseModuleContext: ctx,
		os:                m.commonProperties.CompileOS,
		target:            m.commonProperties.CompileTarget,
		targetPrimary:     m.commonProperties.CompilePrimary,
		multiTargets:      m.commonProperties.CompileMultiTargets,
@@ -1117,6 +1118,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)

type baseModuleContext struct {
	blueprint.BaseModuleContext
	os            OsType
	target        Target
	multiTargets  []Target
	targetPrimary bool
@@ -1460,27 +1462,27 @@ func (b *baseModuleContext) Arch() Arch {
}

func (b *baseModuleContext) Os() OsType {
	return b.target.Os
	return b.os
}

func (b *baseModuleContext) Host() bool {
	return b.target.Os.Class == Host || b.target.Os.Class == HostCross
	return b.os.Class == Host || b.os.Class == HostCross
}

func (b *baseModuleContext) Device() bool {
	return b.target.Os.Class == Device
	return b.os.Class == Device
}

func (b *baseModuleContext) Darwin() bool {
	return b.target.Os == Darwin
	return b.os == Darwin
}

func (b *baseModuleContext) Fuchsia() bool {
	return b.target.Os == Fuchsia
	return b.os == Fuchsia
}

func (b *baseModuleContext) Windows() bool {
	return b.target.Os == Windows
	return b.os == Windows
}

func (b *baseModuleContext) Debug() bool {
+1 −1
Original line number Diff line number Diff line
@@ -87,9 +87,9 @@ var preArch = []RegisterMutatorFunc{

func registerArchMutator(ctx RegisterMutatorsContext) {
	ctx.BottomUp("os", osMutator).Parallel()
	ctx.BottomUp("image", imageMutator).Parallel()
	ctx.BottomUp("arch", archMutator).Parallel()
	ctx.TopDown("arch_hooks", archHookMutator).Parallel()
	ctx.BottomUp("image", imageMutator).Parallel()
}

var preDeps = []RegisterMutatorFunc{
+24 −0
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "host binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     hostTarget.Os,
					target: hostTarget,
				},
			},
@@ -268,6 +269,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "system binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
			},
@@ -278,6 +280,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "vendor binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   socSpecificModule,
				},
@@ -289,6 +292,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "odm binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   deviceSpecificModule,
				},
@@ -300,6 +304,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "product binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   productSpecificModule,
				},
@@ -311,6 +316,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "system_ext binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   systemExtSpecificModule,
				},
@@ -322,6 +328,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "root binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inRoot: true,
@@ -333,6 +340,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "recovery binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inRecovery: true,
@@ -344,6 +352,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "recovery root binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inRecovery: true,
@@ -357,6 +366,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "system native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inData: true,
@@ -368,6 +378,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "vendor native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   socSpecificModule,
				},
@@ -380,6 +391,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "odm native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   deviceSpecificModule,
				},
@@ -392,6 +404,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "product native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   productSpecificModule,
				},
@@ -405,6 +418,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "system_ext native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   systemExtSpecificModule,
				},
@@ -418,6 +432,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized system binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inSanitizerDir: true,
@@ -429,6 +444,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized vendor binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   socSpecificModule,
				},
@@ -441,6 +457,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized odm binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   deviceSpecificModule,
				},
@@ -453,6 +470,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized product binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   productSpecificModule,
				},
@@ -466,6 +484,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized system_ext binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   systemExtSpecificModule,
				},
@@ -479,6 +498,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized system native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
				},
				inData:         true,
@@ -491,6 +511,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized vendor native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   socSpecificModule,
				},
@@ -504,6 +525,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized odm native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   deviceSpecificModule,
				},
@@ -517,6 +539,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized product native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   productSpecificModule,
				},
@@ -530,6 +553,7 @@ func TestPathForModuleInstall(t *testing.T) {
			name: "sanitized system_ext native test binary",
			ctx: &moduleInstallPathContextImpl{
				baseModuleContext: baseModuleContext{
					os:     deviceTarget.Os,
					target: deviceTarget,
					kind:   systemExtSpecificModule,
				},
+2 −2
Original line number Diff line number Diff line
@@ -1097,8 +1097,8 @@ func TestUseVendor(t *testing.T) {
	inputsString := strings.Join(inputsList, " ")

	// ensure that the apex includes vendor variants of the direct and indirect deps
	ensureContains(t, inputsString, "android_arm64_armv8-a_vendor.VER_shared_myapex/mylib.so")
	ensureContains(t, inputsString, "android_arm64_armv8-a_vendor.VER_shared_myapex/mylib2.so")
	ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_myapex/mylib.so")
	ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_myapex/mylib2.so")

	// ensure that the apex does not include core variants
	ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_myapex/mylib.so")
Loading