mirror of https://gitlab.com/ita1024/waf.git
gccdeps: Rename some variables
Rename some local variables to clarify their purpose and to align with msvcdeps.py.
This commit is contained in:
parent
615c32faef
commit
30508f53c2
|
@ -32,9 +32,10 @@ supported_compilers = ['gas', 'gcc', 'icc', 'clang']
|
||||||
def scan(self):
|
def scan(self):
|
||||||
if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS:
|
if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS:
|
||||||
return super(self.derived_gccdeps, self).scan()
|
return super(self.derived_gccdeps, self).scan()
|
||||||
nodes = self.generator.bld.node_deps.get(self.uid(), [])
|
|
||||||
names = []
|
resolved_nodes = self.generator.bld.node_deps.get(self.uid(), [])
|
||||||
return (nodes, names)
|
unresolved_names = []
|
||||||
|
return (resolved_nodes, unresolved_names)
|
||||||
|
|
||||||
re_o = re.compile(r"\.o$")
|
re_o = re.compile(r"\.o$")
|
||||||
re_splitter = re.compile(r'(?<!\\)\s+') # split by space, except when spaces are escaped
|
re_splitter = re.compile(r'(?<!\\)\s+') # split by space, except when spaces are escaped
|
||||||
|
@ -75,14 +76,13 @@ def post_run(self):
|
||||||
if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS:
|
if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS:
|
||||||
return super(self.derived_gccdeps, self).post_run()
|
return super(self.derived_gccdeps, self).post_run()
|
||||||
|
|
||||||
name = self.outputs[0].abspath()
|
deps_filename = self.outputs[0].abspath()
|
||||||
name = re_o.sub('.d', name)
|
deps_filename = re_o.sub('.d', deps_filename)
|
||||||
try:
|
try:
|
||||||
txt = Utils.readf(name)
|
deps_txt = Utils.readf(deps_filename)
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
Logs.error('Could not find a .d dependency file, are cflags/cxxflags overwritten?')
|
Logs.error('Could not find a .d dependency file, are cflags/cxxflags overwritten?')
|
||||||
raise
|
raise
|
||||||
#os.remove(name)
|
|
||||||
|
|
||||||
# Compilers have the choice to either output the file's dependencies
|
# Compilers have the choice to either output the file's dependencies
|
||||||
# as one large Makefile rule:
|
# as one large Makefile rule:
|
||||||
|
@ -102,15 +102,16 @@ def post_run(self):
|
||||||
# So the first step is to sanitize the input by stripping out the left-
|
# So the first step is to sanitize the input by stripping out the left-
|
||||||
# hand side of all these lines. After that, whatever remains are the
|
# hand side of all these lines. After that, whatever remains are the
|
||||||
# implicit dependencies of task.outputs[0]
|
# implicit dependencies of task.outputs[0]
|
||||||
txt = '\n'.join([remove_makefile_rule_lhs(line) for line in txt.splitlines()])
|
deps_txt = '\n'.join([remove_makefile_rule_lhs(line) for line in deps_txt.splitlines()])
|
||||||
|
|
||||||
# Now join all the lines together
|
# Now join all the lines together
|
||||||
txt = txt.replace('\\\n', '')
|
deps_txt = deps_txt.replace('\\\n', '')
|
||||||
|
|
||||||
val = txt.strip()
|
dep_paths = deps_txt.strip()
|
||||||
val = [x.replace('\\ ', ' ') for x in re_splitter.split(val) if x]
|
dep_paths = [x.replace('\\ ', ' ') for x in re_splitter.split(dep_paths) if x]
|
||||||
|
|
||||||
nodes = []
|
resolved_nodes = []
|
||||||
|
unresolved_names = []
|
||||||
bld = self.generator.bld
|
bld = self.generator.bld
|
||||||
|
|
||||||
# Dynamically bind to the cache
|
# Dynamically bind to the cache
|
||||||
|
@ -119,39 +120,41 @@ def post_run(self):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
cached_nodes = bld.cached_nodes = {}
|
cached_nodes = bld.cached_nodes = {}
|
||||||
|
|
||||||
for x in val:
|
for path in dep_paths:
|
||||||
|
|
||||||
node = None
|
node = None
|
||||||
if os.path.isabs(x):
|
if os.path.isabs(path):
|
||||||
node = path_to_node(bld.root, x, cached_nodes)
|
node = path_to_node(bld.root, path, cached_nodes)
|
||||||
else:
|
else:
|
||||||
# TODO waf 1.9 - single cwd value
|
# TODO waf 1.9 - single cwd value
|
||||||
path = getattr(bld, 'cwdx', bld.bldnode)
|
base_node = getattr(bld, 'cwdx', bld.bldnode)
|
||||||
# when calling find_resource, make sure the path does not contain '..'
|
# when calling find_resource, make sure the path does not contain '..'
|
||||||
x = [k for k in Utils.split_path(x) if k and k != '.']
|
path = [k for k in Utils.split_path(path) if k and k != '.']
|
||||||
while '..' in x:
|
while '..' in path:
|
||||||
idx = x.index('..')
|
idx = path.index('..')
|
||||||
if idx == 0:
|
if idx == 0:
|
||||||
x = x[1:]
|
path = path[1:]
|
||||||
path = path.parent
|
base_node = base_node.parent
|
||||||
else:
|
else:
|
||||||
del x[idx]
|
del path[idx]
|
||||||
del x[idx-1]
|
del path[idx-1]
|
||||||
|
|
||||||
node = path_to_node(path, x, cached_nodes)
|
node = path_to_node(base_node, path, cached_nodes)
|
||||||
|
|
||||||
if not node:
|
if not node:
|
||||||
raise ValueError('could not find %r for %r' % (x, self))
|
raise ValueError('could not find %r for %r' % (path, self))
|
||||||
|
|
||||||
if id(node) == id(self.inputs[0]):
|
if id(node) == id(self.inputs[0]):
|
||||||
# ignore the source file, it is already in the dependencies
|
# ignore the source file, it is already in the dependencies
|
||||||
# this way, successful config tests may be retrieved from the cache
|
# this way, successful config tests may be retrieved from the cache
|
||||||
continue
|
continue
|
||||||
nodes.append(node)
|
|
||||||
|
|
||||||
Logs.debug('deps: gccdeps for %s returned %s', self, nodes)
|
resolved_nodes.append(node)
|
||||||
|
|
||||||
bld.node_deps[self.uid()] = nodes
|
Logs.debug('deps: gccdeps for %s returned %s', self, resolved_nodes)
|
||||||
bld.raw_deps[self.uid()] = []
|
|
||||||
|
bld.node_deps[self.uid()] = resolved_nodes
|
||||||
|
bld.raw_deps[self.uid()] = unresolved_names
|
||||||
|
|
||||||
try:
|
try:
|
||||||
del self.cache_sig
|
del self.cache_sig
|
||||||
|
|
Loading…
Reference in New Issue