Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/install.rs')
-rw-r--r--xtask/src/install.rs36
1 files changed, 29 insertions, 7 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index f0cc445dfa..a803b4e943 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -39,6 +39,21 @@ pub(crate) struct ServerOpt {
pub(crate) malloc: Malloc,
pub(crate) dev_rel: bool,
pub(crate) pgo: Option<PgoTrainingCrate>,
+ pub(crate) force_always_assert: bool,
+}
+
+impl ServerOpt {
+ fn to_features(&self) -> Vec<&'static str> {
+ let malloc_features = self.malloc.to_features();
+ let mut features = Vec::with_capacity(
+ malloc_features.len() + if self.force_always_assert { 2 } else { 0 },
+ );
+ features.extend(malloc_features);
+ if self.force_always_assert {
+ features.extend(["--features", "force-always-assert"]);
+ }
+ features
+ }
}
pub(crate) struct ProcMacroServerOpt {
@@ -136,21 +151,21 @@ fn install_client(sh: &Shell, client_opt: ClientOpt) -> anyhow::Result<()> {
}
fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
- let features = opts.malloc.to_features();
+ let features = &opts.to_features();
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
let mut install_cmd = cmd!(
sh,
- "cargo install --path crates/rust-analyzer --profile={profile} --locked --force --features force-always-assert {features...}"
+ "cargo install --path crates/rust-analyzer --profile={profile} --locked --force {features...}"
);
if let Some(train_crate) = opts.pgo {
+ let target = detect_target(sh);
let build_cmd = cmd!(
sh,
- "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --profile={profile} --locked --features force-always-assert {features...}"
+ "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --profile={profile} --locked {features...}"
);
- let target = detect_target(sh);
let profile = crate::pgo::gather_pgo_profile(sh, build_cmd, &target, train_crate)?;
install_cmd = crate::pgo::apply_pgo_to_cmd(install_cmd, &profile);
}
@@ -162,10 +177,17 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
fn install_proc_macro_server(sh: &Shell, opts: ProcMacroServerOpt) -> anyhow::Result<()> {
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
- cmd!(
+ let mut cmd = cmd!(
sh,
- "cargo +nightly install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features sysroot-abi"
- ).run()?;
+ "cargo install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features sysroot-abi"
+ );
+ if std::env::var_os("RUSTUP_TOOLCHAIN").is_none() {
+ cmd = cmd.env("RUSTUP_TOOLCHAIN", "nightly");
+ } else {
+ cmd = cmd.env("RUSTC_BOOTSTRAP", "1");
+ }
+
+ cmd.run()?;
Ok(())
}