diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-06-05 22:33:49 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-06-05 22:47:40 -0700 |
commit | 22abd40ed05090927ce7b0ac2c387c353253e7e2 (patch) | |
tree | 937d8b3b1b5d686791e241e63cd85d29cf1f83b9 | |
parent | 58f9bb1160074f06e2cea66f78dfdf4d42834c59 (diff) | |
download | build_soong-22abd40ed05090927ce7b0ac2c387c353253e7e2.tar.gz build_soong-22abd40ed05090927ce7b0ac2c387c353253e7e2.tar.bz2 build_soong-22abd40ed05090927ce7b0ac2c387c353253e7e2.zip |
androidmk: TOP is always "."
But if it comes out to ./, remove both characters.
Change-Id: Ia86c1a60522736773b2e8ee0cf54a4348d302573
-rw-r--r-- | androidmk/cmd/androidmk/test.go | 15 | ||||
-rw-r--r-- | androidmk/cmd/androidmk/values.go | 39 |
2 files changed, 41 insertions, 13 deletions
diff --git a/androidmk/cmd/androidmk/test.go b/androidmk/cmd/androidmk/test.go index b3ce5d02..077c35fb 100644 --- a/androidmk/cmd/androidmk/test.go +++ b/androidmk/cmd/androidmk/test.go @@ -108,7 +108,7 @@ input = ["testing/include"] cc_library_shared { // Comment 1 include_dirs: ["system/core/include"] + // Comment 2 - input + [TOP + "/system/core/include"], + input + ["system/core/include"], local_include_dirs: ["."] + ["include"] + ["test/include"], // Comment 3 }`, @@ -345,6 +345,19 @@ cc_library_shared { } `, }, + { + desc: "Handle TOP", + in: ` +include $(CLEAR_VARS) +LOCAL_C_INCLUDES := $(TOP)/system/core/include $(TOP) +include $(BUILD_SHARED_LIBRARY) +`, + expected: ` +cc_library_shared { + include_dirs: ["system/core/include", "."], +} +`, + }, } func reformatBlueprint(input string) string { diff --git a/androidmk/cmd/androidmk/values.go b/androidmk/cmd/androidmk/values.go index ce2f2796..c4fb204c 100644 --- a/androidmk/cmd/androidmk/values.go +++ b/androidmk/cmd/androidmk/values.go @@ -65,9 +65,17 @@ func makeToStringExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bpp Variable: name.Value(nil), } - val, err = addValues(val, tmp) - if err != nil { - return nil, err + if tmp.Variable == "TOP" { + if s[0] == '/' { + s = s[1:] + } else { + s = "." + s + } + } else { + val, err = addValues(val, tmp) + if err != nil { + return nil, err + } } } @@ -120,15 +128,22 @@ func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bppar if !f.Variables[0].Name.Const() { return nil, fmt.Errorf("unsupported non-const variable name") } - if len(listValue.ListValue) > 0 { - listOfListValues = append(listOfListValues, listValue) - } - listOfListValues = append(listOfListValues, &bpparser.Value{ - Type: bpparser.List, - Variable: f.Variables[0].Name.Value(nil), - }) - listValue = &bpparser.Value{ - Type: bpparser.List, + if f.Variables[0].Name.Value(nil) == "TOP" { + listValue.ListValue = append(listValue.ListValue, bpparser.Value{ + Type: bpparser.String, + StringValue: ".", + }) + } else { + if len(listValue.ListValue) > 0 { + listOfListValues = append(listOfListValues, listValue) + } + listOfListValues = append(listOfListValues, &bpparser.Value{ + Type: bpparser.List, + Variable: f.Variables[0].Name.Value(nil), + }) + listValue = &bpparser.Value{ + Type: bpparser.List, + } } } } else { |