Move rustc::util::fs into separate (new) crate
This commit is contained in:
parent
bf103700c6
commit
e3177c6f3f
@ -1887,6 +1887,7 @@ dependencies = [
|
||||
"rustc_apfloat 0.0.0",
|
||||
"rustc_data_structures 0.0.0",
|
||||
"rustc_errors 0.0.0",
|
||||
"rustc_fs_util 0.0.0",
|
||||
"rustc_target 0.0.0",
|
||||
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serialize 0.0.0",
|
||||
@ -2185,6 +2186,10 @@ dependencies = [
|
||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_fs_util"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_incremental"
|
||||
version = "0.0.0"
|
||||
@ -2194,6 +2199,7 @@ dependencies = [
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc 0.0.0",
|
||||
"rustc_data_structures 0.0.0",
|
||||
"rustc_fs_util 0.0.0",
|
||||
"serialize 0.0.0",
|
||||
"syntax 0.0.0",
|
||||
"syntax_pos 0.0.0",
|
||||
|
@ -32,6 +32,7 @@ backtrace = "0.3.3"
|
||||
parking_lot = "0.5.5"
|
||||
byteorder = { version = "1.1", features = ["i128"]}
|
||||
chalk-engine = { version = "0.6.0", default-features=false }
|
||||
rustc_fs_util = { path = "../librustc_fs_util" }
|
||||
|
||||
# Note that these dependencies are a lie, they're just here to get linkage to
|
||||
# work.
|
||||
|
@ -99,6 +99,7 @@ extern crate syntax_pos;
|
||||
extern crate jobserver;
|
||||
extern crate proc_macro;
|
||||
extern crate chalk_engine;
|
||||
extern crate rustc_fs_util;
|
||||
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
||||
@ -162,7 +163,6 @@ pub mod util {
|
||||
pub mod common;
|
||||
pub mod ppaux;
|
||||
pub mod nodemap;
|
||||
pub mod fs;
|
||||
pub mod time_graph;
|
||||
pub mod profiling;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use session::search_paths::{SearchPaths, PathKind};
|
||||
use util::fs as rustcfs;
|
||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum FileMatch {
|
||||
@ -151,7 +151,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
||||
// See comments on this target function, but the gist is that
|
||||
// gcc chokes on verbatim paths which fs::canonicalize generates
|
||||
// so we try to avoid those kinds of paths.
|
||||
Ok(canon) => Some(rustcfs::fix_windows_verbatim_for_gcc(&canon)),
|
||||
Ok(canon) => Some(fix_windows_verbatim_for_gcc(&canon)),
|
||||
Err(e) => bug!("failed to get realpath: {}", e),
|
||||
}
|
||||
})
|
||||
|
@ -26,7 +26,7 @@ use rustc::middle::cstore::{NativeLibrary, LibSource, NativeLibraryKind};
|
||||
use rustc::middle::dependency_format::Linkage;
|
||||
use {CodegenResults, CrateInfo};
|
||||
use rustc::util::common::time;
|
||||
use rustc::util::fs::fix_windows_verbatim_for_gcc;
|
||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||
use rustc::hir::def_id::CrateNum;
|
||||
use tempfile::{Builder as TempFileBuilder, TempDir};
|
||||
use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};
|
||||
|
@ -31,7 +31,7 @@ use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::util::common::{time_ext, time_depth, set_time_depth, print_time_passes_entry};
|
||||
use rustc::util::common::path2cstr;
|
||||
use rustc::util::fs::{link_or_copy};
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use errors::{self, Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId};
|
||||
use errors::emitter::{Emitter};
|
||||
use syntax::attr;
|
||||
|
@ -55,6 +55,7 @@ extern crate rustc_incremental;
|
||||
extern crate rustc_llvm;
|
||||
extern crate rustc_platform_intrinsics as intrinsics;
|
||||
extern crate rustc_codegen_utils;
|
||||
extern crate rustc_fs_util;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
|
11
src/librustc_fs_util/Cargo.toml
Normal file
11
src/librustc_fs_util/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustc_fs_util"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
name = "rustc_fs_util"
|
||||
path = "lib.rs"
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
@ -8,8 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::path::{self, Path, PathBuf};
|
||||
use std::ffi::OsString;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
@ -29,10 +28,10 @@ use std::io;
|
||||
//
|
||||
// For some more information, see this comment:
|
||||
// https://github.com/rust-lang/rust/issues/25505#issuecomment-102876737
|
||||
#[cfg(windows)]
|
||||
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
|
||||
if !cfg!(windows) {
|
||||
return p.to_path_buf();
|
||||
}
|
||||
use std::path;
|
||||
use std::ffi::OsString;
|
||||
let mut components = p.components();
|
||||
let prefix = match components.next() {
|
||||
Some(path::Component::Prefix(p)) => p,
|
||||
@ -56,6 +55,11 @@ pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
|
||||
p.to_path_buf()
|
||||
}
|
||||
|
||||
pub enum LinkOrCopy {
|
||||
Link,
|
||||
Copy,
|
@ -17,3 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
serialize = { path = "../libserialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rustc_fs_util = { path = "../librustc_fs_util" }
|
||||
|
@ -23,6 +23,7 @@ extern crate graphviz;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate serialize as rustc_serialize;
|
||||
extern crate rand;
|
||||
extern crate rustc_fs_util;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
extern crate syntax;
|
||||
|
@ -115,7 +115,7 @@
|
||||
//! implemented.
|
||||
|
||||
use rustc::session::{Session, CrateDisambiguator};
|
||||
use rustc::util::fs as fs_util;
|
||||
use rustc_fs_util::{link_or_copy, LinkOrCopy};
|
||||
use rustc_data_structures::{flock, base_n};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
||||
use rustc_data_structures::svh::Svh;
|
||||
@ -429,11 +429,11 @@ fn copy_files(sess: &Session,
|
||||
let source_path = entry.path();
|
||||
|
||||
debug!("copying into session dir: {}", source_path.display());
|
||||
match fs_util::link_or_copy(source_path, target_file_path) {
|
||||
Ok(fs_util::LinkOrCopy::Link) => {
|
||||
match link_or_copy(source_path, target_file_path) {
|
||||
Ok(LinkOrCopy::Link) => {
|
||||
files_linked += 1
|
||||
}
|
||||
Ok(fs_util::LinkOrCopy::Copy) => {
|
||||
Ok(LinkOrCopy::Copy) => {
|
||||
files_copied += 1
|
||||
}
|
||||
Err(_) => return Err(())
|
||||
|
@ -13,7 +13,7 @@
|
||||
use persist::fs::*;
|
||||
use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
|
||||
use rustc::session::Session;
|
||||
use rustc::util::fs::link_or_copy;
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use std::path::PathBuf;
|
||||
use std::fs as std_fs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user