gecko-dev/third_party/rust/bindgen/build.rs
Benjamin Bouvier e207459263 Bug 1583471: Update bindgen to 0.51.1 througout the tree; r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D46962

--HG--
rename : third_party/rust/quote/tests/conditional/integer128.rs => third_party/rust/quote-0.6.11/tests/conditional/integer128.rs
rename : third_party/rust/unicode-xid/scripts/unicode.py => third_party/rust/unicode-xid-0.1.0/scripts/unicode.py
extra : moz-landing-system : lando
2019-09-25 09:50:10 +00:00

75 lines
2.1 KiB
Rust

mod target {
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
pub fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let mut dst =
File::create(Path::new(&out_dir).join("host-target.txt")).unwrap();
dst.write_all(env::var("TARGET").unwrap().as_bytes())
.unwrap();
}
}
mod testgen {
use std::char;
use std::env;
use std::ffi::OsStr;
use std::fs::{self, File};
use std::io::Write;
use std::path::{Path, PathBuf};
pub fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let mut dst =
File::create(Path::new(&out_dir).join("tests.rs")).unwrap();
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let headers_dir = manifest_dir.join("tests").join("headers");
let headers = match fs::read_dir(headers_dir) {
Ok(dir) => dir,
// We may not have headers directory after packaging.
Err(..) => return,
};
let entries =
headers.map(|result| result.expect("Couldn't read header file"));
println!("cargo:rerun-if-changed=tests/headers");
for entry in entries {
match entry.path().extension().and_then(OsStr::to_str) {
Some("h") | Some("hpp") => {
let func = entry
.file_name()
.to_str()
.unwrap()
.replace(|c| !char::is_alphanumeric(c), "_")
.replace("__", "_")
.to_lowercase();
writeln!(
dst,
"test_header!(header_{}, {:?});",
func,
entry.path(),
)
.unwrap();
}
_ => {}
}
}
dst.flush().unwrap();
}
}
fn main() {
target::main();
testgen::main();
}