use std::fs;
use std::path::{Path, PathBuf};
-use crate::search_paths::{SearchPath, PathKind};
-use rustc_fs_util::fix_windows_verbatim_for_gcc;
+use crate::search_paths::{PathKind, SearchPath};
use log::debug;
+use rustc_fs_util::fix_windows_verbatim_for_gcc;
#[derive(Copy, Clone)]
pub enum FileMatch {
impl<'a> FileSearch<'a> {
pub fn search_paths(&self) -> impl Iterator<Item = &'a SearchPath> {
let kind = self.kind;
- self.search_paths.iter()
+ self.search_paths
+ .iter()
.filter(move |sp| sp.kind.matches(kind))
.chain(std::iter::once(self.tlib_path))
}
}
pub fn search<F>(&self, mut pick: F)
- where F: FnMut(&Path, PathKind) -> FileMatch
+ where
+ F: FnMut(&Path, PathKind) -> FileMatch,
{
for search_path in self.search_paths() {
debug!("searching {}", search_path.dir.display());
}
}
- pub fn new(sysroot: &'a Path,
- triple: &'a str,
- search_paths: &'a Vec<SearchPath>,
- tlib_path: &'a SearchPath,
- kind: PathKind)
- -> FileSearch<'a> {
+ pub fn new(
+ sysroot: &'a Path,
+ triple: &'a str,
+ search_paths: &'a Vec<SearchPath>,
+ tlib_path: &'a SearchPath,
+ kind: PathKind,
+ ) -> FileSearch<'a> {
debug!("using sysroot = {}, triple = {}", sysroot.display(), triple);
- FileSearch {
- sysroot,
- triple,
- search_paths,
- tlib_path,
- kind,
- }
+ FileSearch { sysroot, triple, search_paths, tlib_path, kind }
}
// Returns just the directories within the search paths.
pub fn search_path_dirs(&self) -> Vec<PathBuf> {
- self.search_paths()
- .map(|sp| sp.dir.to_path_buf())
- .collect()
+ self.search_paths().map(|sp| sp.dir.to_path_buf()).collect()
}
// Returns a list of directories where target-specific tool binaries are located.
}
match env::current_exe() {
- Ok(exe) => {
- match canonicalize(Some(exe)) {
- Some(mut p) => { p.pop(); p.pop(); p },
- None => panic!("can't determine value for sysroot")
+ Ok(exe) => match canonicalize(Some(exe)) {
+ Some(mut p) => {
+ p.pop();
+ p.pop();
+ p
}
- }
- Err(ref e) => panic!(format!("failed to get current_exe: {}", e))
+ None => panic!("can't determine value for sysroot"),
+ },
+ Err(ref e) => panic!(format!("failed to get current_exe: {}", e)),
}
}
match option_env!("CFG_LIBDIR_RELATIVE") {
Some(libdir) if libdir != "lib" => libdir.into(),
- _ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
- PRIMARY_LIB_DIR.into()
- } else {
- SECONDARY_LIB_DIR.into()
+ _ => {
+ if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
+ PRIMARY_LIB_DIR.into()
+ } else {
+ SECONDARY_LIB_DIR.into()
+ }
}
}
}