build-manifest: split the manifest struct definition in a separate file

This commit is contained in:
Pietro Albini 2020-09-30 14:40:38 +02:00
parent d4928ad7fd
commit 6e15975540
No known key found for this signature in database
GPG key ID: 3E06ABE80BAAF19C
2 changed files with 55 additions and 52 deletions

View file

@ -4,10 +4,11 @@
//! via `x.py dist hash-and-sign`; the cmdline arguments are set up
//! by rustbuild (in `src/bootstrap/dist.rs`).
mod manifest;
mod versions;
use crate::manifest::{Component, Manifest, Package, Rename, Target};
use crate::versions::{PkgType, Versions};
use serde::Serialize;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::env;
@ -167,57 +168,6 @@ static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"];
static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-analyzer-preview"];
#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
struct Manifest {
manifest_version: String,
date: String,
pkg: BTreeMap<String, Package>,
renames: BTreeMap<String, Rename>,
profiles: BTreeMap<String, Vec<String>>,
}
#[derive(Serialize)]
struct Package {
version: String,
git_commit_hash: Option<String>,
target: BTreeMap<String, Target>,
}
#[derive(Serialize)]
struct Rename {
to: String,
}
#[derive(Serialize, Default)]
struct Target {
available: bool,
url: Option<String>,
hash: Option<String>,
xz_url: Option<String>,
xz_hash: Option<String>,
components: Option<Vec<Component>>,
extensions: Option<Vec<Component>>,
}
impl Target {
fn unavailable() -> Self {
Self::default()
}
}
#[derive(Serialize)]
struct Component {
pkg: String,
target: String,
}
impl Component {
fn from_str(pkg: &str, target: &str) -> Self {
Self { pkg: pkg.to_string(), target: target.to_string() }
}
}
macro_rules! t {
($e:expr) => {
match $e {

View file

@ -0,0 +1,53 @@
use serde::Serialize;
use std::collections::BTreeMap;
#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct Manifest {
pub(crate) manifest_version: String,
pub(crate) date: String,
pub(crate) pkg: BTreeMap<String, Package>,
pub(crate) renames: BTreeMap<String, Rename>,
pub(crate) profiles: BTreeMap<String, Vec<String>>,
}
#[derive(Serialize)]
pub(crate) struct Package {
pub(crate) version: String,
pub(crate) git_commit_hash: Option<String>,
pub(crate) target: BTreeMap<String, Target>,
}
#[derive(Serialize)]
pub(crate) struct Rename {
pub(crate) to: String,
}
#[derive(Serialize, Default)]
pub(crate) struct Target {
pub(crate) available: bool,
pub(crate) url: Option<String>,
pub(crate) hash: Option<String>,
pub(crate) xz_url: Option<String>,
pub(crate) xz_hash: Option<String>,
pub(crate) components: Option<Vec<Component>>,
pub(crate) extensions: Option<Vec<Component>>,
}
impl Target {
pub(crate) fn unavailable() -> Self {
Self::default()
}
}
#[derive(Serialize)]
pub(crate) struct Component {
pub(crate) pkg: String,
pub(crate) target: String,
}
impl Component {
pub(crate) fn from_str(pkg: &str, target: &str) -> Self {
Self { pkg: pkg.to_string(), target: target.to_string() }
}
}