native_client_sdk/src/tools/lib/get_shared_deps.py
def GleanFromObjdump(files, arch, objdump, lib_path):
  '''Get architecture and dependency information for given files

  Args:
    files: A list of files to examine.
        [ '/path/to/my.nexe',
          '/path/to/lib64/libmy.so',
          '/path/to/mydata.so',
          '/path/to/my.data' ]
    arch: The architecure we are looking for, or None to accept any
          architecture.
    objdump: Path to the objdump executable.
    lib_path: A list of paths to search for shared libraries.

  Returns: A tuple with the following members:
    input_info: A dict with key=filename and value=architecture. The
        architecture will be one of ('x86_32', 'x86_64', 'arm').
    needed: A set of strings formatted as "arch/name".  Example:
        set(['x86-32/libc.so', 'x86-64/libgcc.so'])
  '''
  if not objdump:
    raise NoObjdumpError('No objdump executable found!')

  full_paths = set()
  for filename in files:
    if os.path.exists(filename):
      full_paths.add(filename)
    else:
      for path in _FindLibsInPath(filename, lib_path):
        full_paths.add(path)

  cmd = [objdump, '-p'] + list(sorted(full_paths))
  env = {'LANG': 'en_US.UTF-8'}
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE, bufsize=-1,
                          universal_newlines=True,
                          env=env)

  input_info = {}
  found_basenames = set()
  needed = set()
  output, err_output = proc.communicate()
  if proc.returncode:
    raise Error('%s\nStdError=%s\nobjdump failed with error code: %d' %
                (output, err_output, proc.returncode))

  file_arch = None
  for line in output.splitlines(True):
    # Objdump should display the architecture first and then the dependencies
    # second for each file in the list.
    matched = FormatMatcher.match(line)
    if matched:
      filename = matched.group(1)
      file_arch = OBJDUMP_ARCH_MAP[matched.group(2)]
      if arch and file_arch != arch:
        continue
      name = os.path.basename(filename)
      found_basenames.add(name)
      input_info[filename] = file_arch
    matched = NeededMatcher.match(line)
    if matched:
      if arch and file_arch != arch:
        continue
      filename = matched.group(1)
      new_needed = (filename, file_arch)
      needed.add(new_needed)

  for filename in files:
    if os.path.basename(filename) not in found_basenames:
      raise Error('Library not found [%s]: %s' % (arch, filename))

  return input_info, needed
Get architecture and dependency information for given files

  Args:
    files: A list of files to examine.
        [ '/path/to/my.nexe',
          '/path/to/lib64/libmy.so',
          '/path/to/mydata.so',
          '/path/to/my.data' ]
    arch: The architecure we are looking for, or None to accept any
          architecture.
    objdump: Path to the objdump executable.
    lib_path: A list of paths to search for shared libraries.

  Returns: A tuple with the following members:
    input_info: A dict with key=filename and value=architecture. The
        architecture will be one of ('x86_32', 'x86_64', 'arm').
    needed: A set of strings formatted as "arch/name".  Example:
        set(['x86-32/libc.so', 'x86-64/libgcc.so'])
  
Get architecture and dependency information for given files
Get architecture and dependency information for given files
def GleanFromObjdump(files, arch, objdump, lib_path):
  if not objdump:
    raise NoObjdumpError('No objdump executable found!')
  full_paths = set()
  for filename in files:
    if os.path.exists(filename):
      full_paths.add(filename)
    else:
      for path in _FindLibsInPath(filename, lib_path):
        full_paths.add(path)
  cmd = [objdump, '-p'] + list(sorted(full_paths))
  env = {'LANG': 'en_US.UTF-8'}
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE, bufsize=-1,
                          universal_newlines=True,
                          env=env)
  input_info = {}
  found_basenames = set()
  needed = set()
  output, err_output = proc.communicate()
  if proc.returncode:
    raise Error('%s\nStdError=%s\nobjdump failed with error code: %d' %
                (output, err_output, proc.returncode))
  file_arch = None
  for line in output.splitlines(True):
    matched = FormatMatcher.match(line)
    if matched:
      filename = matched.group(1)
      file_arch = OBJDUMP_ARCH_MAP[matched.group(2)]
      if arch and file_arch != arch:
        continue
      name = os.path.basename(filename)
      found_basenames.add(name)
      input_info[filename] = file_arch
    matched = NeededMatcher.match(line)
    if matched:
      if arch and file_arch != arch:
        continue
      filename = matched.group(1)
      new_needed = (filename, file_arch)
      needed.add(new_needed)
  for filename in files:
    if os.path.basename(filename) not in found_basenames:
      raise Error('Library not found [%s]: %s' % (arch, filename))
  return input_info, needed
def GleanFromObjdump ( files , arch , objdump , lib_path ) : if not objdump : raise NoObjdumpError ( 'No objdump executable found!' ) full_paths = set ( ) for filename in files : if os . path . exists ( filename ) : full_paths . add ( filename ) else : for path in _FindLibsInPath ( filename , lib_path ) : full_paths . add ( path ) cmd = [ objdump , '-p' ] + list ( sorted ( full_paths ) ) env = { 'LANG' : 'en_US.UTF-8' } proc = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE , bufsize = - 1 , universal_newlines = True , env = env ) input_info = { } found_basenames = set ( ) needed = set ( ) output , err_output = proc . communicate ( ) if proc . returncode : raise Error ( '%s\nStdError=%s\nobjdump failed with error code: %d' % ( output , err_output , proc . returncode ) ) file_arch = None for line in output . splitlines ( True ) : matched = FormatMatcher . match ( line ) if matched : filename = matched . group ( 1 ) file_arch = OBJDUMP_ARCH_MAP [ matched . group ( 2 ) ] if arch and file_arch != arch : continue name = os . path . basename ( filename ) found_basenames . add ( name ) input_info [ filename ] = file_arch matched = NeededMatcher . match ( line ) if matched : if arch and file_arch != arch : continue filename = matched . group ( 1 ) new_needed = ( filename , file_arch ) needed . add ( new_needed ) for filename in files : if os . path . basename ( filename ) not in found_basenames : raise Error ( 'Library not found [%s]: %s' % ( arch , filename ) ) return input_info , needed
Get architecture and dependency information for given files
Get architecture and dependency information for given files
'''Get architecture and dependency information for given files

  Args:
    files: A list of files to examine.
        [ '/path/to/my.nexe',
          '/path/to/lib64/libmy.so',
          '/path/to/mydata.so',
          '/path/to/my.data' ]
    arch: The architecure we are looking for, or None to accept any
          architecture.
    objdump: Path to the objdump executable.
    lib_path: A list of paths to search for shared libraries.

  Returns: A tuple with the following members:
    input_info: A dict with key=filename and value=architecture. The
        architecture will be one of ('x86_32', 'x86_64', 'arm').
    needed: A set of strings formatted as "arch/name".  Example:
        set(['x86-32/libc.so', 'x86-64/libgcc.so'])
  ''' # Objdump should display the architecture first and then the dependencies # second for each file in the list.
files
A list of files to examine.
A list of files to examine .
arch
The architecure we are looking for, or None to accept any
architecture.
The architecure we are looking for or None to accept any architecture .
objdump
Path to the objdump executable.
Path to the objdump executable .
lib_path
A list of paths to search for shared libraries.
A list of paths to search for shared libraries .