mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 915642 - Allow simple variable references in includedeps files; r=gps
This commit is contained in:
parent
b3541e24ab
commit
2347d58a74
@ -374,10 +374,13 @@ def parsefile(pathname):
|
||||
|
||||
# colon followed by anything except a slash (Windows path detection)
|
||||
_depfilesplitter = re.compile(r':(?![\\/])')
|
||||
# simple variable references
|
||||
_vars = re.compile('\$\((\w+)\)')
|
||||
|
||||
def parsedepfile(pathname):
|
||||
"""
|
||||
Parse a filename listing only depencencies into a parserdata.StatementList.
|
||||
Simple variable references are allowed in such files.
|
||||
"""
|
||||
def continuation_iter(lines):
|
||||
current_line = []
|
||||
@ -394,12 +397,29 @@ def parsedepfile(pathname):
|
||||
if current_line:
|
||||
yield ''.join(current_line)
|
||||
|
||||
def get_expansion(s):
|
||||
if '$' in s:
|
||||
expansion = data.Expansion()
|
||||
# for an input like e.g. "foo $(bar) baz",
|
||||
# _vars.split returns ["foo", "bar", "baz"]
|
||||
# every other element is a variable name.
|
||||
for i, element in enumerate(_vars.split(s)):
|
||||
if i % 2:
|
||||
expansion.appendfunc(functions.VariableRef(None,
|
||||
data.StringExpansion(element, None)))
|
||||
elif element:
|
||||
expansion.appendstr(element)
|
||||
|
||||
return expansion
|
||||
|
||||
return data.StringExpansion(s, None)
|
||||
|
||||
pathname = os.path.realpath(pathname)
|
||||
stmts = parserdata.StatementList()
|
||||
for line in continuation_iter(open(pathname).readlines()):
|
||||
target, deps = _depfilesplitter.split(line, 1)
|
||||
stmts.append(parserdata.Rule(data.StringExpansion(target, None),
|
||||
data.StringExpansion(deps, None), False))
|
||||
stmts.append(parserdata.Rule(get_expansion(target),
|
||||
get_expansion(deps), False))
|
||||
return stmts
|
||||
|
||||
def parsestring(s, filename):
|
||||
|
1
build/pymake/tests/includedeps-variables.deps
Normal file
1
build/pymake/tests/includedeps-variables.deps
Normal file
@ -0,0 +1 @@
|
||||
$(FILE)1: filemissing
|
10
build/pymake/tests/includedeps-variables.mk
Normal file
10
build/pymake/tests/includedeps-variables.mk
Normal file
@ -0,0 +1,10 @@
|
||||
#T gmake skip
|
||||
|
||||
FILE = includedeps-variables
|
||||
|
||||
all: $(FILE)1
|
||||
|
||||
includedeps $(TESTPATH)/includedeps-variables.deps
|
||||
|
||||
filemissing:
|
||||
@echo TEST-PASS
|
Loading…
Reference in New Issue
Block a user