aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/dist.rs20
-rw-r--r--xtask/src/lib.rs4
-rw-r--r--xtask/src/main.rs14
-rw-r--r--xtask/src/not_bash.rs4
4 files changed, 19 insertions, 23 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 3255eefb9..a56eeef8d 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -3,24 +3,20 @@ use std::path::PathBuf;
3use anyhow::Result; 3use anyhow::Result;
4 4
5use crate::{ 5use crate::{
6 not_bash::{fs2, pushd, rm_rf, run}, 6 not_bash::{date_iso, fs2, pushd, rm_rf, run},
7 project_root, 7 project_root,
8}; 8};
9 9
10pub struct ClientOpts { 10pub fn run_dist(nightly: bool, client_version: Option<String>) -> Result<()> {
11 pub version: String,
12 pub release_tag: String,
13}
14
15pub fn run_dist(client_opts: Option<ClientOpts>) -> Result<()> {
16 let dist = project_root().join("dist"); 11 let dist = project_root().join("dist");
17 rm_rf(&dist)?; 12 rm_rf(&dist)?;
18 fs2::create_dir_all(&dist)?; 13 fs2::create_dir_all(&dist)?;
19 14
20 if let Some(ClientOpts { version, release_tag }) = client_opts { 15 if let Some(version) = client_version {
16 let release_tag = if nightly { "nightly".to_string() } else { date_iso()? };
21 dist_client(&version, &release_tag)?; 17 dist_client(&version, &release_tag)?;
22 } 18 }
23 dist_server()?; 19 dist_server(nightly)?;
24 Ok(()) 20 Ok(())
25} 21}
26 22
@@ -50,7 +46,7 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
50 Ok(()) 46 Ok(())
51} 47}
52 48
53fn dist_server() -> Result<()> { 49fn dist_server(nightly: bool) -> Result<()> {
54 if cfg!(target_os = "linux") { 50 if cfg!(target_os = "linux") {
55 std::env::set_var("CC", "clang"); 51 std::env::set_var("CC", "clang");
56 run!( 52 run!(
@@ -60,7 +56,9 @@ fn dist_server() -> Result<()> {
60 // We'd want to add, but that requires setting the right linker somehow 56 // We'd want to add, but that requires setting the right linker somehow
61 // --features=jemalloc 57 // --features=jemalloc
62 )?; 58 )?;
63 run!("strip ./target/x86_64-unknown-linux-musl/release/rust-analyzer")?; 59 if !nightly {
60 run!("strip ./target/x86_64-unknown-linux-musl/release/rust-analyzer")?;
61 }
64 } else { 62 } else {
65 run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?; 63 run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?;
66 } 64 }
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 0b8243f62..9d087daa2 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -21,7 +21,7 @@ use walkdir::{DirEntry, WalkDir};
21 21
22use crate::{ 22use crate::{
23 codegen::Mode, 23 codegen::Mode,
24 not_bash::{fs2, pushd, rm_rf, run}, 24 not_bash::{date_iso, fs2, pushd, rm_rf, run},
25}; 25};
26 26
27pub use anyhow::Result; 27pub use anyhow::Result;
@@ -180,7 +180,7 @@ pub fn run_release(dry_run: bool) -> Result<()> {
180 let website_root = project_root().join("../rust-analyzer.github.io"); 180 let website_root = project_root().join("../rust-analyzer.github.io");
181 let changelog_dir = website_root.join("./thisweek/_posts"); 181 let changelog_dir = website_root.join("./thisweek/_posts");
182 182
183 let today = run!("date --iso")?; 183 let today = date_iso()?;
184 let commit = run!("git rev-parse HEAD")?; 184 let commit = run!("git rev-parse HEAD")?;
185 let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); 185 let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count();
186 186
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index a9adcfba4..dff3ce4a1 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -13,7 +13,7 @@ use std::env;
13use pico_args::Arguments; 13use pico_args::Arguments;
14use xtask::{ 14use xtask::{
15 codegen::{self, Mode}, 15 codegen::{self, Mode},
16 dist::{run_dist, ClientOpts}, 16 dist::run_dist,
17 install::{ClientOpt, InstallCmd, ServerOpt}, 17 install::{ClientOpt, InstallCmd, ServerOpt},
18 not_bash::pushd, 18 not_bash::pushd,
19 pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, 19 pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt,
@@ -103,16 +103,10 @@ FLAGS:
103 run_release(dry_run) 103 run_release(dry_run)
104 } 104 }
105 "dist" => { 105 "dist" => {
106 let client_opts = if args.contains("--client") { 106 let nightly = args.contains("--nightly");
107 Some(ClientOpts { 107 let client_version: Option<String> = args.opt_value_from_str("--client")?;
108 version: args.value_from_str("--version")?,
109 release_tag: args.value_from_str("--tag")?,
110 })
111 } else {
112 None
113 };
114 args.finish()?; 108 args.finish()?;
115 run_dist(client_opts) 109 run_dist(nightly, client_version)
116 } 110 }
117 _ => { 111 _ => {
118 eprintln!( 112 eprintln!(
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs
index 2d45e5dff..ef1699934 100644
--- a/xtask/src/not_bash.rs
+++ b/xtask/src/not_bash.rs
@@ -94,6 +94,10 @@ pub fn run_process(cmd: String, echo: bool) -> Result<String> {
94 run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd)) 94 run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd))
95} 95}
96 96
97pub fn date_iso() -> Result<String> {
98 run!("date --iso --utc")
99}
100
97fn run_process_inner(cmd: &str, echo: bool) -> Result<String> { 101fn run_process_inner(cmd: &str, echo: bool) -> Result<String> {
98 let mut args = shelx(cmd); 102 let mut args = shelx(cmd);
99 let binary = args.remove(0); 103 let binary = args.remove(0);