Merge changes from topic "colefaust_mksort" am: 4cbfa0d7d3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2056409 Change-Id: I3ad6de6b5f690b06e260b4a97b540d33dbea6f82 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/scanner"
|
"text/scanner"
|
||||||
@@ -110,6 +111,7 @@ var knownFunctions = map[string]interface {
|
|||||||
"require-artifacts-in-path-relaxed": &simpleCallParser{name: baseName + ".require_artifacts_in_path_relaxed", returnType: starlarkTypeVoid},
|
"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
|
// TODO(asmundak): remove it once all calls are removed from configuration makefiles. see b/183161002
|
||||||
"shell": &shellCallParser{},
|
"shell": &shellCallParser{},
|
||||||
|
"sort": &simpleCallParser{name: baseName + ".mksort", returnType: starlarkTypeList},
|
||||||
"strip": &simpleCallParser{name: baseName + ".mkstrip", returnType: starlarkTypeString},
|
"strip": &simpleCallParser{name: baseName + ".mkstrip", returnType: starlarkTypeString},
|
||||||
"subst": &substCallParser{fname: "subst"},
|
"subst": &substCallParser{fname: "subst"},
|
||||||
"warning": &makeControlFuncParser{name: baseName + ".mkwarning"},
|
"warning": &makeControlFuncParser{name: baseName + ".mkwarning"},
|
||||||
@@ -758,6 +760,16 @@ func (ctx *parseContext) newDependentModule(path string, optional bool) *moduleI
|
|||||||
func (ctx *parseContext) handleSubConfig(
|
func (ctx *parseContext) handleSubConfig(
|
||||||
v mkparser.Node, pathExpr starlarkExpr, loadAlways bool, processModule func(inheritedModule) starlarkNode) []starlarkNode {
|
v mkparser.Node, pathExpr starlarkExpr, loadAlways bool, processModule func(inheritedModule) starlarkNode) []starlarkNode {
|
||||||
|
|
||||||
|
// Allow seeing $(sort $(wildcard realPathExpr)) or $(wildcard realPathExpr)
|
||||||
|
// because those are functionally the same as not having the sort/wildcard calls.
|
||||||
|
if ce, ok := pathExpr.(*callExpr); ok && ce.name == "rblf.mksort" && len(ce.args) == 1 {
|
||||||
|
if ce2, ok2 := ce.args[0].(*callExpr); ok2 && ce2.name == "rblf.expand_wildcard" && len(ce2.args) == 1 {
|
||||||
|
pathExpr = ce2.args[0]
|
||||||
|
}
|
||||||
|
} else if ce2, ok2 := pathExpr.(*callExpr); ok2 && ce2.name == "rblf.expand_wildcard" && len(ce2.args) == 1 {
|
||||||
|
pathExpr = ce2.args[0]
|
||||||
|
}
|
||||||
|
|
||||||
// In a simple case, the name of a module to inherit/include is known statically.
|
// In a simple case, the name of a module to inherit/include is known statically.
|
||||||
if path, ok := maybeString(pathExpr); ok {
|
if path, ok := maybeString(pathExpr); ok {
|
||||||
// Note that even if this directive loads a module unconditionally, a module may be
|
// Note that even if this directive loads a module unconditionally, a module may be
|
||||||
@@ -765,6 +777,7 @@ func (ctx *parseContext) handleSubConfig(
|
|||||||
moduleShouldExist := loadAlways && ctx.ifNestLevel == 0
|
moduleShouldExist := loadAlways && ctx.ifNestLevel == 0
|
||||||
if strings.Contains(path, "*") {
|
if strings.Contains(path, "*") {
|
||||||
if paths, err := fs.Glob(ctx.script.sourceFS, path); err == nil {
|
if paths, err := fs.Glob(ctx.script.sourceFS, path); err == nil {
|
||||||
|
sort.Strings(paths)
|
||||||
result := make([]starlarkNode, 0)
|
result := make([]starlarkNode, 0)
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
mi := ctx.newDependentModule(p, !moduleShouldExist)
|
mi := ctx.newDependentModule(p, !moduleShouldExist)
|
||||||
|
@@ -197,15 +197,31 @@ def init(g, handle):
|
|||||||
mkname: "path/product.mk",
|
mkname: "path/product.mk",
|
||||||
in: `
|
in: `
|
||||||
$(call inherit-product, */font.mk)
|
$(call inherit-product, */font.mk)
|
||||||
|
$(call inherit-product, $(sort $(wildcard */font.mk)))
|
||||||
|
$(call inherit-product, $(wildcard */font.mk))
|
||||||
|
|
||||||
|
include */font.mk
|
||||||
|
include $(sort $(wildcard */font.mk))
|
||||||
|
include $(wildcard */font.mk)
|
||||||
`,
|
`,
|
||||||
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
||||||
load("//foo:font.star", _font_init = "init")
|
load("//bar:font.star", _font_init = "init")
|
||||||
load("//bar:font.star", _font1_init = "init")
|
load("//foo:font.star", _font1_init = "init")
|
||||||
|
|
||||||
def init(g, handle):
|
def init(g, handle):
|
||||||
cfg = rblf.cfg(handle)
|
cfg = rblf.cfg(handle)
|
||||||
rblf.inherit(handle, "foo/font", _font_init)
|
rblf.inherit(handle, "bar/font", _font_init)
|
||||||
rblf.inherit(handle, "bar/font", _font1_init)
|
rblf.inherit(handle, "foo/font", _font1_init)
|
||||||
|
rblf.inherit(handle, "bar/font", _font_init)
|
||||||
|
rblf.inherit(handle, "foo/font", _font1_init)
|
||||||
|
rblf.inherit(handle, "bar/font", _font_init)
|
||||||
|
rblf.inherit(handle, "foo/font", _font1_init)
|
||||||
|
_font_init(g, handle)
|
||||||
|
_font1_init(g, handle)
|
||||||
|
_font_init(g, handle)
|
||||||
|
_font1_init(g, handle)
|
||||||
|
_font_init(g, handle)
|
||||||
|
_font1_init(g, handle)
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1022,12 +1038,13 @@ def init(g, handle):
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "strip function",
|
desc: "strip/sort functions",
|
||||||
mkname: "product.mk",
|
mkname: "product.mk",
|
||||||
in: `
|
in: `
|
||||||
ifeq ($(filter hwaddress,$(PRODUCT_PACKAGES)),)
|
ifeq ($(filter hwaddress,$(PRODUCT_PACKAGES)),)
|
||||||
PRODUCT_PACKAGES := $(strip $(PRODUCT_PACKAGES) hwaddress)
|
PRODUCT_PACKAGES := $(strip $(PRODUCT_PACKAGES) hwaddress)
|
||||||
endif
|
endif
|
||||||
|
MY_VAR := $(sort b a c)
|
||||||
`,
|
`,
|
||||||
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
||||||
|
|
||||||
@@ -1036,6 +1053,7 @@ def init(g, handle):
|
|||||||
if "hwaddress" not in cfg.get("PRODUCT_PACKAGES", []):
|
if "hwaddress" not in cfg.get("PRODUCT_PACKAGES", []):
|
||||||
rblf.setdefault(handle, "PRODUCT_PACKAGES")
|
rblf.setdefault(handle, "PRODUCT_PACKAGES")
|
||||||
cfg["PRODUCT_PACKAGES"] = (rblf.mkstrip("%s hwaddress" % " ".join(cfg.get("PRODUCT_PACKAGES", [])))).split()
|
cfg["PRODUCT_PACKAGES"] = (rblf.mkstrip("%s hwaddress" % " ".join(cfg.get("PRODUCT_PACKAGES", [])))).split()
|
||||||
|
g["MY_VAR"] = rblf.mksort("b a c")
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user