def GetNeeded(self): """Collect the list of dependencies for the main_files Returns: A dict with key=filename and value=ArchFile of input files. Includes the input files as well, with arch filled in if absent. Example: { '/path/to/my.nexe': ArchFile(my.nexe), '/path/to/libfoo.so': ArchFile(libfoo.so) }""" if self.needed: return self.needed DebugPrint('GetNeeded(%s)' % self.main_files) if not self.objdump: self.objdump = FindObjdumpExecutable() try: all_files = get_shared_deps.GetNeeded(self.main_files, self.objdump, self.lib_path) except get_shared_deps.NoObjdumpError: raise Error( 'No objdump executable found (see --help for more info)') except get_shared_deps.Error, e: raise Error(str(e))
def testCorrectArch(self): lib_path = [os.path.join(self.toolchain, 'x86_64-nacl', 'lib32'), os.path.join(self.toolchain, 'x86_64-nacl', 'lib')] needed = get_shared_deps.GetNeeded([self.dyn_nexe], lib_path=lib_path, objdump=self.objdump) for arch in needed.itervalues(): self.assertEqual(arch, 'x86-32')
def testDynamic(self): libdir = os.path.join(self.toolchain, 'x86_64-nacl', 'lib32') needed = get_shared_deps.GetNeeded([self.dyn_nexe], lib_path=[libdir], objdump=self.objdump) names = needed.keys() # this nexe has 5 dependencies expected = set(self.dyn_deps) expected.add(os.path.basename(self.dyn_nexe)) basenames = set(StripDependencies(names)) self.assertEqual(expected, basenames)
def testStatic(self): nexe = os.path.join(DATA_DIR, 'test_static_x86_32.nexe') # GetNeeded should not raise an error if objdump is not set, but the .nexe # is statically linked. objdump = None lib_path = [] needed = get_shared_deps.GetNeeded([nexe], objdump, lib_path) # static nexe should have exactly one needed file self.assertEqual(len(needed), 1) self.assertEqual(needed.keys()[0], nexe) # arch of needed file should be x86-32 arch = needed.values()[0] self.assertEqual(arch, 'x86-32')
def GetNeeded(self): """Collect the list of dependencies for the main_files Returns: A dict with key=filename and value=ArchFile of input files. Includes the input files as well, with arch filled in if absent. Example: { '/path/to/my.nexe': ArchFile(my.nexe), '/path/to/libfoo.so': ArchFile(libfoo.so) }""" if self.needed: return self.needed DebugPrint('GetNeeded(%s)' % self.main_files) if not self.objdump: self.objdump = FindObjdumpExecutable() try: all_files = get_shared_deps.GetNeeded(self.main_files, self.objdump, self.lib_path) except get_shared_deps.NoObjdumpError: raise Error( 'No objdump executable found (see --help for more info)') except get_shared_deps.Error as e: raise Error(str(e)) self.needed = {} # all_files is a dictionary mapping filename to architecture. self.needed # should be a dictionary of filename to ArchFile. for filename, arch in all_files.items(): name = os.path.basename(filename) self.needed[filename] = ArchFile(name=name, path=filename, arch=arch) self._SetArchFileUrls() return self.needed