Merge "Convert shared customizer functions to return FixturePreparers" am: 7ba0448314 am: 47e8b9af4e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1647197

Change-Id: I3b9cf01007f3cd29bb0e8a363330d3e4ddb960cf
This commit is contained in:
Paul Duffin 2021-03-22 09:15:07 +00:00 committed by Automerger Merge Worker
commit 85ca23b70e

View file

@ -70,20 +70,16 @@ func testApex(t *testing.T, bp string, handlers ...interface{}) *android.TestCon
// deprecated
type testCustomizer func(fs map[string][]byte, config android.Config)
func withFiles(files map[string][]byte) testCustomizer {
return func(fs map[string][]byte, config android.Config) {
for k, v := range files {
fs[k] = v
}
}
func withFiles(files android.MockFS) android.FixturePreparer {
return files.AddToFixture()
}
func withTargets(targets map[android.OsType][]android.Target) testCustomizer {
return func(fs map[string][]byte, config android.Config) {
func withTargets(targets map[android.OsType][]android.Target) android.FixturePreparer {
return android.FixtureModifyConfig(func(config android.Config) {
for k, v := range targets {
config.Targets[k] = v
}
}
})
}
// withNativeBridgeTargets sets configuration with targets including:
@ -91,32 +87,38 @@ func withTargets(targets map[android.OsType][]android.Target) testCustomizer {
// - X86 (secondary)
// - Arm64 on X86_64 (native bridge)
// - Arm on X86 (native bridge)
func withNativeBridgeEnabled(_ map[string][]byte, config android.Config) {
config.Targets[android.Android] = []android.Target{
{Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}},
NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""},
{Os: android.Android, Arch: android.Arch{ArchType: android.X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}},
NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""},
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}},
NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86_64", NativeBridgeRelativePath: "arm64"},
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}},
NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86", NativeBridgeRelativePath: "arm"},
}
var withNativeBridgeEnabled = android.FixtureModifyConfig(
func(config android.Config) {
config.Targets[android.Android] = []android.Target{
{Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}},
NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""},
{Os: android.Android, Arch: android.Arch{ArchType: android.X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}},
NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""},
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}},
NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86_64", NativeBridgeRelativePath: "arm64"},
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}},
NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86", NativeBridgeRelativePath: "arm"},
}
},
)
func withManifestPackageNameOverrides(specs []string) android.FixturePreparer {
return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.ManifestPackageNameOverrides = specs
})
}
func withManifestPackageNameOverrides(specs []string) testCustomizer {
return func(fs map[string][]byte, config android.Config) {
config.TestProductVariables.ManifestPackageNameOverrides = specs
}
}
var withBinder32bit = android.FixtureModifyProductVariables(
func(variables android.FixtureProductVariables) {
variables.Binder32bit = proptools.BoolPtr(true)
},
)
func withBinder32bit(_ map[string][]byte, config android.Config) {
config.TestProductVariables.Binder32bit = proptools.BoolPtr(true)
}
func withUnbundledBuild(_ map[string][]byte, config android.Config) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
}
var withUnbundledBuild = android.FixtureModifyProductVariables(
func(variables android.FixtureProductVariables) {
variables.Unbundled_build = proptools.BoolPtr(true)
},
)
var emptyFixtureFactory = android.NewFixtureFactory(&buildDir)