Move most of the root package into a subcrate. (#1445)

This improves incremental build time when working on what was previously
the root package. For example, previously all plugins would be rebuilt
with a change to `src/commands/classified/external.rs`, but now only
`nu-cli` will have to be rebuilt (and anything that depends on it).
This commit is contained in:
Jason Gedge
2020-03-04 13:58:20 -05:00
committed by GitHub
parent c731a5b628
commit b2c5af457e
210 changed files with 239 additions and 206 deletions

View File

@ -225,15 +225,41 @@ pub fn executable_path() -> PathBuf {
path
}
pub fn root() -> PathBuf {
let manifest_dir = if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
PathBuf::from(manifest_dir)
} else {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
};
let test_path = manifest_dir.join("Cargo.lock");
if test_path.exists() {
manifest_dir
} else {
manifest_dir
.parent()
.expect("Couldn't find the debug binaries directory")
.parent()
.expect("Couldn't find the debug binaries directory")
.to_path_buf()
}
}
pub fn binaries() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("Couldn't find the debug binaries directory")
.parent()
.expect("Couldn't find the debug binaries directory")
.join("target/debug")
root().join("target/debug")
}
pub fn fixtures() -> PathBuf {
root().join("tests/fixtures")
}
pub fn in_directory(str: impl AsRef<Path>) -> String {
str.as_ref().display().to_string()
let path = str.as_ref();
let path = if path.is_relative() {
root().join(path)
} else {
path.to_path_buf()
};
path.display().to_string()
}

View File

@ -1,4 +1,4 @@
use crate::fs::line_ending;
use crate::fs;
use crate::fs::Stub;
use getset::Getters;
@ -52,17 +52,9 @@ impl Playground {
cwd: nuplay_dir,
};
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let playground_root = playground.root.path();
let fixtures = project_root;
let fixtures = fixtures
.parent()
.expect("Couldn't find the fixtures directory")
.parent()
.expect("Couldn't find the fixtures directory")
.join("tests/fixtures");
let fixtures = fs::fixtures();
let fixtures = dunce::canonicalize(fixtures.clone()).unwrap_or_else(|e| {
panic!(
"Couldn't canonicalize fixtures path {}: {:?}",
@ -104,7 +96,7 @@ impl Playground {
}
pub fn with_files(&mut self, files: Vec<Stub>) -> &mut Self {
let endl = line_ending();
let endl = fs::line_ending();
files
.iter()