androidmk: support conditionals on HOST_OS == linux

Add HOST_OS == linux to the supported conditionals, and replace
a manual list with a map lookup.

Change-Id: I0c26e3a854d1011870f41c05fc400d68334cd45f
This commit is contained in:
Colin Cross 2015-03-26 16:15:58 -07:00
parent 24e6aef941
commit bbcb4963d6
2 changed files with 8 additions and 8 deletions

View file

@ -87,10 +87,12 @@ var conditionalTranslations = map[string]struct {
class string class string
suffix string suffix string
}{ }{
"($(HOST_OS),darwin)": {"host_os", "darwin"}, "($(HOST_OS),darwin)": {"target", "darwin"},
"($(HOST_OS), darwin)": {"host_os", "darwin"}, "($(HOST_OS), darwin)": {"target", "darwin"},
"($(HOST_OS),windows)": {"host_os", "windows"}, "($(HOST_OS),windows)": {"target", "windows"},
"($(HOST_OS), windows)": {"host_os", "windows"}, "($(HOST_OS), windows)": {"target", "windows"},
"($(HOST_OS),linux)": {"target", "linux"},
"($(HOST_OS), linux)": {"target", "linux"},
} }
func mydir(args []string) string { func mydir(args []string) string {

View file

@ -125,9 +125,7 @@ func main() {
case "ifeq", "ifneq": case "ifeq", "ifneq":
args := directive.Args.Dump() args := directive.Args.Dump()
eq := directive.Name == "ifeq" eq := directive.Name == "ifeq"
switch args { if _, ok := conditionalTranslations[args]; ok {
case "($(HOST_OS),windows)", "($(HOST_OS), windows)",
"($(HOST_OS),darwin)", "($(HOST_OS), darwin)":
newCond := conditional{args, eq} newCond := conditional{args, eq}
conds = append(conds, &newCond) conds = append(conds, &newCond)
if cond == nil { if cond == nil {
@ -135,7 +133,7 @@ func main() {
} else { } else {
file.errorf(directive, "unsupported nested conditional") file.errorf(directive, "unsupported nested conditional")
} }
default: } else {
file.errorf(directive, "unsupported conditional") file.errorf(directive, "unsupported conditional")
conds = append(conds, nil) conds = append(conds, nil)
continue continue