build-manifest: bundle the rustc version in the binary

This commit is contained in:
Pietro Albini 2020-10-12 19:40:35 +02:00
parent cbded3e193
commit 0b7ee9d522
No known key found for this signature in database
GPG Key ID: 3E06ABE80BAAF19C
4 changed files with 7 additions and 15 deletions

View File

@ -2353,7 +2353,6 @@ impl Step for HashSign {
cmd.arg(today.trim());
cmd.arg(addr);
cmd.arg(&builder.config.channel);
cmd.arg(&builder.version);
cmd.env("BUILD_MANIFEST_LEGACY", "1");
builder.create_dir(&distdir(builder));

View File

@ -77,7 +77,6 @@ impl Step for BuildManifest {
cmd.arg(today.trim());
cmd.arg(addr);
cmd.arg(&builder.config.channel);
cmd.arg(&builder.version);
builder.create_dir(&distdir(builder));
builder.run(&mut cmd);

View File

@ -226,7 +226,6 @@ fn main() {
let date = args.next().unwrap();
let s3_address = args.next().unwrap();
let channel = args.next().unwrap();
let rustc_version = args.next().unwrap();
// Do not ask for a passphrase while manually testing
let mut passphrase = String::new();
@ -236,7 +235,7 @@ fn main() {
}
Builder {
versions: Versions::new(&channel, &rustc_version, &input).unwrap(),
versions: Versions::new(&channel, &input).unwrap(),
input,
output,

View File

@ -7,6 +7,7 @@ use std::path::{Path, PathBuf};
use tar::Archive;
const DEFAULT_TARGET: &str = "x86_64-unknown-linux-gnu";
const RUSTC_VERSION: &str = include_str!("../../../version");
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
pub(crate) enum PkgType {
@ -87,19 +88,13 @@ pub(crate) struct VersionInfo {
pub(crate) struct Versions {
channel: String,
rustc_version: String,
dist_path: PathBuf,
versions: HashMap<PkgType, VersionInfo>,
}
impl Versions {
pub(crate) fn new(channel: &str, rustc_version: &str, dist_path: &Path) -> Result<Self, Error> {
Ok(Self {
channel: channel.into(),
rustc_version: rustc_version.into(),
dist_path: dist_path.into(),
versions: HashMap::new(),
})
pub(crate) fn new(channel: &str, dist_path: &Path) -> Result<Self, Error> {
Ok(Self { channel: channel.into(), dist_path: dist_path.into(), versions: HashMap::new() })
}
pub(crate) fn channel(&self) -> &str {
@ -177,10 +172,10 @@ impl Versions {
) -> Result<String, Error> {
let component_name = package.tarball_component_name();
let version = match self.channel.as_str() {
"stable" => self.rustc_version.clone(),
"stable" => RUSTC_VERSION.into(),
"beta" => "beta".into(),
"nightly" => "nightly".into(),
_ => format!("{}-dev", self.rustc_version),
_ => format!("{}-dev", RUSTC_VERSION),
};
if package.target_independent() {
@ -191,6 +186,6 @@ impl Versions {
}
pub(crate) fn rustc_version(&self) -> &str {
&self.rustc_version
RUSTC_VERSION
}
}