diff options
author | Colin Cross <ccross@android.com> | 2015-03-31 13:58:33 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2015-04-02 14:49:06 -0700 |
commit | 139b8158753967c507d9cc62bcdd8c5c4ddcefb9 (patch) | |
tree | e760b2d6abe8d73ebdfdfab98311df3abbeb3e62 /androidmk | |
parent | 7d21c4430d506e25fb9d99d144e0e2f49d667270 (diff) | |
download | build_soong-139b8158753967c507d9cc62bcdd8c5c4ddcefb9.tar.gz build_soong-139b8158753967c507d9cc62bcdd8c5c4ddcefb9.tar.bz2 build_soong-139b8158753967c507d9cc62bcdd8c5c4ddcefb9.zip |
androidmk: use map to hold module types
Reduces the number of places that need to be edited when adding
new module types.
Change-Id: Id35d16f005e377e1e3bb955348ed92a4a2c392bb
Diffstat (limited to 'androidmk')
-rw-r--r-- | androidmk/cmd/androidmk/android.go | 46 | ||||
-rw-r--r-- | androidmk/cmd/androidmk/androidmk.go | 11 |
2 files changed, 22 insertions, 35 deletions
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go index 44165e83..4f2fca1a 100644 --- a/androidmk/cmd/androidmk/android.go +++ b/androidmk/cmd/androidmk/android.go @@ -5,16 +5,7 @@ import ( ) const ( - clear_vars = "__android_mk_clear_vars" - build_shared_library = "cc_library_shared" - build_static_library = "cc_library_static" - build_host_static_library = "cc_library_host_static" - build_host_shared_library = "cc_library_host_shared" - build_executable = "cc_binary" - build_host_executable = "cc_binary_host" - build_native_test = "cc_test" - build_host_native_test = "cc_test_host" - build_prebuilt = "prebuilt" + clear_vars = "__android_mk_clear_vars" ) var stringProperties = map[string]string{ @@ -103,28 +94,29 @@ func mydir(args []string) string { return "." } +var moduleTypes = map[string]string{ + "BUILD_SHARED_LIBRARY": "cc_library_shared", + "BUILD_STATIC_LIBRARY": "cc_library_static", + "BUILD_HOST_SHARED_LIBRARY": "cc_library_host_shared", + "BUILD_HOST_STATIC_LIBRARY": "cc_library_host_static", + "BUILD_EXECUTABLE": "cc_binary", + "BUILD_HOST_EXECUTABLE": "cc_binary_host", + "BUILD_NATIVE_TEST": "cc_test", + "BUILD_HOST_NATIVE_TEST": "cc_test_host", + "BUILD_PREBUILT": "prebuilt", +} + +var soongModuleTypes = map[string]bool{} + func androidScope() parser.Scope { globalScope := parser.NewScope(nil) globalScope.Set("CLEAR_VARS", clear_vars) - globalScope.Set("BUILD_HOST_EXECUTABLE", build_host_executable) - globalScope.Set("BUILD_SHARED_LIBRARY", build_shared_library) - globalScope.Set("BUILD_STATIC_LIBRARY", build_static_library) - globalScope.Set("BUILD_HOST_STATIC_LIBRARY", build_host_static_library) - globalScope.Set("BUILD_HOST_SHARED_LIBRARY", build_host_shared_library) - globalScope.Set("BUILD_NATIVE_TEST", build_native_test) - globalScope.Set("BUILD_HOST_NATIVE_TEST", build_host_native_test) - globalScope.Set("BUILD_EXECUTABLE", build_executable) - globalScope.Set("BUILD_PREBUILT", build_prebuilt) globalScope.SetFunc("my-dir", mydir) - globalScope.Set("lib32", "lib32") - globalScope.Set("lib64", "lib64") - globalScope.Set("arm", "arm") - globalScope.Set("arm64", "arm64") - globalScope.Set("mips", "mips") - globalScope.Set("mips64", "mips64") - globalScope.Set("x86", "x86") - globalScope.Set("x86_64", "x86_64") + for k, v := range moduleTypes { + globalScope.Set(k, v) + soongModuleTypes[v] = true + } return globalScope } diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go index 22b29b24..8ac58bfd 100644 --- a/androidmk/cmd/androidmk/androidmk.go +++ b/androidmk/cmd/androidmk/androidmk.go @@ -107,16 +107,11 @@ func main() { switch directive.Name { case "include": val := directive.Args.Value(file.scope) - switch val { - case build_shared_library, build_static_library, - build_executable, build_host_executable, - build_prebuilt, build_host_static_library, - build_host_shared_library, build_native_test, - build_host_native_test: - + switch { + case soongModuleTypes[val]: handleModuleConditionals(file, directive, cond) makeModule(file, val) - case clear_vars: + case val == clear_vars: resetModule(file) default: file.errorf(directive, "unsupported include") |