tools/android/modularization/convenience/lookup_dep.py
def _index_root(self) -> Dict[str, List[TargetInfo]]:
    """Create the class to target index."""
    logging.debug('Running list_java_targets.py...')
    list_java_targets_command = [
        'build/android/list_java_targets.py', '--gn-labels',
        '--print-build-config-paths',
        f'--output-directory={self._abs_build_output_dir}'
    ]
    if self._should_build:
      list_java_targets_command += ['--build']

    list_java_targets_run = subprocess.run(list_java_targets_command,
                                           cwd=_SRC_DIR,
                                           capture_output=True,
                                           text=True,
                                           check=True)
    logging.debug('... done.')

    # Parse output of list_java_targets.py with mapping of build_target to
    # build_config
    root_build_targets = list_java_targets_run.stdout.split('\n')
    class_index = collections.defaultdict(list)
    for target_line in root_build_targets:
      # Skip empty lines
      if not target_line:
        continue

      target_line_parts = target_line.split(': ')
      assert len(target_line_parts) == 2, target_line_parts
      target, build_config_path = target_line_parts

      if not os.path.exists(build_config_path):
        assert not self._should_build
        continue

      with open(build_config_path) as build_config_contents:
        build_config: Dict = json.load(build_config_contents)
      deps_info = build_config['deps_info']
      # Checking the library type here instead of in list_java_targets.py avoids
      # reading each .build_config file twice.
      if deps_info['type'] != 'java_library':
        continue

      target = self._compute_toplevel_target(target)
      low_classpath_priority = bool(deps_info.get('low_classpath_priority'))
      target_info = TargetInfo(target, low_classpath_priority)
      full_class_names = self._compute_full_class_names_for_build_config(
          deps_info)
      for full_class_name in full_class_names:
        class_index[full_class_name].append(target_info)

    return class_index
Create the class to target index.
Create the class to target index.
Create the class to target index .
def _index_root(self) -> Dict[str, List[TargetInfo]]:
    logging.debug('Running list_java_targets.py...')
    list_java_targets_command = [
        'build/android/list_java_targets.py', '--gn-labels',
        '--print-build-config-paths',
        f'--output-directory={self._abs_build_output_dir}'
    ]
    if self._should_build:
      list_java_targets_command += ['--build']
    list_java_targets_run = subprocess.run(list_java_targets_command,
                                           cwd=_SRC_DIR,
                                           capture_output=True,
                                           text=True,
                                           check=True)
    logging.debug('... done.')
    root_build_targets = list_java_targets_run.stdout.split('\n')
    class_index = collections.defaultdict(list)
    for target_line in root_build_targets:
      if not target_line:
        continue
      target_line_parts = target_line.split(': ')
      assert len(target_line_parts) == 2, target_line_parts
      target, build_config_path = target_line_parts
      if not os.path.exists(build_config_path):
        assert not self._should_build
        continue
      with open(build_config_path) as build_config_contents:
        build_config: Dict = json.load(build_config_contents)
      deps_info = build_config['deps_info']
      if deps_info['type'] != 'java_library':
        continue
      target = self._compute_toplevel_target(target)
      low_classpath_priority = bool(deps_info.get('low_classpath_priority'))
      target_info = TargetInfo(target, low_classpath_priority)
      full_class_names = self._compute_full_class_names_for_build_config(
          deps_info)
      for full_class_name in full_class_names:
        class_index[full_class_name].append(target_info)
    return class_index
def _index_root ( self ) -> Dict [ str , List [ TargetInfo ] ] : logging . debug ( 'Running list_java_targets.py...' ) list_java_targets_command = [ 'build/android/list_java_targets.py' , '--gn-labels' , '--print-build-config-paths' , f'--output-directory={self._abs_build_output_dir}' ] if self . _should_build : list_java_targets_command += [ '--build' ] list_java_targets_run = subprocess . run ( list_java_targets_command , cwd = _SRC_DIR , capture_output = True , text = True , check = True ) logging . debug ( '... done.' ) root_build_targets = list_java_targets_run . stdout . split ( '\n' ) class_index = collections . defaultdict ( list ) for target_line in root_build_targets : if not target_line : continue target_line_parts = target_line . split ( ': ' ) assert len ( target_line_parts ) == 2 , target_line_parts target , build_config_path = target_line_parts if not os . path . exists ( build_config_path ) : assert not self . _should_build continue with open ( build_config_path ) as build_config_contents : build_config : Dict = json . load ( build_config_contents ) deps_info = build_config [ 'deps_info' ] if deps_info [ 'type' ] != 'java_library' : continue target = self . _compute_toplevel_target ( target ) low_classpath_priority = bool ( deps_info . get ( 'low_classpath_priority' ) ) target_info = TargetInfo ( target , low_classpath_priority ) full_class_names = self . _compute_full_class_names_for_build_config ( deps_info ) for full_class_name in full_class_names : class_index [ full_class_name ] . append ( target_info ) return class_index
Create the class to target index.
Create the class to target index .
"""Create the class to target index.""" # Parse output of list_java_targets.py with mapping of build_target to # build_config # Skip empty lines # Checking the library type here instead of in list_java_targets.py avoids # reading each .build_config file twice.
self