]>
git.proxmox.com Git - rustc.git/blob - src/bootstrap/build/channel.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use std
::fs
::{self, File}
;
13 use std
::io
::prelude
::*;
14 use std
::process
::Command
;
16 use build_helper
::output
;
21 pub fn collect(build
: &mut Build
) {
22 let mut main_mk
= String
::new();
23 t
!(t
!(File
::open(build
.src
.join("mk/main.mk"))).read_to_string(&mut main_mk
));
24 let mut release_num
= "";
25 let mut prerelease_version
= "";
26 for line
in main_mk
.lines() {
27 if line
.starts_with("CFG_RELEASE_NUM") {
28 release_num
= line
.split('
='
).skip(1).next().unwrap().trim();
30 if line
.starts_with("CFG_PRERELEASE_VERSION") {
31 prerelease_version
= line
.split('
='
).skip(1).next().unwrap().trim();
35 // FIXME: this is duplicating makefile logic
36 match &build
.config
.channel
[..] {
38 build
.release
= release_num
.to_string();
39 build
.package_vers
= build
.release
.clone();
40 build
.unstable_features
= false;
43 build
.release
= format
!("{}-beta{}", release_num
,
45 build
.package_vers
= "beta".to_string();
46 build
.unstable_features
= false;
49 build
.release
= format
!("{}-nightly", release_num
);
50 build
.package_vers
= "nightly".to_string();
51 build
.unstable_features
= true;
54 build
.release
= format
!("{}-dev", release_num
);
55 build
.package_vers
= build
.release
.clone();
56 build
.unstable_features
= true;
59 build
.version
= build
.release
.clone();
61 if fs
::metadata(build
.src
.join(".git")).is_ok() {
62 let ver_date
= output(Command
::new("git").current_dir(&build
.src
)
65 .arg("--pretty=format:%cd"));
66 let ver_hash
= output(Command
::new("git").current_dir(&build
.src
)
67 .arg("rev-parse").arg("HEAD"));
68 let short_ver_hash
= output(Command
::new("git")
69 .current_dir(&build
.src
)
73 let ver_date
= ver_date
.trim().to_string();
74 let ver_hash
= ver_hash
.trim().to_string();
75 let short_ver_hash
= short_ver_hash
.trim().to_string();
76 build
.version
.push_str(&format
!(" ({} {})", short_ver_hash
,
78 build
.ver_date
= Some(ver_date
.to_string());
79 build
.ver_hash
= Some(ver_hash
);
80 build
.short_ver_hash
= Some(short_ver_hash
);
83 let key
= md5
::compute(build
.release
.as_bytes());
84 build
.bootstrap_key
= format
!("{:02x}{:02x}{:02x}{:02x}",
85 key
[0], key
[1], key
[2], key
[3]);
86 env
::set_var("RUSTC_BOOTSTRAP_KEY", &build
.bootstrap_key
);