Dedup registration for cc default test config
The cc.GatherRequiredDepsForTest() method returns some default module definitions that are required when using cc module types like cc_library. Previously, the registration of the module types and mutators needed to process those default definitions was duplicated in the test config initialization. This change removes that duplicated code and replaces it with calls to cc.RegisterRequiredBuildComponentsForTest(ctx) which registers all the required build components. Test: m checkbuild Bug: 146540677 Change-Id: I80b6913c5691ff164ce9d308b9e1da24940f2d42
This commit is contained in:
parent
2ccaffd1d7
commit
77980a8bb9
6 changed files with 24 additions and 135 deletions
|
@ -286,20 +286,17 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||
ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
|
||||
ctx.RegisterModuleType("override_apex", overrideApexFactory)
|
||||
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
||||
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
||||
cc.RegisterPrebuiltBuildComponents(ctx)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
|
||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||
ctx.RegisterModuleType("cc_defaults", func() android.Module {
|
||||
return cc.DefaultsFactory()
|
||||
})
|
||||
ctx.RegisterModuleType("cc_test", cc.TestFactory)
|
||||
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
|
||||
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
|
||||
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
|
@ -311,13 +308,6 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
|
||||
})
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
|
||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
|
||||
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
})
|
||||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
|
|
@ -18,6 +18,23 @@ import (
|
|||
"android/soong/android"
|
||||
)
|
||||
|
||||
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
||||
ctx.RegisterModuleType("cc_library", LibraryFactory)
|
||||
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
||||
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
||||
ctx.BottomUp("link", LinkageMutator).Parallel()
|
||||
ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
|
||||
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
||||
ctx.BottomUp("version", VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", BeginMutator).Parallel()
|
||||
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
|
||||
})
|
||||
}
|
||||
|
||||
func GatherRequiredDepsForTest(os android.OsType) string {
|
||||
ret := `
|
||||
toolchain_library {
|
||||
|
@ -289,26 +306,17 @@ func CreateTestContext() *android.TestContext {
|
|||
ctx.RegisterModuleType("cc_binary", BinaryFactory)
|
||||
ctx.RegisterModuleType("cc_binary_host", binaryHostFactory)
|
||||
ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
|
||||
ctx.RegisterModuleType("cc_library", LibraryFactory)
|
||||
ctx.RegisterModuleType("cc_library_shared", LibrarySharedFactory)
|
||||
ctx.RegisterModuleType("cc_library_static", LibraryStaticFactory)
|
||||
ctx.RegisterModuleType("cc_library_headers", LibraryHeaderFactory)
|
||||
ctx.RegisterModuleType("cc_test", TestFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
||||
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
|
||||
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
||||
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
||||
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("link", LinkageMutator).Parallel()
|
||||
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
||||
ctx.BottomUp("version", VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", BeginMutator).Parallel()
|
||||
})
|
||||
RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
|
||||
})
|
||||
|
|
|
@ -85,15 +85,8 @@ func testContext() *android.TestContext {
|
|||
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
|
||||
|
||||
// Register module types and mutators from cc needed for JNI testing
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
})
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
|
@ -75,97 +75,19 @@ func GatherRequiredDepsForTest() string {
|
|||
//////////////////////////////
|
||||
// Device module requirements
|
||||
|
||||
toolchain_library {
|
||||
name: "libgcc",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
src: "",
|
||||
system_shared_libs: [],
|
||||
}
|
||||
cc_library {
|
||||
name: "libc",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
cc_library {
|
||||
name: "libm",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
cc_library {
|
||||
name: "libdl",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
cc_object {
|
||||
name: "crtbegin_dynamic",
|
||||
}
|
||||
|
||||
cc_object {
|
||||
name: "crtend_android",
|
||||
}
|
||||
cc_library {
|
||||
name: "liblog",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// cc module requirements
|
||||
|
||||
toolchain_library {
|
||||
name: "libatomic",
|
||||
src: "",
|
||||
}
|
||||
toolchain_library {
|
||||
name: "libclang_rt.builtins-aarch64-android",
|
||||
src: "",
|
||||
}
|
||||
toolchain_library {
|
||||
name: "libgcc_stripped",
|
||||
src: "",
|
||||
}
|
||||
cc_library {
|
||||
name: "libc++_static",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
cc_library {
|
||||
name: "libc++demangle",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
host_supported: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "libc++",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
cc_library {
|
||||
name: "libunwind_llvm",
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
`
|
||||
` + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
return bp
|
||||
}
|
||||
|
||||
func CreateTestContext() *android.TestContext {
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
|
||||
ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
|
||||
ctx.RegisterModuleType("rust_test", RustTestFactory)
|
||||
|
@ -182,13 +104,7 @@ func CreateTestContext() *android.TestContext {
|
|||
ctx.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
|
||||
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
|
||||
ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
// cc mutators
|
||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
|
||||
// rust mutators
|
||||
ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
|
||||
ctx.BottomUp("rust_unit_tests", TestPerSrcMutator).Parallel()
|
||||
|
|
|
@ -83,20 +83,10 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||
java.RegisterStubsBuildComponents(ctx)
|
||||
|
||||
// from cc package
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
||||
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
|
||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||
cc.RegisterPrebuiltBuildComponents(ctx)
|
||||
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
|
||||
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
|
||||
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
})
|
||||
|
||||
// from apex package
|
||||
ctx.RegisterModuleType("apex", apex.BundleFactory)
|
||||
|
|
|
@ -67,18 +67,10 @@ func testContext(config android.Config) *android.TestContext {
|
|||
ctx.BottomUp("sysprop_deps", syspropDepsMutator).Parallel()
|
||||
})
|
||||
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
||||
ctx.RegisterModuleType("cc_library_static", cc.LibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
|
||||
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
ctx.BottomUp("sysprop_cc", cc.SyspropMutator).Parallel()
|
||||
ctx.BottomUp("sysprop_java", java.SyspropMutator).Parallel()
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue