Esempio n. 1
0
def Run(args, on_config_error):
    # Up-front check for faster error-checking.
    for path in args.inputs:
        if not path.endswith('.size') and not path.endswith('.sizediff'):
            on_config_error('All inputs must end with ".size" or ".sizediff"')

    size_infos = []
    for path in args.inputs:
        if path.endswith('.sizediff'):
            size_infos.extend(archive.LoadAndPostProcessDeltaSizeInfo(path))
        else:
            size_infos.append(archive.LoadAndPostProcessSizeInfo(path))
    output_directory_finder = path_util.OutputDirectoryFinder(
        value=args.output_directory,
        any_path_within_output_directory=args.inputs[0])
    linker_name = size_infos[-1].build_config.get(
        models.BUILD_CONFIG_LINKER_NAME)
    tool_prefix_finder = path_util.ToolPrefixFinder(
        value=args.tool_prefix,
        output_directory=output_directory_finder.Tentative(),
        linker_name=linker_name)
    session = _Session(size_infos, output_directory_finder, tool_prefix_finder)

    if args.query:
        logging.info('Running query from command-line.')
        session.Eval(args.query)
    else:
        logging.info('Entering interactive console.')
        session.GoInteractive()
Esempio n. 2
0
  def test_SaveDeltaSizeInfo(self):
    # Check that saving & loading is the same as directly parsing.
    orig_info1 = self._CloneSizeInfo(use_apk=True, use_aux_elf=True)
    orig_info2 = self._CloneSizeInfo(use_elf=True)
    orig_delta = diff.Diff(orig_info1, orig_info2)

    with tempfile.NamedTemporaryFile(suffix='.sizediff') as sizediff_file:
      file_format.SaveDeltaSizeInfo(orig_delta, sizediff_file.name)
      new_info1, new_info2 = archive.LoadAndPostProcessDeltaSizeInfo(
          sizediff_file.name)
    new_delta = diff.Diff(new_info1, new_info2)

    # File format discards unchanged symbols.
    orig_delta.raw_symbols = orig_delta.raw_symbols.WhereDiffStatusIs(
        models.DIFF_STATUS_UNCHANGED).Inverted()

    self.assertEqual(
        '\n'.join(describe.GenerateLines(orig_delta, verbose=True)),
        '\n'.join(describe.GenerateLines(new_delta, verbose=True)))
Esempio n. 3
0
def Run(args, on_config_error):
    # Up-front check for faster error-checking.
    for path in args.inputs:
        if not path.endswith('.size') and not path.endswith('.sizediff'):
            on_config_error('All inputs must end with ".size" or ".sizediff"')

    size_infos = []
    for path in args.inputs:
        if path.endswith('.sizediff'):
            size_infos.extend(archive.LoadAndPostProcessDeltaSizeInfo(path))
        else:
            size_infos.append(archive.LoadAndPostProcessSizeInfo(path))
    output_directory_finder = path_util.OutputDirectoryFinder(
        value=args.output_directory,
        any_path_within_output_directory=args.inputs[0])
    linker_name = size_infos[-1].build_config.get(
        models.BUILD_CONFIG_LINKER_NAME)
    tool_prefix_finder = path_util.ToolPrefixFinder(
        value=args.tool_prefix,
        output_directory=output_directory_finder.Tentative(),
        linker_name=linker_name)
    session = _Session(size_infos, output_directory_finder, tool_prefix_finder)

    if args.query:
        logging.info('Running query from command-line.')
        session.Eval(args.query)
    else:
        logging.info('Entering interactive console.')
        session.GoInteractive()

    # Exit without running GC, which can save multiple seconds due the large
    # number of objects created. It meants atexit and __del__ calls are not
    # made, but this shouldn't matter for console.
    sys.stdout.flush()
    sys.stderr.flush()
    os._exit(0)