parameters: (self, paths)
return_statement: return result, all_contexts
docstring: 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
          hierarchy and read those moz.build files.
  
          The return value is a 2-tuple. The first item is a dict mapping each
          input filesystem path to a list of Context instances that are relevant
          to that path. The second item is a list of all Context instances. Each
          Context instance is in both data structures.
docstring_summary: Read and process moz.build files relevant for a set of paths.
docstring_tokens: Read and process moz . build files relevant for a set of paths .
function: 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
          hierarchy and read those moz.build files.
  
          The return value is a 2-tuple. The first item is a dict mapping each
          input filesystem path to a list of Context instances that are relevant
          to that path. The second item is a list of all Context instances. Each
          Context instance is in both data structures.
          """
          relevants = self._find_relevant_mozbuilds(paths)
  
          topsrcdir = self.config.topsrcdir
  
          # Source moz.build file to directories to traverse.
          dirs = defaultdict(set)
          # Relevant path to absolute paths of relevant contexts.
          path_mozbuilds = {}
  
          # There is room to improve this code (and the code in
          # _find_relevant_mozbuilds) to better handle multiple files in the same
          # directory. Bug 1136966 tracks.
          for path, mbpaths in relevants.items():
              path_mozbuilds[path] = [mozpath.join(topsrcdir, p) for p in mbpaths]
  
              for i, mbpath in enumerate(mbpaths[0:-1]):
                  source_dir = mozpath.dirname(mbpath)
                  target_dir = mozpath.dirname(mbpaths[i + 1])
  
                  d = mozpath.normpath(mozpath.join(topsrcdir, mbpath))
                  dirs[d].add(mozpath.relpath(target_dir, source_dir))
  
          # Exporting doesn't work reliably in tree traversal mode. Override
          # the function to no-op.
          functions = dict(FUNCTIONS)
          def export(sandbox):
              return lambda varname: None
          functions['export'] = tuple([export] + list(FUNCTIONS['export'][1:]))
  
          metadata = {
              'functions': functions,
          }
  
          contexts = defaultdict(list)
          all_contexts = []
          for context in self.read_mozbuild(mozpath.join(topsrcdir, 'moz.build'),
                                            self.config, metadata=metadata):
              # Explicitly set directory traversal variables to override default
              # traversal rules.
              if not isinstance(context, SubContext):
                  for v in ('DIRS', 'GYP_DIRS'):
                      context[v][:] = []
  
                  context['DIRS'] = sorted(dirs[context.main_path])
  
              contexts[context.main_path].append(context)
              all_contexts.append(context)
  
          result = {}
          for path, paths in path_mozbuilds.items():
              result[path] = reduce(lambda x, y: x + y, (contexts[p] for p in paths), [])
  
          return result, all_contexts
function_tokens: def read_relevant_mozbuilds ( self , paths ) : relevants = self . _find_relevant_mozbuilds ( paths ) topsrcdir = self . config . topsrcdir # Source moz.build file to directories to traverse. dirs = defaultdict ( set ) # Relevant path to absolute paths of relevant contexts. path_mozbuilds = { } # There is room to improve this code (and the code in # _find_relevant_mozbuilds) to better handle multiple files in the same # directory. Bug 1136966 tracks. for path , mbpaths in relevants . items ( ) : path_mozbuilds [ path ] = [ mozpath . join ( topsrcdir , p ) for p in mbpaths ] for i , mbpath in enumerate ( mbpaths [ 0 : - 1 ] ) : source_dir = mozpath . dirname ( mbpath ) target_dir = mozpath . dirname ( mbpaths [ i + 1 ] ) d = mozpath . normpath ( mozpath . join ( topsrcdir , mbpath ) ) dirs [ d ] . add ( mozpath . relpath ( target_dir , source_dir ) ) # Exporting doesn't work reliably in tree traversal mode. Override # the function to no-op. functions = dict ( FUNCTIONS ) def export ( sandbox ) : return lambda varname : None functions [ 'export' ] = tuple ( [ export ] + list ( FUNCTIONS [ 'export' ] [ 1 : ] ) ) metadata = { 'functions' : functions , } contexts = defaultdict ( list ) all_contexts = [ ] for context in self . read_mozbuild ( mozpath . join ( topsrcdir , 'moz.build' ) , self . config , metadata = metadata ) : # Explicitly set directory traversal variables to override default # traversal rules. if not isinstance ( context , SubContext ) : for v in ( 'DIRS' , 'GYP_DIRS' ) : context [ v ] [ : ] = [ ] context [ 'DIRS' ] = sorted ( dirs [ context . main_path ] ) contexts [ context . main_path ] . append ( context ) all_contexts . append ( context ) result = { } for path , paths in path_mozbuilds . items ( ) : result [ path ] = reduce ( lambda x , y : x + y , ( contexts [ p ] for p in paths ) , [ ] ) return result , all_contexts