def FindBaseHost(tool): """ Find the base directory for host binaries (i.e. llvm/binutils) """ if env.has('BPREFIXES'): for prefix in env.get('BPREFIXES'): if os.path.exists(pathtools.join(prefix, 'bin', tool + env.getone('EXEC_EXT'))): return prefix base_pnacl = FindBasePNaCl() if not pathtools.exists(pathtools.join(base_pnacl, 'bin', tool + env.getone('EXEC_EXT'))): Log.Fatal('Could not find PNaCl host directory for ' + tool) return base_pnacl
def ReadConfig(): # Mock out ReadConfig if running unittests. Settings are applied directly # by DriverTestEnv rather than reading this configuration file. if env.has('PNACL_RUNNING_UNITTESTS'): return driver_bin = env.getone('DRIVER_BIN') driver_conf = pathtools.join(driver_bin, 'driver.conf') fp = DriverOpen(driver_conf, 'r') linecount = 0 for line in fp: linecount += 1 line = line.strip() if line == '' or line.startswith('#'): continue sep = line.find('=') if sep < 0: Log.Fatal("%s: Parse error, missing '=' on line %d", pathtools.touser(driver_conf), linecount) keyname = line[:sep].strip() value = line[sep + 1:].strip() env.setraw(keyname, value) DriverClose(fp) if env.getone('LIBMODE') not in ('newlib', 'glibc'): Log.Fatal('Invalid LIBMODE in %s', pathtools.touser(driver_conf))
def ReadConfig(): # Mock out ReadConfig if running unittests. Settings are applied directly # by DriverTestEnv rather than reading this configuration file. if env.has('PNACL_RUNNING_UNITTESTS'): return driver_bin = env.getone('DRIVER_BIN') driver_conf = pathtools.join(driver_bin, 'driver.conf') fp = DriverOpen(driver_conf, 'r') linecount = 0 for line in fp: linecount += 1 line = line.strip() if line == '' or line.startswith('#'): continue sep = line.find('=') if sep < 0: Log.Fatal("%s: Parse error, missing '=' on line %d", pathtools.touser(driver_conf), linecount) keyname = line[:sep].strip() value = line[sep+1:].strip() env.setraw(keyname, value) DriverClose(fp) if env.getone('LIBMODE') not in ('newlib', 'glibc'): Log.Fatal('Invalid LIBMODE in %s', pathtools.touser(driver_conf))
def GetThinArchiveData(archive_filename, member, strtab_data): # Get member's filename (relative to the archive) and open the member # ourselves to check the data. member_filename = GetMemberFilename(member, strtab_data) member_filename = pathtools.join( pathtools.dirname(pathtools.abspath(archive_filename)), member_filename) member_fp = driver_log.DriverOpen(member_filename, 'rb') data = member_fp.read(member.size) member_fp.close() return data
def ValidatePathLength(self, temp, imtype): temp = pathtools.normpath(temp) if temp else temp # If the temp name is too long, just pick a random one instead. if not CheckPathLength(temp, exit_on_failure=False): # imtype is sometimes just an extension, and sometimes a compound # extension (e.g. pre_opt.pexe). To keep name length shorter, # only take the last extension if '.' in imtype: imtype = imtype[imtype.rfind('.') + 1:] temp = pathtools.join( self.OutputDir, str(random.randrange(100000, 1000000)) + '.' + imtype) CheckPathLength(temp) return temp
def FindFile(search_names, search_dirs, acceptable_types): for curdir in search_dirs: for name in search_names: path = pathtools.join(curdir, name) if pathtools.exists(path): if acceptable_types == LibraryTypes.ANY: return path # Linker scripts aren't classified as Native or Bitcode. if IsLinkerScript(path): return path if acceptable_types == LibraryTypes.NATIVE and filetype.IsNative(path): return path if acceptable_types == LibraryTypes.BITCODE and ( filetype.IsLLVMBitcode(path) or filetype.IsBitcodeArchive(path) ): return path return None
def FindFile(search_names, search_dirs, acceptable_types): for curdir in search_dirs: for name in search_names: path = pathtools.join(curdir, name) if pathtools.exists(path): if acceptable_types == LibraryTypes.ANY: return path # Linker scripts aren't classified as Native or Bitcode. if IsLinkerScript(path): return path if (acceptable_types == LibraryTypes.NATIVE and driver_tools.IsNative(path)): return path if (acceptable_types == LibraryTypes.BITCODE and (driver_tools.IsLLVMBitcode(path) or driver_tools.IsBitcodeArchive(path))): return path return None
def ReadConfig(): driver_bin = env.getone('DRIVER_BIN') driver_conf = pathtools.join(driver_bin, 'driver.conf') fp = DriverOpen(driver_conf, 'r') linecount = 0 for line in fp: linecount += 1 line = line.strip() if line == '' or line.startswith('#'): continue sep = line.find('=') if sep < 0: Log.Fatal("%s: Parse error, missing '=' on line %d", pathtools.touser(driver_conf), linecount) keyname = line[:sep].strip() value = line[sep+1:].strip() env.setraw(keyname, value) DriverClose(fp) if env.getone('LIBMODE') not in ('newlib', 'glibc'): Log.Fatal('Invalid LIBMODE in %s', pathtools.touser(driver_conf))