| 1 |
use std::env; |
| 2 |
use std::fs; |
| 3 |
use std::io::Write; |
| 4 |
use std::path; |
| 5 |
|
| 6 |
fn main() { |
| 7 |
println!("cargo:rerun-if-changed=build.rs"); |
| 8 |
|
| 9 |
// env::ARCH doesn't include the full triplet, and as far as I know there isn't a cleaner way of getting the full triplet |
| 10 |
// (see cargo.rs for the rest of this implementation) |
| 11 |
let out = path::PathBuf::from(env::var_os("OUT_DIR").expect("run within cargo")) |
| 12 |
.join("current_target.txt"); |
| 13 |
let default_target = env::var("TARGET").expect("run as cargo build script"); |
| 14 |
let mut file = fs::File::create(out).expect("can write to OUT_DIR"); |
| 15 |
file.write_all(default_target.as_bytes()) |
| 16 |
.expect("can write to OUT_DIR"); |
| 17 |
} |