aboutsummaryrefslogtreecommitdiff
path: root/tools/compiler_version/src/main.rs
blob: 767cb31bdf060eee2ef9e46602d121d627ab04e4 (plain)
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
use std::process::Command;

fn main() {
    // Print the rustc version.
    Command::new(env!("CARGO"))
        .args(&["rustc", "--quiet", "--", "--version"])
        .status()
        .unwrap();
    println!();

    // Print the Cargo version.
    Command::new(env!("CARGO"))
        .args(&["--version"])
        .status()
        .unwrap();
    println!();

    // Print the C compiler version. This relies on C compiler detection done
    // in build.rs, which sets the COMPILER_PATH variable.
    let compiler_path = env!("COMPILER_PATH");
    let mut compiler_command = Command::new(compiler_path);
    // Use the --version flag on everything other than MSVC.
    if !cfg!(target_env = "msvc") {
        compiler_command.arg("--version");
    }
    let _ = compiler_command.status().unwrap();
}