Skip to content

Commit

Permalink
build-manifest: bundle the rustc version in the binary
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Oct 12, 2020
1 parent cbded3e commit 0b7ee9d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/bootstrap/dist.rs
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/run.rs
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/tools/build-manifest/src/main.rs
Expand Up @@ -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();
Expand All @@ -236,7 +235,7 @@ fn main() {
}

Builder {
versions: Versions::new(&channel, &rustc_version, &input).unwrap(),
versions: Versions::new(&channel, &input).unwrap(),

input,
output,
Expand Down
17 changes: 6 additions & 11 deletions src/tools/build-manifest/src/versions.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -191,6 +186,6 @@ impl Versions {
}

pub(crate) fn rustc_version(&self) -> &str {
&self.rustc_version
RUSTC_VERSION
}
}

0 comments on commit 0b7ee9d

Please sign in to comment.