Convert $(sort) to Starlark

This is mostly so that we can not error out when
seeing sort inside a `include $(sort $(wildcard foo/*.mk))`.

Bug: 218736658
Test: go test
Change-Id: I827ecfc751a908227cb2dd9ed1e4b3f313791a16
This commit is contained in:
Cole Faust 2022-04-05 16:37:39 -07:00
parent 7821a5e180
commit 95b95cb647
2 changed files with 4 additions and 1 deletions

View file

@ -110,6 +110,7 @@ var knownFunctions = map[string]interface {
"require-artifacts-in-path-relaxed": &simpleCallParser{name: baseName + ".require_artifacts_in_path_relaxed", returnType: starlarkTypeVoid},
// TODO(asmundak): remove it once all calls are removed from configuration makefiles. see b/183161002
"shell": &shellCallParser{},
"sort": &simpleCallParser{name: baseName + ".mksort", returnType: starlarkTypeList},
"strip": &simpleCallParser{name: baseName + ".mkstrip", returnType: starlarkTypeString},
"subst": &substCallParser{fname: "subst"},
"warning": &makeControlFuncParser{name: baseName + ".mkwarning"},

View file

@ -1022,12 +1022,13 @@ def init(g, handle):
`,
},
{
desc: "strip function",
desc: "strip/sort functions",
mkname: "product.mk",
in: `
ifeq ($(filter hwaddress,$(PRODUCT_PACKAGES)),)
PRODUCT_PACKAGES := $(strip $(PRODUCT_PACKAGES) hwaddress)
endif
MY_VAR := $(sort b a c)
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
@ -1036,6 +1037,7 @@ def init(g, handle):
if "hwaddress" not in cfg.get("PRODUCT_PACKAGES", []):
rblf.setdefault(handle, "PRODUCT_PACKAGES")
cfg["PRODUCT_PACKAGES"] = (rblf.mkstrip("%s hwaddress" % " ".join(cfg.get("PRODUCT_PACKAGES", [])))).split()
g["MY_VAR"] = rblf.mksort("b a c")
`,
},
{