diff options
author | Colin Cross <ccross@android.com> | 2015-06-17 14:20:06 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2015-07-09 17:57:18 -0700 |
commit | 463a90e5872d6c8cf26a2302e7ad1586957304a0 (patch) | |
tree | 3d8001008839eff93d224dc2411be26842a7f9ad | |
parent | 3fde0c220aa0c43ef125f0156d27499622b59b61 (diff) | |
download | build_soong-463a90e5872d6c8cf26a2302e7ad1586957304a0.tar.gz build_soong-463a90e5872d6c8cf26a2302e7ad1586957304a0.tar.bz2 build_soong-463a90e5872d6c8cf26a2302e7ad1586957304a0.zip |
use init functions to register module types, etc.
Instead of putting all the blueprint registrations in soong_build,
put them all in init() functions. This puts the registration next
to the implementation.
Change-Id: Ide1a749518f5e9d1367a18ab3bb1d91da3310c76
-rw-r--r-- | Android.bp | 17 | ||||
-rw-r--r-- | build.ninja.in | 67 | ||||
-rw-r--r-- | cc/cc.go | 29 | ||||
-rw-r--r-- | cmd/soong_build/main.go | 61 | ||||
-rw-r--r-- | common/arch.go | 7 | ||||
-rw-r--r-- | common/env.go | 5 | ||||
-rw-r--r-- | common/module.go | 5 | ||||
-rw-r--r-- | genrule/genrule.go | 6 | ||||
-rw-r--r-- | java/java.go | 14 | ||||
-rw-r--r-- | register.go | 68 |
10 files changed, 205 insertions, 74 deletions
@@ -15,6 +15,7 @@ bootstrap_go_binary { deps: [ "blueprint", "blueprint-bootstrap", + "soong", "soong-art", "soong-cc", "soong-common", @@ -70,11 +71,24 @@ bootstrap_go_package { } bootstrap_go_package { + name: "soong", + pkgPath: "android/soong", + deps: [ + "blueprint", + ], + srcs: [ + "doc.go", + "register.go", + ], +} + +bootstrap_go_package { name: "soong-common", pkgPath: "android/soong/common", deps: [ "blueprint", "blueprint-bootstrap", + "soong", "soong-env", "soong-glob", ], @@ -96,6 +110,7 @@ bootstrap_go_package { deps: [ "blueprint", "blueprint-pathtools", + "soong", "soong-common", "soong-genrule", ], @@ -124,6 +139,7 @@ bootstrap_go_package { deps: [ "blueprint", "blueprint-pathtools", + "soong", "soong-common", ], srcs: [ @@ -144,6 +160,7 @@ bootstrap_go_package { deps: [ "blueprint", "blueprint-pathtools", + "soong", "soong-common", "soong-genrule", ], diff --git a/build.ninja.in b/build.ninja.in index 2e62364a..3bb9559c 100644 --- a/build.ninja.in +++ b/build.ninja.in @@ -63,7 +63,7 @@ rule g.bootstrap.test # Variant: # Type: bootstrap_go_binary # Factory: github.com/google/blueprint/bootstrap.func·003 -# Defined: build/soong/Android.bp:191:1 +# Defined: build/soong/Android.bp:208:1 build .bootstrap/androidbp/test/androidbp.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/androidbp/cmd/androidbp.go $ @@ -130,7 +130,7 @@ default .bootstrap/bin/androidbp # Variant: # Type: bootstrap_go_binary # Factory: github.com/google/blueprint/bootstrap.func·003 -# Defined: build/soong/Android.bp:164:1 +# Defined: build/soong/Android.bp:181:1 build .bootstrap/androidmk/obj/androidmk.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/androidmk/cmd/androidmk/android.go $ @@ -156,7 +156,7 @@ default .bootstrap/bin/androidmk # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:177:1 +# Defined: build/soong/Android.bp:194:1 build .bootstrap/androidmk-parser/test/android/soong/androidmk/parser.a: $ g.bootstrap.gc $ @@ -564,6 +564,24 @@ build .bootstrap/bin/minibp: g.bootstrap.cp .bootstrap/minibp/obj/a.out default .bootstrap/bin/minibp # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: soong +# Variant: +# Type: bootstrap_go_package +# Factory: github.com/google/blueprint/bootstrap.func·002 +# Defined: build/soong/Android.bp:73:1 + +build .bootstrap/soong/pkg/android/soong.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/soong/doc.go $ + ${g.bootstrap.srcDir}/build/soong/register.go | ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a $ + .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ + .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ + .bootstrap/blueprint/pkg/github.com/google/blueprint.a + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg + pkgPath = android/soong +default .bootstrap/soong/pkg/android/soong.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Module: soong-art # Variant: # Type: bootstrap_go_package @@ -576,6 +594,7 @@ build .bootstrap/soong-art/pkg/android/soong/art.a: g.bootstrap.gc $ .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ .bootstrap/blueprint/pkg/github.com/google/blueprint.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ @@ -584,7 +603,7 @@ build .bootstrap/soong-art/pkg/android/soong/art.a: g.bootstrap.gc $ .bootstrap/soong-common/pkg/android/soong/common.a $ .bootstrap/soong-genrule/pkg/android/soong/genrule.a $ .bootstrap/soong-cc/pkg/android/soong/cc.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg -I .bootstrap/soong-cc/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/soong/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg -I .bootstrap/soong-cc/pkg pkgPath = android/soong/art default .bootstrap/soong-art/pkg/android/soong/art.a @@ -593,7 +612,7 @@ default .bootstrap/soong-art/pkg/android/soong/art.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:93:1 +# Defined: build/soong/Android.bp:107:1 build .bootstrap/soong-cc/test/android/soong/cc.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/cc/builder.go $ @@ -611,6 +630,7 @@ build .bootstrap/soong-cc/test/android/soong/cc.a: g.bootstrap.gc $ .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ .bootstrap/blueprint/pkg/github.com/google/blueprint.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ @@ -618,7 +638,7 @@ build .bootstrap/soong-cc/test/android/soong/cc.a: g.bootstrap.gc $ .bootstrap/soong-glob/pkg/android/soong/glob.a $ .bootstrap/soong-common/pkg/android/soong/common.a $ .bootstrap/soong-genrule/pkg/android/soong/genrule.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/soong/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg pkgPath = android/soong/cc default .bootstrap/soong-cc/test/android/soong/cc.a @@ -637,7 +657,7 @@ default .bootstrap/soong-cc/test/test.a build .bootstrap/soong-cc/test/test: g.bootstrap.link $ .bootstrap/soong-cc/test/test.a | ${g.bootstrap.linkCmd} - libDirFlags = -L .bootstrap/soong-cc/test -L .bootstrap/blueprint-parser/pkg -L .bootstrap/blueprint-pathtools/pkg -L .bootstrap/blueprint-proptools/pkg -L .bootstrap/blueprint/pkg -L .bootstrap/blueprint-deptools/pkg -L .bootstrap/blueprint-bootstrap-bpdoc/pkg -L .bootstrap/blueprint-bootstrap/pkg -L .bootstrap/soong-env/pkg -L .bootstrap/soong-glob/pkg -L .bootstrap/soong-common/pkg -L .bootstrap/soong-genrule/pkg + libDirFlags = -L .bootstrap/soong-cc/test -L .bootstrap/blueprint-parser/pkg -L .bootstrap/blueprint-pathtools/pkg -L .bootstrap/blueprint-proptools/pkg -L .bootstrap/blueprint/pkg -L .bootstrap/soong/pkg -L .bootstrap/blueprint-deptools/pkg -L .bootstrap/blueprint-bootstrap-bpdoc/pkg -L .bootstrap/blueprint-bootstrap/pkg -L .bootstrap/soong-env/pkg -L .bootstrap/soong-glob/pkg -L .bootstrap/soong-common/pkg -L .bootstrap/soong-genrule/pkg default .bootstrap/soong-cc/test/test build .bootstrap/soong-cc/test/test.passed: g.bootstrap.test $ @@ -662,6 +682,7 @@ build .bootstrap/soong-cc/pkg/android/soong/cc.a: g.bootstrap.gc $ .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ .bootstrap/blueprint/pkg/github.com/google/blueprint.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ @@ -670,7 +691,7 @@ build .bootstrap/soong-cc/pkg/android/soong/cc.a: g.bootstrap.gc $ .bootstrap/soong-common/pkg/android/soong/common.a $ .bootstrap/soong-genrule/pkg/android/soong/genrule.a || $ .bootstrap/soong-cc/test/test.passed - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/soong/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg pkgPath = android/soong/cc default .bootstrap/soong-cc/pkg/android/soong/cc.a @@ -679,7 +700,7 @@ default .bootstrap/soong-cc/pkg/android/soong/cc.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:72:1 +# Defined: build/soong/Android.bp:85:1 build .bootstrap/soong-common/pkg/android/soong/common.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/common/arch.go $ @@ -698,9 +719,10 @@ build .bootstrap/soong-common/pkg/android/soong/common.a: g.bootstrap.gc $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/soong-env/pkg/android/soong/env.a $ .bootstrap/soong-glob/pkg/android/soong/glob.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg pkgPath = android/soong/common default .bootstrap/soong-common/pkg/android/soong/common.a @@ -709,7 +731,7 @@ default .bootstrap/soong-common/pkg/android/soong/common.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:41:1 +# Defined: build/soong/Android.bp:42:1 build .bootstrap/soong-env/pkg/android/soong/env.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/env/env.go | ${g.bootstrap.gcCmd} @@ -721,7 +743,7 @@ default .bootstrap/soong-env/pkg/android/soong/env.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:121:1 +# Defined: build/soong/Android.bp:136:1 build .bootstrap/soong-genrule/pkg/android/soong/genrule.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/genrule/genrule.go | $ @@ -730,13 +752,14 @@ build .bootstrap/soong-genrule/pkg/android/soong/genrule.a: g.bootstrap.gc $ .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ .bootstrap/blueprint/pkg/github.com/google/blueprint.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ .bootstrap/soong-env/pkg/android/soong/env.a $ .bootstrap/soong-glob/pkg/android/soong/glob.a $ .bootstrap/soong-common/pkg/android/soong/common.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/soong/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg pkgPath = android/soong/genrule default .bootstrap/soong-genrule/pkg/android/soong/genrule.a @@ -745,7 +768,7 @@ default .bootstrap/soong-genrule/pkg/android/soong/genrule.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:60:1 +# Defined: build/soong/Android.bp:61:1 build .bootstrap/soong-glob/pkg/android/soong/glob.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/glob/glob.go | ${g.bootstrap.gcCmd} $ @@ -760,7 +783,7 @@ default .bootstrap/soong-glob/pkg/android/soong/glob.a # Variant: # Type: bootstrap_go_package # Factory: github.com/google/blueprint/bootstrap.func·002 -# Defined: build/soong/Android.bp:141:1 +# Defined: build/soong/Android.bp:157:1 build .bootstrap/soong-java/pkg/android/soong/java.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/java/app_builder.go $ @@ -774,6 +797,7 @@ build .bootstrap/soong-java/pkg/android/soong/java.a: g.bootstrap.gc $ .bootstrap/blueprint-pathtools/pkg/github.com/google/blueprint/pathtools.a $ .bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $ .bootstrap/blueprint/pkg/github.com/google/blueprint.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ @@ -781,7 +805,7 @@ build .bootstrap/soong-java/pkg/android/soong/java.a: g.bootstrap.gc $ .bootstrap/soong-glob/pkg/android/soong/glob.a $ .bootstrap/soong-common/pkg/android/soong/common.a $ .bootstrap/soong-genrule/pkg/android/soong/genrule.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/soong/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg pkgPath = android/soong/java default .bootstrap/soong-java/pkg/android/soong/java.a @@ -802,6 +826,7 @@ build .bootstrap/soong_build/obj/soong_build.a: g.bootstrap.gc $ .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $ .bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $ .bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $ + .bootstrap/soong/pkg/android/soong.a $ .bootstrap/soong-env/pkg/android/soong/env.a $ .bootstrap/soong-glob/pkg/android/soong/glob.a $ .bootstrap/soong-common/pkg/android/soong/common.a $ @@ -809,13 +834,13 @@ build .bootstrap/soong_build/obj/soong_build.a: g.bootstrap.gc $ .bootstrap/soong-cc/pkg/android/soong/cc.a $ .bootstrap/soong-art/pkg/android/soong/art.a $ .bootstrap/soong-java/pkg/android/soong/java.a - incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg -I .bootstrap/soong-cc/pkg -I .bootstrap/soong-art/pkg -I .bootstrap/soong-java/pkg + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-bootstrap-bpdoc/pkg -I .bootstrap/blueprint-bootstrap/pkg -I .bootstrap/soong/pkg -I .bootstrap/soong-env/pkg -I .bootstrap/soong-glob/pkg -I .bootstrap/soong-common/pkg -I .bootstrap/soong-genrule/pkg -I .bootstrap/soong-cc/pkg -I .bootstrap/soong-art/pkg -I .bootstrap/soong-java/pkg pkgPath = soong_build default .bootstrap/soong_build/obj/soong_build.a build .bootstrap/soong_build/obj/a.out: g.bootstrap.link $ .bootstrap/soong_build/obj/soong_build.a | ${g.bootstrap.linkCmd} - libDirFlags = -L .bootstrap/blueprint-parser/pkg -L .bootstrap/blueprint-pathtools/pkg -L .bootstrap/blueprint-proptools/pkg -L .bootstrap/blueprint/pkg -L .bootstrap/blueprint-deptools/pkg -L .bootstrap/blueprint-bootstrap-bpdoc/pkg -L .bootstrap/blueprint-bootstrap/pkg -L .bootstrap/soong-env/pkg -L .bootstrap/soong-glob/pkg -L .bootstrap/soong-common/pkg -L .bootstrap/soong-genrule/pkg -L .bootstrap/soong-cc/pkg -L .bootstrap/soong-art/pkg -L .bootstrap/soong-java/pkg + libDirFlags = -L .bootstrap/blueprint-parser/pkg -L .bootstrap/blueprint-pathtools/pkg -L .bootstrap/blueprint-proptools/pkg -L .bootstrap/blueprint/pkg -L .bootstrap/blueprint-deptools/pkg -L .bootstrap/blueprint-bootstrap-bpdoc/pkg -L .bootstrap/blueprint-bootstrap/pkg -L .bootstrap/soong/pkg -L .bootstrap/soong-env/pkg -L .bootstrap/soong-glob/pkg -L .bootstrap/soong-common/pkg -L .bootstrap/soong-genrule/pkg -L .bootstrap/soong-cc/pkg -L .bootstrap/soong-art/pkg -L .bootstrap/soong-java/pkg default .bootstrap/soong_build/obj/a.out build .bootstrap/bin/soong_build: g.bootstrap.cp $ @@ -827,7 +852,7 @@ default .bootstrap/bin/soong_build # Variant: # Type: bootstrap_go_binary # Factory: github.com/google/blueprint/bootstrap.func·003 -# Defined: build/soong/Android.bp:31:1 +# Defined: build/soong/Android.bp:32:1 build .bootstrap/soong_env/obj/soong_env.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/cmd/soong_env/soong_env.go | $ @@ -849,7 +874,7 @@ default .bootstrap/bin/soong_env # Variant: # Type: bootstrap_go_binary # Factory: github.com/google/blueprint/bootstrap.func·003 -# Defined: build/soong/Android.bp:50:1 +# Defined: build/soong/Android.bp:51:1 build .bootstrap/soong_glob/obj/soong_glob.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/cmd/soong_glob/soong_glob.go | $ @@ -875,7 +900,7 @@ default .bootstrap/bin/soong_glob # Variant: # Type: bootstrap_go_binary # Factory: github.com/google/blueprint/bootstrap.func·003 -# Defined: build/soong/Android.bp:134:1 +# Defined: build/soong/Android.bp:150:1 build .bootstrap/soong_jar/obj/soong_jar.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/cmd/soong_jar/soong_jar.go | $ @@ -27,10 +27,39 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/pathtools" + "android/soong" "android/soong/common" "android/soong/genrule" ) +func init() { + soong.RegisterModuleType("cc_library_static", CCLibraryStaticFactory) + soong.RegisterModuleType("cc_library_shared", CCLibrarySharedFactory) + soong.RegisterModuleType("cc_library", CCLibraryFactory) + soong.RegisterModuleType("cc_object", CCObjectFactory) + soong.RegisterModuleType("cc_binary", CCBinaryFactory) + soong.RegisterModuleType("cc_test", CCTestFactory) + soong.RegisterModuleType("cc_benchmark", CCBenchmarkFactory) + + soong.RegisterModuleType("toolchain_library", ToolchainLibraryFactory) + 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) + + soong.RegisterModuleType("cc_library_host_static", CCLibraryHostStaticFactory) + soong.RegisterModuleType("cc_library_host_shared", CCLibraryHostSharedFactory) + soong.RegisterModuleType("cc_binary_host", CCBinaryHostFactory) + soong.RegisterModuleType("cc_test_host", CCTestHostFactory) + soong.RegisterModuleType("cc_benchmark_host", CCBenchmarkHostFactory) + + // 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 + // functions will run first. + soong.RegisterEarlyMutator("link", LinkageMutator) + soong.RegisterEarlyMutator("test_per_src", TestPerSrcMutator) +} + var ( HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", common.Config.PrebuiltOS) SrcDir = pctx.VariableConfigMethod("SrcDir", common.Config.SrcDir) diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 9ef0d064..94fb6e74 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -20,14 +20,16 @@ import ( "os" "path/filepath" - "github.com/google/blueprint" "github.com/google/blueprint/bootstrap" - "android/soong/art" - "android/soong/cc" + "android/soong" + + // These imports cause the modules to register their ModuleTypes, etc. with the soong package + _ "android/soong/art" + _ "android/soong/cc" "android/soong/common" - "android/soong/genrule" - "android/soong/java" + _ "android/soong/genrule" + _ "android/soong/java" ) func main() { @@ -36,54 +38,7 @@ func main() { // The top-level Blueprints file is passed as the first argument. srcDir := filepath.Dir(flag.Arg(0)) - ctx := blueprint.NewContext() - - // Module types - ctx.RegisterModuleType("cc_library_static", cc.CCLibraryStaticFactory) - ctx.RegisterModuleType("cc_library_shared", cc.CCLibrarySharedFactory) - ctx.RegisterModuleType("cc_library", cc.CCLibraryFactory) - ctx.RegisterModuleType("cc_object", cc.CCObjectFactory) - ctx.RegisterModuleType("cc_binary", cc.CCBinaryFactory) - ctx.RegisterModuleType("cc_test", cc.CCTestFactory) - ctx.RegisterModuleType("cc_benchmark", cc.CCBenchmarkFactory) - - ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory) - ctx.RegisterModuleType("ndk_prebuilt_library", cc.NdkPrebuiltLibraryFactory) - ctx.RegisterModuleType("ndk_prebuilt_object", cc.NdkPrebuiltObjectFactory) - ctx.RegisterModuleType("ndk_prebuilt_static_stl", cc.NdkPrebuiltStaticStlFactory) - ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory) - - ctx.RegisterModuleType("cc_library_host_static", cc.CCLibraryHostStaticFactory) - ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory) - ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory) - ctx.RegisterModuleType("cc_test_host", cc.CCTestHostFactory) - ctx.RegisterModuleType("cc_benchmark_host", cc.CCBenchmarkHostFactory) - - ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory) - ctx.RegisterModuleType("genrule", genrule.GenRuleFactory) - - ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory) - ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory) - - ctx.RegisterModuleType("java_library", java.JavaLibraryFactory) - ctx.RegisterModuleType("java_library_static", java.JavaLibraryFactory) - ctx.RegisterModuleType("java_library_host", java.JavaLibraryHostFactory) - ctx.RegisterModuleType("java_binary", java.JavaBinaryFactory) - ctx.RegisterModuleType("java_binary_host", java.JavaBinaryHostFactory) - ctx.RegisterModuleType("prebuilt_java_library", java.JavaPrebuiltFactory) - ctx.RegisterModuleType("prebuilt_sdk", java.SdkPrebuiltFactory) - ctx.RegisterModuleType("android_app", java.AndroidAppFactory) - - // Mutators - ctx.RegisterEarlyMutator("host_or_device", common.HostOrDeviceMutator) - ctx.RegisterEarlyMutator("arch", common.ArchMutator) - ctx.RegisterEarlyMutator("link", cc.LinkageMutator) - ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator) - - // Singletons - ctx.RegisterSingletonType("buildtarget", common.BuildTargetSingleton) - ctx.RegisterSingletonType("env", common.EnvSingleton) - ctx.RegisterSingletonType("logtags", java.LogtagsSingleton) + ctx := soong.NewContext() configuration, err := common.NewConfig(srcDir) if err != nil { diff --git a/common/arch.go b/common/arch.go index 6865904d..c0e63eb0 100644 --- a/common/arch.go +++ b/common/arch.go @@ -20,10 +20,17 @@ import ( "runtime" "strings" + "android/soong" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) +func init() { + soong.RegisterEarlyMutator("host_or_device", HostOrDeviceMutator) + soong.RegisterEarlyMutator("arch", ArchMutator) +} + var ( Arm = newArch("arm", "lib32") Arm64 = newArch("arm64", "lib64") diff --git a/common/env.go b/common/env.go index e33a0258..3214baa8 100644 --- a/common/env.go +++ b/common/env.go @@ -15,6 +15,7 @@ package common import ( + "android/soong" "android/soong/env" "github.com/google/blueprint" @@ -27,6 +28,10 @@ import ( // compare the contents of the environment variables, rewriting the file if necessary to cause // a manifest regeneration. +func init() { + soong.RegisterSingletonType("env", EnvSingleton) +} + func EnvSingleton() blueprint.Singleton { return &envSingleton{} } diff --git a/common/module.go b/common/module.go index 1d17de10..b19b6d1c 100644 --- a/common/module.go +++ b/common/module.go @@ -15,6 +15,7 @@ package common import ( + "android/soong" "path/filepath" "runtime" "sort" @@ -520,6 +521,10 @@ func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) []s return ret } +func init() { + soong.RegisterSingletonType("buildtarget", BuildTargetSingleton) +} + func BuildTargetSingleton() blueprint.Singleton { return &buildTargetSingleton{} } diff --git a/genrule/genrule.go b/genrule/genrule.go index 2052dfdd..a5a4c71f 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -20,9 +20,15 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/pathtools" + "android/soong" "android/soong/common" ) +func init() { + soong.RegisterModuleType("gensrcs", GenSrcsFactory) + soong.RegisterModuleType("genrule", GenRuleFactory) +} + var ( pctx = blueprint.NewPackageContext("android/soong/genrule") ) diff --git a/java/java.go b/java/java.go index 94f6914e..8b50eff4 100644 --- a/java/java.go +++ b/java/java.go @@ -26,10 +26,24 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/pathtools" + "android/soong" "android/soong/common" "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) + + soong.RegisterSingletonType("logtags", LogtagsSingleton) +} + // TODO: // Autogenerated files: // Proto diff --git a/register.go b/register.go new file mode 100644 index 00000000..c35beae5 --- /dev/null +++ b/register.go @@ -0,0 +1,68 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package soong + +import "github.com/google/blueprint" + +type moduleType struct { + name string + factory blueprint.ModuleFactory +} + +var moduleTypes []moduleType + +type singleton struct { + name string + factory blueprint.SingletonFactory +} + +var singletons []singleton + +type earlyMutator struct { + name string + mutator blueprint.EarlyMutator +} + +var earlyMutators []earlyMutator + +func RegisterModuleType(name string, factory blueprint.ModuleFactory) { + moduleTypes = append(moduleTypes, moduleType{name, factory}) +} + +func RegisterSingletonType(name string, factory blueprint.SingletonFactory) { + singletons = append(singletons, singleton{name, factory}) +} + +func RegisterEarlyMutator(name string, mutator blueprint.EarlyMutator) { + earlyMutators = append(earlyMutators, earlyMutator{name, mutator}) +} + +func NewContext() *blueprint.Context { + ctx := blueprint.NewContext() + + for _, t := range moduleTypes { + ctx.RegisterModuleType(t.name, t.factory) + } + + for _, t := range singletons { + ctx.RegisterSingletonType(t.name, t.factory) + } + + for _, t := range earlyMutators { + ctx.RegisterEarlyMutator(t.name, t.mutator) + } + + return ctx +} |