-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
use std::{env, fs, path::PathBuf}; | ||
use std::{env, fs, path::PathBuf, process::Command, str}; | ||
|
||
fn main() { | ||
let target = env::var("TARGET").expect("TARGET not set"); | ||
let rustc = &*env::var("RUSTC").expect("RUSTC not set"); | ||
let output = Command::new(rustc).args(["--print", "sysroot"]).output().unwrap(); | ||
assert!(output.status.success()); | ||
let sysroot = str::from_utf8(&output.stdout).unwrap().trim(); | ||
let out_dir: PathBuf = env::var_os("OUT_DIR").expect("OUT_DIR not set").into(); | ||
let out_file = &out_dir.join("target"); | ||
fs::write(out_file, format!("\"{target}\"")) | ||
.unwrap_or_else(|e| panic!("failed to write {}: {e}", out_file.display())); | ||
let out_file = &out_dir.join("build-info"); | ||
fs::write( | ||
out_file, | ||
format!( | ||
"pub const TARGET: &str = r\"{target}\";\n\ | ||
pub const SYSROOT: &str = r\"{sysroot}\";\n" | ||
), | ||
) | ||
.unwrap_or_else(|e| panic!("failed to write {}: {e}", out_file.display())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub const TARGET: &str = include!(concat!(env!("OUT_DIR"), "/target")); | ||
include!(concat!(env!("OUT_DIR"), "/build-info")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters