style: Setup bindgen flags for servo similarly to cranelift and neqo

While the use of toml allows the flags to be separated, the split is
done via some shell shenanigans anyways, and servo's build.rs can
handle the same just fine.

Differential Revision: https://phabricator.services.mozilla.com/D121042
This commit is contained in:
Mike Hommey 2023-05-22 13:07:32 +02:00 committed by Oriol Brufau
parent 9b070745c9
commit 9e33a154fd

View file

@ -46,11 +46,15 @@ lazy_static! {
.join("layout/style/ServoBindings.toml");
read_config(&path)
};
static ref BUILD_CONFIG: Table = {
static ref BINDGEN_FLAGS: Vec<String> = {
// Load build-specific config overrides.
let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap())
.join("layout/style/bindgen.toml");
read_config(&path)
.join("layout/style/extra-bindgen-flags");
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
fs::read_to_string(path).expect("Failed to read extra-bindgen-flags file")
.split_whitespace()
.map(std::borrow::ToOwned::to_owned)
.collect()
};
static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap();
static ref DISTDIR_PATH: PathBuf = {
@ -159,12 +163,8 @@ impl BuilderExt for Builder {
builder = builder.clang_arg("-DDEBUG=1").clang_arg("-DJS_DEBUG=1");
}
let build_config = BUILD_CONFIG["build"]
.as_table()
.expect("Malformed config file");
let extra_bindgen_flags = build_config["args"].as_array().unwrap().as_slice();
for item in extra_bindgen_flags.iter() {
builder = builder.clang_arg(item.as_str().expect("Expect string in list"));
for item in &*BINDGEN_FLAGS {
builder = builder.clang_arg(item);
}
builder