Merge changes I7e9440a0,I7f1a4b64,If5d6fdac
* changes: Dedup cc prebuilts module type registration Detect registration of duplicate module/singleton types Dedup prebuilt apis module type/mutator registration
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,6 +124,7 @@ func ModuleTypeFactories() map[string]ModuleFactory {
|
|||||||
type RegistrationContext interface {
|
type RegistrationContext interface {
|
||||||
RegisterModuleType(name string, factory ModuleFactory)
|
RegisterModuleType(name string, factory ModuleFactory)
|
||||||
RegisterSingletonType(name string, factory SingletonFactory)
|
RegisterSingletonType(name string, factory SingletonFactory)
|
||||||
|
PreArchMutators(f RegisterMutatorFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to register build components from an init() method, e.g.
|
// Used to register build components from an init() method, e.g.
|
||||||
@@ -140,17 +143,35 @@ type RegistrationContext interface {
|
|||||||
//
|
//
|
||||||
// ctx := android.NewTestContext()
|
// ctx := android.NewTestContext()
|
||||||
// RegisterBuildComponents(ctx)
|
// RegisterBuildComponents(ctx)
|
||||||
var InitRegistrationContext RegistrationContext = initRegistrationContext{}
|
var InitRegistrationContext RegistrationContext = &initRegistrationContext{
|
||||||
|
moduleTypes: make(map[string]ModuleFactory),
|
||||||
|
singletonTypes: make(map[string]SingletonFactory),
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the TestContext implements RegistrationContext.
|
// Make sure the TestContext implements RegistrationContext.
|
||||||
var _ RegistrationContext = (*TestContext)(nil)
|
var _ RegistrationContext = (*TestContext)(nil)
|
||||||
|
|
||||||
type initRegistrationContext struct{}
|
type initRegistrationContext struct {
|
||||||
|
moduleTypes map[string]ModuleFactory
|
||||||
|
singletonTypes map[string]SingletonFactory
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx initRegistrationContext) RegisterModuleType(name string, factory ModuleFactory) {
|
func (ctx *initRegistrationContext) RegisterModuleType(name string, factory ModuleFactory) {
|
||||||
|
if _, present := ctx.moduleTypes[name]; present {
|
||||||
|
panic(fmt.Sprintf("module type %q is already registered", name))
|
||||||
|
}
|
||||||
|
ctx.moduleTypes[name] = factory
|
||||||
RegisterModuleType(name, factory)
|
RegisterModuleType(name, factory)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {
|
func (ctx *initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {
|
||||||
|
if _, present := ctx.singletonTypes[name]; present {
|
||||||
|
panic(fmt.Sprintf("singleton type %q is already registered", name))
|
||||||
|
}
|
||||||
|
ctx.singletonTypes[name] = factory
|
||||||
RegisterSingletonType(name, factory)
|
RegisterSingletonType(name, factory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
|
||||||
|
PreArchMutators(f)
|
||||||
|
}
|
||||||
|
@@ -289,8 +289,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||||
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
||||||
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_shared", cc.PrebuiltSharedLibraryFactory)
|
cc.RegisterPrebuiltBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_static", cc.PrebuiltStaticLibraryFactory)
|
|
||||||
ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
|
ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
|
||||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_defaults", func() android.Module {
|
ctx.RegisterModuleType("cc_defaults", func() android.Module {
|
||||||
|
@@ -19,9 +19,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
RegisterPrebuiltBuildComponents(android.InitRegistrationContext)
|
||||||
android.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
}
|
||||||
android.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
|
||||||
|
func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
||||||
|
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
||||||
|
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
type prebuiltLinkerInterface interface {
|
type prebuiltLinkerInterface interface {
|
||||||
|
@@ -72,9 +72,7 @@ func TestPrebuilt(t *testing.T) {
|
|||||||
|
|
||||||
ctx := CreateTestContext()
|
ctx := CreateTestContext()
|
||||||
|
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
RegisterPrebuiltBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
|
||||||
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
|
||||||
|
|
||||||
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
|
||||||
ctx.PostDepsMutators(android.RegisterPrebuiltsPostDepsMutators)
|
ctx.PostDepsMutators(android.RegisterPrebuiltsPostDepsMutators)
|
||||||
|
@@ -74,13 +74,12 @@ func testContext() *android.TestContext {
|
|||||||
RegisterDocsBuildComponents(ctx)
|
RegisterDocsBuildComponents(ctx)
|
||||||
RegisterStubsBuildComponents(ctx)
|
RegisterStubsBuildComponents(ctx)
|
||||||
RegisterSdkLibraryBuildComponents(ctx)
|
RegisterSdkLibraryBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
|
|
||||||
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
|
||||||
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
|
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
|
|
||||||
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
|
RegisterPrebuiltApisBuildComponents(ctx)
|
||||||
})
|
|
||||||
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
||||||
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
|
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
|
||||||
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
|
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
|
||||||
|
@@ -23,9 +23,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
|
RegisterPrebuiltApisBuildComponents(android.InitRegistrationContext)
|
||||||
|
}
|
||||||
|
|
||||||
android.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
|
func RegisterPrebuiltApisBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
|
||||||
|
|
||||||
|
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
|
||||||
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
|
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -87,8 +87,7 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||||||
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
|
||||||
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
|
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
|
||||||
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_shared", cc.PrebuiltSharedLibraryFactory)
|
cc.RegisterPrebuiltBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_static", cc.PrebuiltStaticLibraryFactory)
|
|
||||||
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
|
||||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||||
|
Reference in New Issue
Block a user