Skip to content

Commit

Permalink
build-manifest: move PkgType into the versions module
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Sep 18, 2020
1 parent b9af3e3 commit 0917b21
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
35 changes: 4 additions & 31 deletions src/tools/build-manifest/src/main.rs
Expand Up @@ -4,8 +4,10 @@
//! via `x.py dist hash-and-sign`; the cmdline arguments are set up
//! by rustbuild (in `src/bootstrap/dist.rs`).

use serde::Serialize;
mod versions;

use crate::versions::PkgType;
use serde::Serialize;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -336,35 +338,6 @@ fn main() {
.build();
}

enum PkgType {
RustSrc,
Cargo,
Rls,
RustAnalyzer,
Clippy,
Rustfmt,
LlvmTools,
Miri,
Other,
}

impl PkgType {
fn from_component(component: &str) -> Self {
use PkgType::*;
match component {
"rust-src" => RustSrc,
"cargo" => Cargo,
"rls" | "rls-preview" => Rls,
"rust-analyzer" | "rust-analyzer-preview" => RustAnalyzer,
"clippy" | "clippy-preview" => Clippy,
"rustfmt" | "rustfmt-preview" => Rustfmt,
"llvm-tools" | "llvm-tools-preview" => LlvmTools,
"miri" | "miri-preview" => Miri,
_ => Other,
}
}
}

impl Builder {
fn build(&mut self) {
self.rust_version = self.version("rust", "x86_64-unknown-linux-gnu");
Expand Down Expand Up @@ -702,7 +675,7 @@ impl Builder {
Rustfmt => format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target),
LlvmTools => format!("llvm-tools-{}-{}.tar.gz", self.llvm_tools_release, target),
Miri => format!("miri-{}-{}.tar.gz", self.miri_release, target),
Other => format!("{}-{}-{}.tar.gz", component, self.rust_release, target),
Other(_) => format!("{}-{}-{}.tar.gz", component, self.rust_release, target),
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/tools/build-manifest/src/versions.rs
@@ -0,0 +1,27 @@
pub(crate) enum PkgType {
RustSrc,
Cargo,
Rls,
RustAnalyzer,
Clippy,
Rustfmt,
LlvmTools,
Miri,
Other(String),
}

impl PkgType {
pub(crate) fn from_component(component: &str) -> Self {
match component {
"rust-src" => PkgType::RustSrc,
"cargo" => PkgType::Cargo,
"rls" | "rls-preview" => PkgType::Rls,
"rust-analyzer" | "rust-analyzer-preview" => PkgType::RustAnalyzer,
"clippy" | "clippy-preview" => PkgType::Clippy,
"rustfmt" | "rustfmt-preview" => PkgType::Rustfmt,
"llvm-tools" | "llvm-tools-preview" => PkgType::LlvmTools,
"miri" | "miri-preview" => PkgType::Miri,
other => PkgType::Other(other.into()),
}
}
}

0 comments on commit 0917b21

Please sign in to comment.