aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/dist.rs1
-rw-r--r--xtask/src/flags.rs5
-rw-r--r--xtask/src/install.rs2
-rw-r--r--xtask/src/main.rs2
-rw-r--r--xtask/src/pre_cache.rs79
-rw-r--r--xtask/src/release.rs6
6 files changed, 6 insertions, 89 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 12a7fea1e..b6aa2f52a 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -66,6 +66,7 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
66 66
67fn dist_server(release_channel: &str) -> Result<()> { 67fn dist_server(release_channel: &str) -> Result<()> {
68 let _e = pushenv("RUST_ANALYZER_CHANNEL", release_channel); 68 let _e = pushenv("RUST_ANALYZER_CHANNEL", release_channel);
69 let _e = pushenv("CARGO_PROFILE_RELEASE_LTO", "true");
69 let target = get_target(); 70 let target = get_target();
70 if target.contains("-linux-gnu") || target.contains("-linux-musl") { 71 if target.contains("-linux-gnu") || target.contains("-linux-musl") {
71 env::set_var("CC", "clang"); 72 env::set_var("CC", "clang");
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index f80a5dd16..69b3cb9c1 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -28,7 +28,6 @@ xflags::xflags! {
28 } 28 }
29 29
30 cmd fuzz-tests {} 30 cmd fuzz-tests {}
31 cmd pre-cache {}
32 31
33 cmd release { 32 cmd release {
34 optional --dry-run 33 optional --dry-run
@@ -62,7 +61,6 @@ pub enum XtaskCmd {
62 Help(Help), 61 Help(Help),
63 Install(Install), 62 Install(Install),
64 FuzzTests(FuzzTests), 63 FuzzTests(FuzzTests),
65 PreCache(PreCache),
66 Release(Release), 64 Release(Release),
67 Promote(Promote), 65 Promote(Promote),
68 Dist(Dist), 66 Dist(Dist),
@@ -88,9 +86,6 @@ pub struct Install {
88pub struct FuzzTests; 86pub struct FuzzTests;
89 87
90#[derive(Debug)] 88#[derive(Debug)]
91pub struct PreCache;
92
93#[derive(Debug)]
94pub struct Release { 89pub struct Release {
95 pub dry_run: bool, 90 pub dry_run: bool,
96} 91}
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index 91d6a2853..7e2dccdfe 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -8,7 +8,7 @@ use xshell::{cmd, pushd};
8use crate::flags; 8use crate::flags;
9 9
10// Latest stable, feel free to send a PR if this lags behind. 10// Latest stable, feel free to send a PR if this lags behind.
11const REQUIRED_RUST_VERSION: u32 = 51; 11const REQUIRED_RUST_VERSION: u32 = 52;
12 12
13impl flags::Install { 13impl flags::Install {
14 pub(crate) fn run(self) -> Result<()> { 14 pub(crate) fn run(self) -> Result<()> {
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index ce3353410..d0bef7b7a 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -18,7 +18,6 @@ mod install;
18mod release; 18mod release;
19mod dist; 19mod dist;
20mod metrics; 20mod metrics;
21mod pre_cache;
22 21
23use anyhow::{bail, Result}; 22use anyhow::{bail, Result};
24use std::{ 23use std::{
@@ -39,7 +38,6 @@ fn main() -> Result<()> {
39 } 38 }
40 flags::XtaskCmd::Install(cmd) => cmd.run(), 39 flags::XtaskCmd::Install(cmd) => cmd.run(),
41 flags::XtaskCmd::FuzzTests(_) => run_fuzzer(), 40 flags::XtaskCmd::FuzzTests(_) => run_fuzzer(),
42 flags::XtaskCmd::PreCache(cmd) => cmd.run(),
43 flags::XtaskCmd::Release(cmd) => cmd.run(), 41 flags::XtaskCmd::Release(cmd) => cmd.run(),
44 flags::XtaskCmd::Promote(cmd) => cmd.run(), 42 flags::XtaskCmd::Promote(cmd) => cmd.run(),
45 flags::XtaskCmd::Dist(cmd) => cmd.run(), 43 flags::XtaskCmd::Dist(cmd) => cmd.run(),
diff --git a/xtask/src/pre_cache.rs b/xtask/src/pre_cache.rs
deleted file mode 100644
index b456224fd..000000000
--- a/xtask/src/pre_cache.rs
+++ /dev/null
@@ -1,79 +0,0 @@
1use std::{
2 fs::FileType,
3 path::{Path, PathBuf},
4};
5
6use anyhow::Result;
7use xshell::rm_rf;
8
9use crate::flags;
10
11impl flags::PreCache {
12 /// Cleans the `./target` dir after the build such that only
13 /// dependencies are cached on CI.
14 pub(crate) fn run(self) -> Result<()> {
15 let slow_tests_cookie = Path::new("./target/.slow_tests_cookie");
16 if !slow_tests_cookie.exists() {
17 panic!("slow tests were skipped on CI!")
18 }
19 rm_rf(slow_tests_cookie)?;
20
21 for path in read_dir("./target/debug", FileType::is_file)? {
22 // Can't delete yourself on windows :-(
23 if !path.ends_with("xtask.exe") {
24 rm_rf(&path)?
25 }
26 }
27
28 rm_rf("./target/.rustc_info.json")?;
29
30 let to_delete = read_dir("./crates", FileType::is_dir)?
31 .into_iter()
32 .map(|path| path.file_name().unwrap().to_string_lossy().replace('-', "_"))
33 .collect::<Vec<_>>();
34
35 for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() {
36 for path in read_dir(dir, |_file_type| true)? {
37 if path.ends_with("xtask.exe") {
38 continue;
39 }
40 let file_name = path.file_name().unwrap().to_string_lossy();
41 let (stem, _) = match rsplit_once(&file_name, '-') {
42 Some(it) => it,
43 None => {
44 rm_rf(path)?;
45 continue;
46 }
47 };
48 let stem = stem.replace('-', "_");
49 if to_delete.contains(&stem) {
50 rm_rf(path)?;
51 }
52 }
53 }
54
55 Ok(())
56 }
57}
58fn read_dir(path: impl AsRef<Path>, cond: impl Fn(&FileType) -> bool) -> Result<Vec<PathBuf>> {
59 read_dir_impl(path.as_ref(), &cond)
60}
61
62fn read_dir_impl(path: &Path, cond: &dyn Fn(&FileType) -> bool) -> Result<Vec<PathBuf>> {
63 let mut res = Vec::new();
64 for entry in path.read_dir()? {
65 let entry = entry?;
66 let file_type = entry.file_type()?;
67 if cond(&file_type) {
68 res.push(entry.path())
69 }
70 }
71 Ok(res)
72}
73
74fn rsplit_once(haystack: &str, delim: char) -> Option<(&str, &str)> {
75 let mut split = haystack.rsplitn(2, delim);
76 let suffix = split.next()?;
77 let prefix = split.next()?;
78 Some((prefix, suffix))
79}
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index 452f351d0..2c0476778 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -1,6 +1,6 @@
1mod changelog; 1mod changelog;
2 2
3use xshell::{cmd, cp, pushd, read_dir, write_file}; 3use xshell::{cmd, pushd, read_dir, read_file, write_file};
4 4
5use crate::{codegen, date_iso, flags, is_release_tag, project_root, Result}; 5use crate::{codegen, date_iso, flags, is_release_tag, project_root, Result};
6 6
@@ -41,7 +41,9 @@ impl flags::Release {
41 { 41 {
42 let src = project_root().join("./docs/user/").join(adoc); 42 let src = project_root().join("./docs/user/").join(adoc);
43 let dst = website_root.join(adoc); 43 let dst = website_root.join(adoc);
44 cp(src, dst)?; 44
45 let contents = read_file(src)?.replace("\n\n===", "\n\n// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository\n\n==");
46 write_file(dst, contents)?;
45 } 47 }
46 48
47 let tags = cmd!("git tag --list").read()?; 49 let tags = cmd!("git tag --list").read()?;