diff --git a/Android.bp b/Android.bp index 0202ea7fc..0ba669ca9 100644 --- a/Android.bp +++ b/Android.bp @@ -45,7 +45,6 @@ bootstrap_go_package { ], srcs: [ "doc.go", - "register.go", ], } @@ -73,6 +72,7 @@ bootstrap_go_package { "android/onceper.go", "android/package_ctx.go", "android/paths.go", + "android/register.go", "android/util.go", "android/variable.go", diff --git a/android/androidmk.go b/android/androidmk.go index a40893395..28c229039 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -24,14 +24,12 @@ import ( "sort" "strings" - "android/soong" - "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) func init() { - soong.RegisterSingletonType("androidmk", AndroidMkSingleton) + RegisterSingletonType("androidmk", AndroidMkSingleton) } type AndroidMkDataProvider interface { diff --git a/android/env.go b/android/env.go index f9d8030a8..3b523a2f4 100644 --- a/android/env.go +++ b/android/env.go @@ -15,7 +15,6 @@ package android import ( - "android/soong" "android/soong/env" "github.com/google/blueprint" @@ -29,7 +28,7 @@ import ( // a manifest regeneration. func init() { - soong.RegisterSingletonType("env", EnvSingleton) + RegisterSingletonType("env", EnvSingleton) } func EnvSingleton() blueprint.Singleton { diff --git a/android/makevars.go b/android/makevars.go index e431f116a..482fbdea7 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -20,8 +20,6 @@ import ( "io/ioutil" "os" - "android/soong" - "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -66,7 +64,7 @@ func RegisterMakeVarsProvider(pctx blueprint.PackageContext, provider MakeVarsPr /////////////////////////////////////////////////////////////////////////////// func init() { - soong.RegisterSingletonType("makevars", makeVarsSingletonFunc) + RegisterSingletonType("makevars", makeVarsSingletonFunc) } func makeVarsSingletonFunc() blueprint.Singleton { diff --git a/android/module.go b/android/module.go index 00219aec6..d6eee4468 100644 --- a/android/module.go +++ b/android/module.go @@ -19,7 +19,6 @@ import ( "path/filepath" "strings" - "android/soong" "android/soong/glob" "github.com/google/blueprint" @@ -710,7 +709,7 @@ func (ctx *androidModuleContext) Glob(outDir, globPattern string, excludes []str } func init() { - soong.RegisterSingletonType("buildtarget", BuildTargetSingleton) + RegisterSingletonType("buildtarget", BuildTargetSingleton) } func BuildTargetSingleton() blueprint.Singleton { diff --git a/android/mutator.go b/android/mutator.go index 3d5a17723..ff2f9ad40 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -14,11 +14,7 @@ package android -import ( - "android/soong" - - "github.com/google/blueprint" -) +import "github.com/google/blueprint" type AndroidTopDownMutator func(TopDownMutatorContext) @@ -44,26 +40,41 @@ type androidBottomUpMutatorContext struct { androidBaseContextImpl } -func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) soong.MutatorHandle { - return soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) { +func RegisterBottomUpMutator(name string, m AndroidBottomUpMutator) MutatorHandle { + f := func(ctx blueprint.BottomUpMutatorContext) { if a, ok := ctx.Module().(Module); ok { actx := &androidBottomUpMutatorContext{ BottomUpMutatorContext: ctx, androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), } - mutator(actx) + m(actx) } - }) + } + mutator := &mutator{name: name, bottomUpMutator: f} + mutators = append(mutators, mutator) + return mutator } -func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) soong.MutatorHandle { - return soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) { +func RegisterTopDownMutator(name string, m AndroidTopDownMutator) MutatorHandle { + f := func(ctx blueprint.TopDownMutatorContext) { if a, ok := ctx.Module().(Module); ok { actx := &androidTopDownMutatorContext{ TopDownMutatorContext: ctx, androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), } - mutator(actx) + m(actx) } - }) + } + mutator := &mutator{name: name, topDownMutator: f} + mutators = append(mutators, mutator) + return mutator +} + +type MutatorHandle interface { + Parallel() MutatorHandle +} + +func (mutator *mutator) Parallel() MutatorHandle { + mutator.parallel = true + return mutator } diff --git a/register.go b/android/register.go similarity index 77% rename from register.go rename to android/register.go index 2a1bd91ce..7cc9d50ee 100644 --- a/register.go +++ b/android/register.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package soong +package android import "github.com/google/blueprint" @@ -47,27 +47,6 @@ func RegisterSingletonType(name string, factory blueprint.SingletonFactory) { singletons = append(singletons, singleton{name, factory}) } -func RegisterBottomUpMutator(name string, m blueprint.BottomUpMutator) MutatorHandle { - mutator := &mutator{name: name, bottomUpMutator: m} - mutators = append(mutators, mutator) - return mutator -} - -func RegisterTopDownMutator(name string, m blueprint.TopDownMutator) MutatorHandle { - mutator := &mutator{name: name, topDownMutator: m} - mutators = append(mutators, mutator) - return mutator -} - -type MutatorHandle interface { - Parallel() MutatorHandle -} - -func (mutator *mutator) Parallel() MutatorHandle { - mutator.parallel = true - return mutator -} - func NewContext() *blueprint.Context { ctx := blueprint.NewContext() diff --git a/cc/binary.go b/cc/binary.go index 083cf0d08..0965886ff 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -18,7 +18,6 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/proptools" - "android/soong" "android/soong/android" ) @@ -42,8 +41,8 @@ type BinaryLinkerProperties struct { } func init() { - soong.RegisterModuleType("cc_binary", binaryFactory) - soong.RegisterModuleType("cc_binary_host", binaryHostFactory) + android.RegisterModuleType("cc_binary", binaryFactory) + android.RegisterModuleType("cc_binary_host", binaryHostFactory) } // Module factory for binaries diff --git a/cc/cc.go b/cc/cc.go index 75292aa73..791d9ea7e 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -26,14 +26,13 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/proptools" - "android/soong" "android/soong/android" "android/soong/cc/config" "android/soong/genrule" ) func init() { - soong.RegisterModuleType("cc_defaults", defaultsFactory) + android.RegisterModuleType("cc_defaults", defaultsFactory) // LinkageMutator must be registered after common.ArchMutator, but that is guaranteed by // the Go initialization order because this package depends on common, so common's init diff --git a/cc/library.go b/cc/library.go index 2c5f22f9c..cb4dc61e3 100644 --- a/cc/library.go +++ b/cc/library.go @@ -20,7 +20,6 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/pathtools" - "android/soong" "android/soong/android" ) @@ -77,11 +76,11 @@ type FlagExporterProperties struct { } func init() { - soong.RegisterModuleType("cc_library_static", libraryStaticFactory) - soong.RegisterModuleType("cc_library_shared", librarySharedFactory) - soong.RegisterModuleType("cc_library", libraryFactory) - soong.RegisterModuleType("cc_library_host_static", libraryHostStaticFactory) - soong.RegisterModuleType("cc_library_host_shared", libraryHostSharedFactory) + android.RegisterModuleType("cc_library_static", libraryStaticFactory) + android.RegisterModuleType("cc_library_shared", librarySharedFactory) + android.RegisterModuleType("cc_library", libraryFactory) + android.RegisterModuleType("cc_library_host_static", libraryHostStaticFactory) + android.RegisterModuleType("cc_library_host_shared", libraryHostSharedFactory) } // Module factory for combined static + shared libraries, device by default but with possible host diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go index 407a026aa..106c9b51f 100644 --- a/cc/ndk_prebuilt.go +++ b/cc/ndk_prebuilt.go @@ -20,16 +20,15 @@ import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" "android/soong/cc/config" ) func init() { - soong.RegisterModuleType("ndk_prebuilt_library", ndkPrebuiltLibraryFactory) - soong.RegisterModuleType("ndk_prebuilt_object", ndkPrebuiltObjectFactory) - soong.RegisterModuleType("ndk_prebuilt_static_stl", ndkPrebuiltStaticStlFactory) - soong.RegisterModuleType("ndk_prebuilt_shared_stl", ndkPrebuiltSharedStlFactory) + android.RegisterModuleType("ndk_prebuilt_library", ndkPrebuiltLibraryFactory) + android.RegisterModuleType("ndk_prebuilt_object", ndkPrebuiltObjectFactory) + android.RegisterModuleType("ndk_prebuilt_static_stl", ndkPrebuiltStaticStlFactory) + android.RegisterModuleType("ndk_prebuilt_shared_stl", ndkPrebuiltSharedStlFactory) } // NDK prebuilt libraries. diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index 144d91c26..cbdaa266c 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go @@ -55,14 +55,13 @@ package cc import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" ) func init() { - soong.RegisterModuleType("ndk_headers", ndkHeadersFactory) - soong.RegisterModuleType("ndk_library", ndkLibraryFactory) - soong.RegisterSingletonType("ndk", NdkSingleton) + android.RegisterModuleType("ndk_headers", ndkHeadersFactory) + android.RegisterModuleType("ndk_library", ndkLibraryFactory) + android.RegisterSingletonType("ndk", NdkSingleton) pctx.Import("android/soong/common") } diff --git a/cc/object.go b/cc/object.go index c9f0a060a..72fd55bd5 100644 --- a/cc/object.go +++ b/cc/object.go @@ -19,7 +19,6 @@ import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" ) @@ -28,7 +27,7 @@ import ( // func init() { - soong.RegisterModuleType("cc_object", objectFactory) + android.RegisterModuleType("cc_object", objectFactory) } type objectLinker struct { diff --git a/cc/test.go b/cc/test.go index 9c7c0de4a..9cc30c91a 100644 --- a/cc/test.go +++ b/cc/test.go @@ -21,7 +21,6 @@ import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" ) @@ -37,11 +36,11 @@ type TestBinaryProperties struct { } func init() { - soong.RegisterModuleType("cc_test", testFactory) - soong.RegisterModuleType("cc_test_library", testLibraryFactory) - soong.RegisterModuleType("cc_benchmark", benchmarkFactory) - soong.RegisterModuleType("cc_test_host", testHostFactory) - soong.RegisterModuleType("cc_benchmark_host", benchmarkHostFactory) + android.RegisterModuleType("cc_test", testFactory) + android.RegisterModuleType("cc_test_library", testLibraryFactory) + android.RegisterModuleType("cc_benchmark", benchmarkFactory) + android.RegisterModuleType("cc_test_host", testHostFactory) + android.RegisterModuleType("cc_benchmark_host", benchmarkHostFactory) } // Module factory for tests diff --git a/cc/toolchain_library.go b/cc/toolchain_library.go index 0548da984..0097ca3ef 100644 --- a/cc/toolchain_library.go +++ b/cc/toolchain_library.go @@ -18,7 +18,6 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/proptools" - "android/soong" "android/soong/android" ) @@ -27,7 +26,7 @@ import ( // func init() { - soong.RegisterModuleType("toolchain_library", toolchainLibraryFactory) + android.RegisterModuleType("toolchain_library", toolchainLibraryFactory) } type toolchainLibraryDecorator struct { diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 5b0c83cbb..ed8f2fd58 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -22,8 +22,6 @@ import ( "github.com/google/blueprint/bootstrap" - "android/soong" - "android/soong/android" ) @@ -33,7 +31,7 @@ func main() { // The top-level Blueprints file is passed as the first argument. srcDir := filepath.Dir(flag.Arg(0)) - ctx := soong.NewContext() + ctx := android.NewContext() configuration, err := android.NewConfig(srcDir, bootstrap.BuildDir) if err != nil { diff --git a/genrule/genrule.go b/genrule/genrule.go index 4a9b336d1..baa6b335b 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -19,13 +19,12 @@ import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" ) func init() { - soong.RegisterModuleType("gensrcs", GenSrcsFactory) - soong.RegisterModuleType("genrule", GenRuleFactory) + android.RegisterModuleType("gensrcs", GenSrcsFactory) + android.RegisterModuleType("genrule", GenRuleFactory) android.RegisterBottomUpMutator("genrule_deps", genruleDepsMutator).Parallel() } diff --git a/java/java.go b/java/java.go index 315ee499b..808e1db32 100644 --- a/java/java.go +++ b/java/java.go @@ -24,22 +24,21 @@ import ( "github.com/google/blueprint" - "android/soong" "android/soong/android" "android/soong/genrule" ) func init() { - soong.RegisterModuleType("java_library", JavaLibraryFactory) - soong.RegisterModuleType("java_library_static", JavaLibraryFactory) - soong.RegisterModuleType("java_library_host", JavaLibraryHostFactory) - soong.RegisterModuleType("java_binary", JavaBinaryFactory) - soong.RegisterModuleType("java_binary_host", JavaBinaryHostFactory) - soong.RegisterModuleType("prebuilt_java_library", JavaPrebuiltFactory) - soong.RegisterModuleType("prebuilt_sdk", SdkPrebuiltFactory) - soong.RegisterModuleType("android_app", AndroidAppFactory) + android.RegisterModuleType("java_library", JavaLibraryFactory) + android.RegisterModuleType("java_library_static", JavaLibraryFactory) + android.RegisterModuleType("java_library_host", JavaLibraryHostFactory) + android.RegisterModuleType("java_binary", JavaBinaryFactory) + android.RegisterModuleType("java_binary_host", JavaBinaryHostFactory) + android.RegisterModuleType("prebuilt_java_library", JavaPrebuiltFactory) + android.RegisterModuleType("prebuilt_sdk", SdkPrebuiltFactory) + android.RegisterModuleType("android_app", AndroidAppFactory) - soong.RegisterSingletonType("logtags", LogtagsSingleton) + android.RegisterSingletonType("logtags", LogtagsSingleton) } // TODO: