]>
git.proxmox.com Git - rustc.git/blob - src/bootstrap/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.
11 //! Build configuration for Rust's release channels.
13 //! Implements the stable/beta/nightly channel distinctions by setting various
14 //! flags like the `unstable_features`, calculating variables like `release` and
15 //! `package_vers`, and otherwise indicating to the compiler what it should
16 //! print out as part of its version information.
19 use std
::process
::Command
;
21 use build_helper
::output
;
26 pub const CFG_RELEASE_NUM
: &'
static str = "1.17.0";
28 // An optional number to put after the label, e.g. '.2' -> '-beta.2'
29 // Be sure to make this starts with a dot to conform to semver pre-release
30 // versions (section 9)
31 pub const CFG_PRERELEASE_VERSION
: &'
static str = ".3";
44 pub fn new(dir
: &Path
) -> GitInfo
{
45 // See if this even begins to look like a git dir
46 if !dir
.join(".git").exists() {
47 return GitInfo { inner: None }
50 // Make sure git commands work
51 let out
= Command
::new("git")
55 .expect("failed to spawn git");
56 if !out
.status
.success() {
57 return GitInfo { inner: None }
60 // Ok, let's scrape some info
61 let ver_date
= output(Command
::new("git").current_dir(dir
)
64 .arg("--pretty=format:%cd"));
65 let ver_hash
= output(Command
::new("git").current_dir(dir
)
66 .arg("rev-parse").arg("HEAD"));
67 let short_ver_hash
= output(Command
::new("git")
74 commit_date
: ver_date
.trim().to_string(),
75 sha
: ver_hash
.trim().to_string(),
76 short_sha
: short_ver_hash
.trim().to_string(),
81 pub fn sha(&self) -> Option
<&str> {
82 self.inner
.as_ref().map(|s
| &s
.sha
[..])
85 pub fn sha_short(&self) -> Option
<&str> {
86 self.inner
.as_ref().map(|s
| &s
.short_sha
[..])
89 pub fn commit_date(&self) -> Option
<&str> {
90 self.inner
.as_ref().map(|s
| &s
.commit_date
[..])
93 pub fn version(&self, build
: &Build
, num
: &str) -> String
{
94 let mut version
= build
.release(num
);
95 if let Some(ref inner
) = self.inner
{
96 version
.push_str(" (");
97 version
.push_str(&inner
.short_sha
);
98 version
.push_str(" ");
99 version
.push_str(&inner
.commit_date
);
100 version
.push_str(")");