File: build.rs

package info (click to toggle)
rust-trybuild2 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 428 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::env;
use std::fs;
use std::io;
use std::path::Path;

fn main() -> io::Result<()> {
    println!("cargo:rerun-if-changed=build.rs");

    let out_dir = env::var_os("OUT_DIR").unwrap();
    let target = env::var("TARGET").ok();
    let path = Path::new(&out_dir).join("target");
    let value = match target {
        Some(target) => format!(r#"Some("{}")"#, target.escape_debug()),
        None => "None".to_owned(),
    };
    fs::write(path, value)
}