Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/install.rs')
-rw-r--r--xtask/src/install.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index 4e2093f069..f0cc445dfa 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -5,7 +5,10 @@ use std::{env, path::PathBuf, str};
use anyhow::{Context, bail, format_err};
use xshell::{Shell, cmd};
-use crate::flags::{self, Malloc};
+use crate::{
+ flags::{self, Malloc, PgoTrainingCrate},
+ util::detect_target,
+};
impl flags::Install {
pub(crate) fn run(self, sh: &Shell) -> anyhow::Result<()> {
@@ -35,6 +38,7 @@ const VS_CODES: &[&str] = &["code", "code-exploration", "code-insiders", "codium
pub(crate) struct ServerOpt {
pub(crate) malloc: Malloc,
pub(crate) dev_rel: bool,
+ pub(crate) pgo: Option<PgoTrainingCrate>,
}
pub(crate) struct ProcMacroServerOpt {
@@ -135,21 +139,33 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
let features = opts.malloc.to_features();
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
- let cmd = cmd!(
+ let mut install_cmd = cmd!(
sh,
"cargo install --path crates/rust-analyzer --profile={profile} --locked --force --features force-always-assert {features...}"
);
- cmd.run()?;
+
+ if let Some(train_crate) = opts.pgo {
+ 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...}"
+ );
+
+ 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);
+ }
+
+ install_cmd.run()?;
Ok(())
}
fn install_proc_macro_server(sh: &Shell, opts: ProcMacroServerOpt) -> anyhow::Result<()> {
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
- let cmd = cmd!(
+ cmd!(
sh,
"cargo +nightly install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features sysroot-abi"
- );
- cmd.run()?;
+ ).run()?;
+
Ok(())
}