Skip to content

Commit 6e15975

Browse files
committed
build-manifest: split the manifest struct definition in a separate file
1 parent d4928ad commit 6e15975

File tree

2 files changed

+55
-52
lines changed

2 files changed

+55
-52
lines changed

src/tools/build-manifest/src/main.rs

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
//! via `x.py dist hash-and-sign`; the cmdline arguments are set up
55
//! by rustbuild (in `src/bootstrap/dist.rs`).
66
7+
mod manifest;
78
mod versions;
89

10+
use crate::manifest::{Component, Manifest, Package, Rename, Target};
911
use crate::versions::{PkgType, Versions};
10-
use serde::Serialize;
1112
use std::collections::BTreeMap;
1213
use std::collections::HashMap;
1314
use std::env;
@@ -167,57 +168,6 @@ static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"];
167168

168169
static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-analyzer-preview"];
169170

170-
#[derive(Serialize)]
171-
#[serde(rename_all = "kebab-case")]
172-
struct Manifest {
173-
manifest_version: String,
174-
date: String,
175-
pkg: BTreeMap<String, Package>,
176-
renames: BTreeMap<String, Rename>,
177-
profiles: BTreeMap<String, Vec<String>>,
178-
}
179-
180-
#[derive(Serialize)]
181-
struct Package {
182-
version: String,
183-
git_commit_hash: Option<String>,
184-
target: BTreeMap<String, Target>,
185-
}
186-
187-
#[derive(Serialize)]
188-
struct Rename {
189-
to: String,
190-
}
191-
192-
#[derive(Serialize, Default)]
193-
struct Target {
194-
available: bool,
195-
url: Option<String>,
196-
hash: Option<String>,
197-
xz_url: Option<String>,
198-
xz_hash: Option<String>,
199-
components: Option<Vec<Component>>,
200-
extensions: Option<Vec<Component>>,
201-
}
202-
203-
impl Target {
204-
fn unavailable() -> Self {
205-
Self::default()
206-
}
207-
}
208-
209-
#[derive(Serialize)]
210-
struct Component {
211-
pkg: String,
212-
target: String,
213-
}
214-
215-
impl Component {
216-
fn from_str(pkg: &str, target: &str) -> Self {
217-
Self { pkg: pkg.to_string(), target: target.to_string() }
218-
}
219-
}
220-
221171
macro_rules! t {
222172
($e:expr) => {
223173
match $e {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use serde::Serialize;
2+
use std::collections::BTreeMap;
3+
4+
#[derive(Serialize)]
5+
#[serde(rename_all = "kebab-case")]
6+
pub(crate) struct Manifest {
7+
pub(crate) manifest_version: String,
8+
pub(crate) date: String,
9+
pub(crate) pkg: BTreeMap<String, Package>,
10+
pub(crate) renames: BTreeMap<String, Rename>,
11+
pub(crate) profiles: BTreeMap<String, Vec<String>>,
12+
}
13+
14+
#[derive(Serialize)]
15+
pub(crate) struct Package {
16+
pub(crate) version: String,
17+
pub(crate) git_commit_hash: Option<String>,
18+
pub(crate) target: BTreeMap<String, Target>,
19+
}
20+
21+
#[derive(Serialize)]
22+
pub(crate) struct Rename {
23+
pub(crate) to: String,
24+
}
25+
26+
#[derive(Serialize, Default)]
27+
pub(crate) struct Target {
28+
pub(crate) available: bool,
29+
pub(crate) url: Option<String>,
30+
pub(crate) hash: Option<String>,
31+
pub(crate) xz_url: Option<String>,
32+
pub(crate) xz_hash: Option<String>,
33+
pub(crate) components: Option<Vec<Component>>,
34+
pub(crate) extensions: Option<Vec<Component>>,
35+
}
36+
37+
impl Target {
38+
pub(crate) fn unavailable() -> Self {
39+
Self::default()
40+
}
41+
}
42+
43+
#[derive(Serialize)]
44+
pub(crate) struct Component {
45+
pub(crate) pkg: String,
46+
pub(crate) target: String,
47+
}
48+
49+
impl Component {
50+
pub(crate) fn from_str(pkg: &str, target: &str) -> Self {
51+
Self { pkg: pkg.to_string(), target: target.to_string() }
52+
}
53+
}

0 commit comments

Comments
 (0)