forked from mirrors/gecko-dev
Bug 1751331 - Use the mozbuild crate in cranelift. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D136561
This commit is contained in:
parent
47b241bdee
commit
a7254d5105
3 changed files with 22 additions and 27 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -344,6 +344,7 @@ dependencies = [
|
||||||
"cranelift-wasm",
|
"cranelift-wasm",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
|
"mozbuild",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ smallvec = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = {version = "0.56", default-features = false} # disable `logging` to reduce code size
|
bindgen = {version = "0.56", default-features = false} # disable `logging` to reduce code size
|
||||||
|
mozbuild = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ['cranelift-codegen/std']
|
default = ['cranelift-codegen/std']
|
||||||
|
|
|
||||||
|
|
@ -55,38 +55,31 @@ fn main() {
|
||||||
])
|
])
|
||||||
.clang_arg("-I../..");
|
.clang_arg("-I../..");
|
||||||
|
|
||||||
match env::var_os("MOZ_TOPOBJDIR") {
|
let generated_src = mozbuild::TOPOBJDIR.join("js/src");
|
||||||
Some(objdir) => {
|
let path = generated_src.clone().join("rust/extra-bindgen-flags");
|
||||||
let generated_src = PathBuf::from(objdir).join("js/src");
|
|
||||||
let path = generated_src.clone().join("rust/extra-bindgen-flags");
|
|
||||||
|
|
||||||
let mut extra_flags = String::new();
|
let mut extra_flags = String::new();
|
||||||
File::open(&path)
|
File::open(&path)
|
||||||
.expect("Failed to open extra-bindgen-flags file")
|
.expect("Failed to open extra-bindgen-flags file")
|
||||||
.read_to_string(&mut extra_flags)
|
.read_to_string(&mut extra_flags)
|
||||||
.expect("Failed to read extra-bindgen-flags file");
|
.expect("Failed to read extra-bindgen-flags file");
|
||||||
|
|
||||||
let display_path = path.to_str().expect("path is utf8 encoded");
|
let display_path = path.to_str().expect("path is utf8 encoded");
|
||||||
println!("cargo:rerun-if-changed={}", display_path);
|
println!("cargo:rerun-if-changed={}", display_path);
|
||||||
|
|
||||||
let extra_flags: Vec<String> = extra_flags
|
let extra_flags: Vec<String> = extra_flags
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.map(|s| s.to_owned())
|
.map(|s| s.to_owned())
|
||||||
.collect();
|
.collect();
|
||||||
for flag in extra_flags {
|
for flag in extra_flags {
|
||||||
generator = generator.clang_arg(flag);
|
generator = generator.clang_arg(flag);
|
||||||
}
|
|
||||||
|
|
||||||
generator = generator.clang_arg(format!(
|
|
||||||
"-I{}",
|
|
||||||
generated_src.to_str().expect("path is utf8 encoded")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
println!("cargo:warning=MOZ_TOPOBJDIR should be set by default, otherwise the build is not guaranted to finish.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generator = generator.clang_arg(format!(
|
||||||
|
"-I{}",
|
||||||
|
generated_src.to_str().expect("path is utf8 encoded")
|
||||||
|
));
|
||||||
|
|
||||||
let command_line_opts = generator.command_line_flags();
|
let command_line_opts = generator.command_line_flags();
|
||||||
|
|
||||||
// In case of error, bindgen prints to stderr, and the yielded error is the empty type ().
|
// In case of error, bindgen prints to stderr, and the yielded error is the empty type ().
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue