2021-03-01 12:12:44 -06:00
|
|
|
#![allow(unreachable_pub)]
|
|
|
|
|
2023-06-11 14:48:24 -05:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
2021-03-05 02:51:32 -06:00
|
|
|
use crate::install::{ClientOpt, Malloc, ServerOpt};
|
|
|
|
|
2021-03-06 14:02:06 -06:00
|
|
|
xflags::xflags! {
|
|
|
|
src "./src/flags.rs"
|
|
|
|
|
2021-03-01 12:12:44 -06:00
|
|
|
/// Run custom build command.
|
|
|
|
cmd xtask {
|
|
|
|
|
|
|
|
/// Install rust-analyzer server or editor plugin.
|
|
|
|
cmd install {
|
|
|
|
/// Install only VS Code plugin.
|
|
|
|
optional --client
|
|
|
|
/// One of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'.
|
|
|
|
optional --code-bin name: String
|
|
|
|
|
|
|
|
/// Install only the language server.
|
|
|
|
optional --server
|
|
|
|
/// Use mimalloc allocator for server
|
|
|
|
optional --mimalloc
|
|
|
|
/// Use jemalloc allocator for server
|
|
|
|
optional --jemalloc
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd fuzz-tests {}
|
|
|
|
|
|
|
|
cmd release {
|
|
|
|
optional --dry-run
|
|
|
|
}
|
|
|
|
cmd promote {
|
|
|
|
optional --dry-run
|
|
|
|
}
|
|
|
|
cmd dist {
|
2021-04-26 07:17:02 -05:00
|
|
|
optional --client-patch-version version: String
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
2022-12-11 08:49:28 -06:00
|
|
|
/// Read a changelog AsciiDoc file and update the GitHub Releases entry in Markdown.
|
|
|
|
cmd publish-release-notes {
|
|
|
|
/// Only run conversion and show the result.
|
|
|
|
optional --dry-run
|
|
|
|
/// Target changelog file.
|
|
|
|
required changelog: String
|
|
|
|
}
|
2021-03-01 12:12:44 -06:00
|
|
|
cmd metrics {
|
2023-06-11 14:48:24 -05:00
|
|
|
optional measurement_type: MeasurementType
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
|
|
|
/// Builds a benchmark version of rust-analyzer and puts it into `./target`.
|
2022-10-08 09:35:07 -05:00
|
|
|
cmd bb {
|
2021-03-01 13:29:17 -06:00
|
|
|
required suffix: String
|
2022-10-08 09:35:07 -05:00
|
|
|
}
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// generated start
|
|
|
|
// The following code is generated by `xflags` macro.
|
2021-03-06 14:02:06 -06:00
|
|
|
// Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
|
2021-03-01 12:12:44 -06:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Xtask {
|
|
|
|
pub subcommand: XtaskCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum XtaskCmd {
|
|
|
|
Install(Install),
|
|
|
|
FuzzTests(FuzzTests),
|
|
|
|
Release(Release),
|
|
|
|
Promote(Promote),
|
|
|
|
Dist(Dist),
|
2022-12-11 08:49:28 -06:00
|
|
|
PublishReleaseNotes(PublishReleaseNotes),
|
2021-03-01 12:12:44 -06:00
|
|
|
Metrics(Metrics),
|
|
|
|
Bb(Bb),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Install {
|
|
|
|
pub client: bool,
|
|
|
|
pub code_bin: Option<String>,
|
|
|
|
pub server: bool,
|
|
|
|
pub mimalloc: bool,
|
|
|
|
pub jemalloc: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2021-03-06 14:02:06 -06:00
|
|
|
pub struct FuzzTests;
|
2021-03-01 12:12:44 -06:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Release {
|
|
|
|
pub dry_run: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Promote {
|
|
|
|
pub dry_run: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Dist {
|
2021-04-26 07:17:02 -05:00
|
|
|
pub client_patch_version: Option<String>,
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
|
|
|
|
2022-12-11 08:49:28 -06:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct PublishReleaseNotes {
|
|
|
|
pub changelog: String,
|
|
|
|
|
|
|
|
pub dry_run: bool,
|
|
|
|
}
|
|
|
|
|
2023-06-11 14:48:24 -05:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum MeasurementType {
|
|
|
|
Build,
|
2023-12-14 16:40:25 -06:00
|
|
|
RustcTests,
|
2023-06-12 12:44:04 -05:00
|
|
|
AnalyzeSelf,
|
|
|
|
AnalyzeRipgrep,
|
|
|
|
AnalyzeWebRender,
|
|
|
|
AnalyzeDiesel,
|
2023-09-03 04:39:29 -05:00
|
|
|
AnalyzeHyper,
|
2023-06-11 14:48:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl FromStr for MeasurementType {
|
|
|
|
type Err = String;
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s {
|
|
|
|
"build" => Ok(Self::Build),
|
2023-12-14 16:40:25 -06:00
|
|
|
"rustc_tests" => Ok(Self::RustcTests),
|
2023-06-12 12:44:04 -05:00
|
|
|
"self" => Ok(Self::AnalyzeSelf),
|
2023-09-03 03:29:05 -05:00
|
|
|
"ripgrep-13.0.0" => Ok(Self::AnalyzeRipgrep),
|
|
|
|
"webrender-2022" => Ok(Self::AnalyzeWebRender),
|
|
|
|
"diesel-1.4.8" => Ok(Self::AnalyzeDiesel),
|
2023-09-03 04:39:29 -05:00
|
|
|
"hyper-0.14.18" => Ok(Self::AnalyzeHyper),
|
2023-06-11 14:48:24 -05:00
|
|
|
_ => Err("Invalid option".to_string()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-03 03:29:05 -05:00
|
|
|
impl AsRef<str> for MeasurementType {
|
|
|
|
fn as_ref(&self) -> &str {
|
|
|
|
match self {
|
|
|
|
Self::Build => "build",
|
2023-12-14 16:40:25 -06:00
|
|
|
Self::RustcTests => "rustc_tests",
|
2023-09-03 03:29:05 -05:00
|
|
|
Self::AnalyzeSelf => "self",
|
|
|
|
Self::AnalyzeRipgrep => "ripgrep-13.0.0",
|
|
|
|
Self::AnalyzeWebRender => "webrender-2022",
|
|
|
|
Self::AnalyzeDiesel => "diesel-1.4.8",
|
2023-09-03 04:39:29 -05:00
|
|
|
Self::AnalyzeHyper => "hyper-0.14.18",
|
2023-09-03 03:29:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-11 14:48:24 -05:00
|
|
|
|
2021-03-01 12:12:44 -06:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Metrics {
|
2023-06-11 14:48:24 -05:00
|
|
|
pub measurement_type: Option<MeasurementType>,
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Bb {
|
|
|
|
pub suffix: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Xtask {
|
2022-10-08 09:35:07 -05:00
|
|
|
#[allow(dead_code)]
|
|
|
|
pub fn from_env_or_exit() -> Self {
|
|
|
|
Self::from_env_or_exit_()
|
|
|
|
}
|
2021-03-01 12:12:44 -06:00
|
|
|
|
2022-02-24 13:44:26 -06:00
|
|
|
#[allow(dead_code)]
|
2021-03-01 12:12:44 -06:00
|
|
|
pub fn from_env() -> xflags::Result<Self> {
|
2021-03-06 14:02:06 -06:00
|
|
|
Self::from_env_()
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
2022-02-24 13:44:26 -06:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
|
|
|
|
Self::from_vec_(args)
|
|
|
|
}
|
2021-03-01 12:12:44 -06:00
|
|
|
}
|
|
|
|
// generated end
|
2021-03-05 02:51:32 -06:00
|
|
|
|
|
|
|
impl Install {
|
|
|
|
pub(crate) fn server(&self) -> Option<ServerOpt> {
|
|
|
|
if self.client && !self.server {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
let malloc = if self.mimalloc {
|
|
|
|
Malloc::Mimalloc
|
|
|
|
} else if self.jemalloc {
|
|
|
|
Malloc::Jemalloc
|
|
|
|
} else {
|
|
|
|
Malloc::System
|
|
|
|
};
|
|
|
|
Some(ServerOpt { malloc })
|
|
|
|
}
|
|
|
|
pub(crate) fn client(&self) -> Option<ClientOpt> {
|
|
|
|
if !self.client && self.server {
|
|
|
|
return None;
|
|
|
|
}
|
2021-03-05 11:42:41 -06:00
|
|
|
Some(ClientOpt { code_bin: self.code_bin.clone() })
|
2021-03-05 02:51:32 -06:00
|
|
|
}
|
|
|
|
}
|