Bug 1394071 - Ignore moz.build files that should be ignored; r?mshal
Before, the "relevant" moz.build files were based strictly on filename.
In reality, there are some moz.build files that we wish to ignore.
The previous commit introduced a Finder that knows how to ignore
moz.build files that should be ignored. In this commit, we hook
it up to our low-level function for determining the set of relevant
moz.build files for a path.
The main benefit of this change is that paths in the moz.build
test directory no longer say test moz.build files are relevant.
Previously, we would return these test moz.build files. Some of
these are invalid and would cause execution to fail. So, commands
like `mach file-info` will no longer attempt to evaluate moz.build
files they weren't supposed to and will stop erroring.
Another benefit is that the function returns faster. When passing
in every file in the repo (>230,000 files), execution time dropped
from ~8.03s to ~6.16s. This is probably due to fewer path operations.
MozReview-Commit-ID: J2d25ZtxjFt
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -1230,34 +1230,33 @@ class BuildReader(object):
Returns a dict of input paths to a list of relevant moz.build files.
The root moz.build file is first and the leaf-most moz.build is last.
"""
root = self.config.topsrcdir
result = {}
@memoize
def exists(path):
- return self._finder.get(path) is not None
+ return self._relevant_mozbuild_finder.get(path) is not None
def itermozbuild(path):
subpath = ''
yield 'moz.build'
for part in mozpath.split(path):
subpath = mozpath.join(subpath, part)
yield mozpath.join(subpath, 'moz.build')
for path in sorted(paths):
path = mozpath.normpath(path)
if os.path.isabs(path):
if not mozpath.basedir(path, [root]):
raise Exception('Path outside topsrcdir: %s' % path)
path = mozpath.relpath(path, root)
- result[path] = [p for p in itermozbuild(path)
- if exists(mozpath.join(root, p))]
+ result[path] = [p for p in itermozbuild(path) if exists(p)]
return result
def read_relevant_mozbuilds(self, paths):
"""Read and process moz.build files relevant for a set of paths.
For an iterable of relative-to-root filesystem paths ``paths``,
find all moz.build files that may apply to them based on filesystem