diff options
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/lib.rs | 40 | ||||
-rw-r--r-- | xtask/src/main.rs | 6 |
2 files changed, 44 insertions, 2 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index b76278635..e46c21db7 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -9,7 +9,7 @@ mod ast_src; | |||
9 | 9 | ||
10 | use anyhow::Context; | 10 | use anyhow::Context; |
11 | use std::{ | 11 | use std::{ |
12 | env, | 12 | env, fs, |
13 | path::{Path, PathBuf}, | 13 | path::{Path, PathBuf}, |
14 | process::{Command, Stdio}, | 14 | process::{Command, Stdio}, |
15 | }; | 15 | }; |
@@ -101,3 +101,41 @@ pub fn run_fuzzer() -> Result<()> { | |||
101 | 101 | ||
102 | run("rustup run nightly -- cargo fuzz run parser", "./crates/ra_syntax") | 102 | run("rustup run nightly -- cargo fuzz run parser", "./crates/ra_syntax") |
103 | } | 103 | } |
104 | |||
105 | /// Cleans the `./target` dir after the build such that only | ||
106 | /// dependencies are cached on CI. | ||
107 | pub fn run_pre_cache() -> Result<()> { | ||
108 | let slow_tests_cookie = Path::new("./target/.slow_tests_cookie"); | ||
109 | if !slow_tests_cookie.exists() { | ||
110 | panic!("slow tests were skipped on CI!") | ||
111 | } | ||
112 | rm_rf(slow_tests_cookie)?; | ||
113 | |||
114 | for entry in Path::new("./target/debug").read_dir()? { | ||
115 | let entry = entry?; | ||
116 | if entry.file_type().map(|it| it.is_file()).ok() == Some(true) { | ||
117 | // Can't delete yourself on windows :-( | ||
118 | if !entry.path().ends_with("xtask.exe") { | ||
119 | rm_rf(&entry.path())? | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | fs::remove_file("./target/.rustc_info.json")?; | ||
125 | let to_delete = ["ra_", "heavy_test"]; | ||
126 | for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() { | ||
127 | for entry in Path::new(dir).read_dir()? { | ||
128 | let entry = entry?; | ||
129 | if to_delete.iter().any(|&it| entry.path().display().to_string().contains(it)) { | ||
130 | rm_rf(&entry.path())? | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | Ok(()) | ||
136 | } | ||
137 | |||
138 | fn rm_rf(path: &Path) -> Result<()> { | ||
139 | if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) } | ||
140 | .with_context(|| format!("failed to remove {:?}", path)) | ||
141 | } | ||
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9309b2fbd..053453e6e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -14,7 +14,7 @@ use pico_args::Arguments; | |||
14 | use xtask::{ | 14 | use xtask::{ |
15 | codegen::{self, Mode}, | 15 | codegen::{self, Mode}, |
16 | install::{ClientOpt, InstallCmd, ServerOpt}, | 16 | install::{ClientOpt, InstallCmd, ServerOpt}, |
17 | pre_commit, run_clippy, run_fuzzer, run_rustfmt, Result, | 17 | pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | fn main() -> Result<()> { | 20 | fn main() -> Result<()> { |
@@ -88,6 +88,10 @@ FLAGS: | |||
88 | args.finish()?; | 88 | args.finish()?; |
89 | run_fuzzer() | 89 | run_fuzzer() |
90 | } | 90 | } |
91 | "pre-cache" => { | ||
92 | args.finish()?; | ||
93 | run_pre_cache() | ||
94 | } | ||
91 | _ => { | 95 | _ => { |
92 | eprintln!( | 96 | eprintln!( |
93 | "\ | 97 | "\ |