tools/binary_size/diagnose_bloat.py
def _TmpCopyBinarySizeDir():
  """Recursively copy files to a temp dir and yield temp paths."""
  # Needs to be at same level of nesting as the real //tools/binary_size
  # since supersize uses this to find d3 in //third_party.
  tmp_dir = tempfile.mkdtemp(dir=_SRC_ROOT)
  try:
    bs_dir = os.path.join(tmp_dir, 'binary_size')
    shutil.copytree(_BINARY_SIZE_DIR, bs_dir)
    # We also copy the tools supersize needs, but only if they exist.
    tool_prefix = None
    if os.path.exists(_CLANG_UPDATE_PATH):
      if not os.path.exists(os.path.join(_LLVM_TOOLS_DIR, 'llvm-readelf')):
        _RunCmd([_CLANG_UPDATE_PATH, '--package=objdump'])
      tools_dir = os.path.join(bs_dir, 'bintools')
      tool_prefix = os.path.join(tools_dir, 'llvm-')
      shutil.copytree(_LLVM_TOOLS_DIR, tools_dir)
    yield (os.path.join(bs_dir, 'supersize'), tool_prefix)
  finally:
    shutil.rmtree(tmp_dir)
Recursively copy files to a temp dir and yield temp paths.
Recursively copy files to a temp dir and yield temp paths.
Recursively copy files to a temp dir and yield temp paths .
def _TmpCopyBinarySizeDir():
  tmp_dir = tempfile.mkdtemp(dir=_SRC_ROOT)
  try:
    bs_dir = os.path.join(tmp_dir, 'binary_size')
    shutil.copytree(_BINARY_SIZE_DIR, bs_dir)
    tool_prefix = None
    if os.path.exists(_CLANG_UPDATE_PATH):
      if not os.path.exists(os.path.join(_LLVM_TOOLS_DIR, 'llvm-readelf')):
        _RunCmd([_CLANG_UPDATE_PATH, '--package=objdump'])
      tools_dir = os.path.join(bs_dir, 'bintools')
      tool_prefix = os.path.join(tools_dir, 'llvm-')
      shutil.copytree(_LLVM_TOOLS_DIR, tools_dir)
    yield (os.path.join(bs_dir, 'supersize'), tool_prefix)
  finally:
    shutil.rmtree(tmp_dir)
def _TmpCopyBinarySizeDir ( ) : tmp_dir = tempfile . mkdtemp ( dir = _SRC_ROOT ) try : bs_dir = os . path . join ( tmp_dir , 'binary_size' ) shutil . copytree ( _BINARY_SIZE_DIR , bs_dir ) tool_prefix = None if os . path . exists ( _CLANG_UPDATE_PATH ) : if not os . path . exists ( os . path . join ( _LLVM_TOOLS_DIR , 'llvm-readelf' ) ) : _RunCmd ( [ _CLANG_UPDATE_PATH , '--package=objdump' ] ) tools_dir = os . path . join ( bs_dir , 'bintools' ) tool_prefix = os . path . join ( tools_dir , 'llvm-' ) shutil . copytree ( _LLVM_TOOLS_DIR , tools_dir ) yield ( os . path . join ( bs_dir , 'supersize' ) , tool_prefix ) finally : shutil . rmtree ( tmp_dir )
Recursively copy files to a temp dir and yield temp paths.
Recursively copy files to a temp dir and yield temp paths .
"""Recursively copy files to a temp dir and yield temp paths.""" # Needs to be at same level of nesting as the real //tools/binary_size # since supersize uses this to find d3 in //third_party. # We also copy the tools supersize needs, but only if they exist.