зеркало из https://github.com/mozilla/gecko-dev.git
Bug 922685 - Local $(foreach) variable isn't set properly; r=bsmedberg
This commit is contained in:
Родитель
c54df6244c
Коммит
f9808270bb
|
@ -504,13 +504,13 @@ class Variables(object):
|
|||
|
||||
return (None, None, None)
|
||||
|
||||
def set(self, name, flavor, source, value):
|
||||
def set(self, name, flavor, source, value, force=False):
|
||||
assert flavor in (self.FLAVOR_RECURSIVE, self.FLAVOR_SIMPLE)
|
||||
assert source in (self.SOURCE_OVERRIDE, self.SOURCE_COMMANDLINE, self.SOURCE_MAKEFILE, self.SOURCE_ENVIRONMENT, self.SOURCE_AUTOMATIC, self.SOURCE_IMPLICIT)
|
||||
assert isinstance(value, str_type), "expected str, got %s" % type(value)
|
||||
|
||||
prevflavor, prevsource, prevvalue = self.get(name)
|
||||
if prevsource is not None and source > prevsource:
|
||||
if prevsource is not None and source > prevsource and not force:
|
||||
# TODO: give a location for this warning
|
||||
_log.info("not setting variable '%s', set by higher-priority source to value '%s'" % (name, prevvalue))
|
||||
return
|
||||
|
|
|
@ -649,7 +649,11 @@ class ForEachFunction(Function):
|
|||
else:
|
||||
fd.write(' ')
|
||||
|
||||
v.set(vname, data.Variables.FLAVOR_SIMPLE, data.Variables.SOURCE_AUTOMATIC, w)
|
||||
# The $(origin) of the local variable must be "automatic" to
|
||||
# conform with GNU make. However, automatic variables have low
|
||||
# priority. So, we must force its assignment to occur.
|
||||
v.set(vname, data.Variables.FLAVOR_SIMPLE,
|
||||
data.Variables.SOURCE_AUTOMATIC, w, force=True)
|
||||
e.resolve(makefile, v, fd, setting)
|
||||
|
||||
class CallFunction(Function):
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# This test ensures that a local variable in a $(foreach) is bound to
|
||||
# the local value, not a global value.
|
||||
i := dummy
|
||||
|
||||
all:
|
||||
test "$(foreach i,foo bar,found:$(i))" = "found:foo found:bar"
|
||||
test "$(i)" = "dummy"
|
||||
@echo TEST-PASS
|
Загрузка…
Ссылка в новой задаче