Loading mk2rbc/mk2rbc.go +1 −1 Original line number Diff line number Diff line Loading @@ -1376,7 +1376,7 @@ func (p *myDirCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkp if !args.Empty() { return ctx.newBadExpr(node, "my-dir function cannot have any arguments passed to it.") } return &variableRefExpr{ctx.addVariable("LOCAL_PATH"), true} return &stringLiteralExpr{literal: filepath.Dir(ctx.script.mkFile)} } type isProductInListCallParser struct{} Loading mk2rbc/mk2rbc_test.go +13 −0 Original line number Diff line number Diff line Loading @@ -1459,6 +1459,19 @@ def init(g, handle): g["MY_VAR_4"] = "foo" _my_local_var_with_dashes = ["foo"] g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk")) `, }, { desc: "Set LOCAL_PATH to my-dir", mkname: "product.mk", in: ` LOCAL_PATH := $(call my-dir) `, expected: `load("//build/make/core:product_config.rbc", "rblf") def init(g, handle): cfg = rblf.cfg(handle) `, }, } Loading mk2rbc/variable.go +6 −8 Original line number Diff line number Diff line Loading @@ -319,16 +319,14 @@ func (ctx *parseContext) addVariable(name string) variable { v = &localVariable{baseVariable{nam: name, typ: hintType}} } else { vt := hintType if strings.HasPrefix(name, "LOCAL_") && vt == starlarkTypeUnknown { // Heuristics: local variables that contribute to corresponding config variables if cfgVarName, found := localProductConfigVariables[name]; found { if cfgVarName, found := localProductConfigVariables[name]; found && vt == starlarkTypeUnknown { vi, found2 := KnownVariables[cfgVarName] if !found2 { panic(fmt.Errorf("unknown config variable %s for %s", cfgVarName, name)) } vt = vi.valueType } } if strings.HasSuffix(name, "_LIST") && vt == starlarkTypeUnknown { // Heuristics: Variables with "_LIST" suffix are lists vt = starlarkTypeList Loading Loading
mk2rbc/mk2rbc.go +1 −1 Original line number Diff line number Diff line Loading @@ -1376,7 +1376,7 @@ func (p *myDirCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkp if !args.Empty() { return ctx.newBadExpr(node, "my-dir function cannot have any arguments passed to it.") } return &variableRefExpr{ctx.addVariable("LOCAL_PATH"), true} return &stringLiteralExpr{literal: filepath.Dir(ctx.script.mkFile)} } type isProductInListCallParser struct{} Loading
mk2rbc/mk2rbc_test.go +13 −0 Original line number Diff line number Diff line Loading @@ -1459,6 +1459,19 @@ def init(g, handle): g["MY_VAR_4"] = "foo" _my_local_var_with_dashes = ["foo"] g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk")) `, }, { desc: "Set LOCAL_PATH to my-dir", mkname: "product.mk", in: ` LOCAL_PATH := $(call my-dir) `, expected: `load("//build/make/core:product_config.rbc", "rblf") def init(g, handle): cfg = rblf.cfg(handle) `, }, } Loading
mk2rbc/variable.go +6 −8 Original line number Diff line number Diff line Loading @@ -319,16 +319,14 @@ func (ctx *parseContext) addVariable(name string) variable { v = &localVariable{baseVariable{nam: name, typ: hintType}} } else { vt := hintType if strings.HasPrefix(name, "LOCAL_") && vt == starlarkTypeUnknown { // Heuristics: local variables that contribute to corresponding config variables if cfgVarName, found := localProductConfigVariables[name]; found { if cfgVarName, found := localProductConfigVariables[name]; found && vt == starlarkTypeUnknown { vi, found2 := KnownVariables[cfgVarName] if !found2 { panic(fmt.Errorf("unknown config variable %s for %s", cfgVarName, name)) } vt = vi.valueType } } if strings.HasSuffix(name, "_LIST") && vt == starlarkTypeUnknown { // Heuristics: Variables with "_LIST" suffix are lists vt = starlarkTypeList Loading