forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.rs
More file actions
45 lines (39 loc) · 1.12 KB
/
version.rs
File metadata and controls
45 lines (39 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Several function to retrieve version information.
*/
pub fn get_version() -> String {
format!(
"{} {:?} {}",
get_version_number(),
get_build_info(),
get_compiler()
)
}
pub fn get_version_number() -> String {
format!(
"{}.{}.{}{}",
env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MINOR"),
env!("CARGO_PKG_VERSION_PATCH"),
option_env!("CARGO_PKG_VERSION_PRE").unwrap_or("")
)
}
pub fn get_compiler() -> String {
let rustc_version = rustc_version_runtime::version_meta();
format!("rustc {}", rustc_version.semver)
}
pub fn get_build_info() -> (String, String) {
let git_hash = get_git_revision();
// See: https://reproducible-builds.org/docs/timestamps/
let git_timestamp = option_env!("RUSTPYTHON_GIT_TIMESTAMP")
.unwrap_or("")
.to_string();
(git_hash, git_timestamp)
}
pub fn get_git_revision() -> String {
option_env!("RUSTPYTHON_GIT_HASH").unwrap_or("").to_string()
}
pub fn get_git_branch() -> String {
option_env!("RUSTPYTHON_GIT_BRANCH")
.unwrap_or("")
.to_string()
}