diff options
Diffstat (limited to 'androidmk')
-rw-r--r-- | androidmk/cmd/androidmk/android.go | 33 | ||||
-rw-r--r-- | androidmk/cmd/androidmk/androidmk.go | 21 | ||||
-rw-r--r-- | androidmk/cmd/androidmk/androidmk_test.go | 13 |
3 files changed, 50 insertions, 17 deletions
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go index 1ecda2d5..a5dfcd90 100644 --- a/androidmk/cmd/androidmk/android.go +++ b/androidmk/cmd/androidmk/android.go @@ -105,6 +105,7 @@ func init() { "LOCAL_MANIFEST_FILE": "manifest", "LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING": "dex_preopt.profile", + "LOCAL_TEST_CONFIG": "test_config", }) addStandardProperties(bpparser.ListType, map[string]string{ @@ -513,8 +514,8 @@ func strip() func(ctx variableAssignmentContext) error { func prebuiltClass(ctx variableAssignmentContext) error { class := ctx.mkvalue.Value(ctx.file.scope) - if v, ok := prebuiltTypes[class]; ok { - ctx.file.scope.Set("BUILD_PREBUILT", v) + if _, ok := prebuiltTypes[class]; ok { + ctx.file.scope.Set("BUILD_PREBUILT", class) } else { // reset to default ctx.file.scope.Set("BUILD_PREBUILT", "prebuilt") @@ -873,6 +874,19 @@ var prebuiltTypes = map[string]string{ var soongModuleTypes = map[string]bool{} +var includePathToModule = map[string]string{ + "test/vts/tools/build/Android.host_config.mk": "vts_config", + // The rest will be populated dynamically in androidScope below +} + +func mapIncludePath(path string) (string, bool) { + if path == clear_vars || path == include_ignored { + return path, true + } + module, ok := includePathToModule[path] + return module, ok +} + func androidScope() mkparser.Scope { globalScope := mkparser.NewScope(nil) globalScope.Set("CLEAR_VARS", clear_vars) @@ -887,12 +901,17 @@ func androidScope() mkparser.Scope { globalScope.SetFunc("first-makefiles-under", includeIgnored) globalScope.SetFunc("all-named-subdir-makefiles", includeIgnored) globalScope.SetFunc("all-subdir-makefiles", includeIgnored) - for k, v := range moduleTypes { - globalScope.Set(k, v) - soongModuleTypes[v] = true + + // The scope maps each known variable to a path, and then includePathToModule maps a path + // to a module. We don't care what the actual path value is so long as the value in scope + // is mapped, so we might as well use variable name as key, too. + for varName, moduleName := range moduleTypes { + path := varName + globalScope.Set(varName, path) + includePathToModule[path] = moduleName } - for _, v := range prebuiltTypes { - soongModuleTypes[v] = true + for varName, moduleName := range prebuiltTypes { + includePathToModule[varName] = moduleName } return globalScope diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go index b6a973c0..0426b43f 100644 --- a/androidmk/cmd/androidmk/androidmk.go +++ b/androidmk/cmd/androidmk/androidmk.go @@ -169,20 +169,21 @@ func convertFile(filename string, buffer *bytes.Buffer) (string, []error) { handleAssignment(file, x, assignmentCond) case *mkparser.Directive: switch x.Name { - case "include": - val := x.Args.Value(file.scope) - switch { - case soongModuleTypes[val]: - handleModuleConditionals(file, x, conds) - makeModule(file, val) - case val == clear_vars: + case "include", "-include": + module, ok := mapIncludePath(x.Args.Value(file.scope)) + if !ok { + file.errorf(x, "unsupported include") + continue + } + switch module { + case clear_vars: resetModule(file) - case val == include_ignored: + case include_ignored: // subdirs are already automatically included in Soong continue default: - file.errorf(x, "unsupported include") - continue + handleModuleConditionals(file, x, conds) + makeModule(file, module) } case "ifeq", "ifneq", "ifdef", "ifndef": args := x.Args.Dump() diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go index 52b8476a..618dd42f 100644 --- a/androidmk/cmd/androidmk/androidmk_test.go +++ b/androidmk/cmd/androidmk/androidmk_test.go @@ -1028,6 +1028,19 @@ prebuilt_etc { } `, }, + { + desc: "vts_config", + in: ` +include $(CLEAR_VARS) +LOCAL_MODULE := vtsconf +include test/vts/tools/build/Android.host_config.mk +`, + expected: ` +vts_config { + name: "vtsconf", +} +`, + }, } func TestEndToEnd(t *testing.T) { |