Make FirstTarget treat HostCross separately from Host

Use Target.Os and Target.HostCross as the key in FirstTarget so that
it returns a separate target for host and host cross architectures.
This is useful when host and host cross are both linux_musl, but
host cross is an independenct architecture like arm64.

Also filter the targets returned by ctx.MultiTargets() to match
the HostCross value of ctx.Target() to prevent the newly created
HostCross variants from colliding with Host variants in JNI or
test data attached to Java targets using a common arch.

This relands If75790001afe9d0f9d4d8166f207847851812297 with the
addition of the ctx.MultiTargets() filtering.

Bug: 236052820
Test: TestArchMutator
Change-Id: Ia6fe1185915d174d0ad6b401c227e0e57bee5c24
This commit is contained in:
Colin Cross
2022-07-19 14:41:11 -07:00
parent 852d0c4859
commit c0f0eb86db
3 changed files with 152 additions and 24 deletions

View File

@@ -118,6 +118,11 @@ func modifyTestConfigForMusl(config Config) {
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
}
func modifyTestConfigForMuslArm64HostCross(config Config) {
config.Targets[LinuxMusl] = append(config.Targets[LinuxMusl],
Target{config.BuildOS, Arch{ArchType: Arm64}, NativeBridgeDisabled, "", "", true})
}
// TestArchConfig returns a Config object suitable for using for tests that
// need to run the arch mutator.
func TestArchConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) Config {