>()
+ .join("::");
- /// Copy contents of one directory into another.
- /// It currently only does a shallow copy.
- fn copy_dir(from: P, to: Q, callback: F) -> io::Result<()>
- where
- P: AsRef,
- Q: AsRef,
- F: Fn(&Path),
- {
- let to = to.as_ref();
- for entry in from.as_ref().read_dir()? {
- let entry = entry?;
- let path = entry.path();
- callback(&path);
- fs::copy(&path, to.join(entry.file_name()))?;
- }
- Ok(())
+ fixups.push(Fixup {
+ pat: format!("\\broot\\s*::\\s*{}\\b", gecko),
+ rep: format!("::gecko_bindings::structs::{}", gecko_name),
+ });
+ builder.blacklist_type(gecko).raw_line(format!(
+ "pub type {0}{2} = {1}{2};",
+ gecko_name,
+ servo,
+ if generic { "" } else { "" }
+ ))
+ })
+ .get_builder();
+ write_binding_file(builder, STRUCTS_FILE, &fixups);
+}
+
+fn setup_logging() -> bool {
+ struct BuildLogger {
+ file: Option>,
+ filter: String,
}
- pub fn generate() {
- let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated");
- println!("cargo:rerun-if-changed={}", dir.display());
- copy_dir(&dir, &*OUTDIR_PATH, |path| {
- println!("cargo:rerun-if-changed={}", path.display());
- })
- .expect("Fail to copy generated files to out dir");
+ impl log::Log for BuildLogger {
+ fn enabled(&self, meta: &log::Metadata) -> bool {
+ self.file.is_some() && meta.target().contains(&self.filter)
+ }
+
+ fn log(&self, record: &log::Record) {
+ if !self.enabled(record.metadata()) {
+ return;
+ }
+
+ let mut file = self.file.as_ref().unwrap().lock().unwrap();
+ let _ = writeln!(
+ file,
+ "{} - {} - {} @ {}:{}",
+ record.level(),
+ record.target(),
+ record.args(),
+ record.file().unwrap_or(""),
+ record.line().unwrap_or(0)
+ );
+ }
+
+ fn flush(&self) {
+ if let Some(ref file) = self.file {
+ file.lock().unwrap().flush().unwrap();
+ }
+ }
+ }
+
+ if let Some(path) = env::var_os("STYLO_BUILD_LOG") {
+ log::set_max_level(log::LevelFilter::Debug);
+ log::set_boxed_logger(Box::new(BuildLogger {
+ file: fs::File::create(path).ok().map(Mutex::new),
+ filter: env::var("STYLO_BUILD_FILTER")
+ .ok()
+ .unwrap_or_else(|| "bindgen".to_owned()),
+ }))
+ .expect("Failed to set logger.");
+
+ true
+ } else {
+ false
+ }
+}
+
+fn generate_atoms() {
+ let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap())
+ .join("gecko")
+ .join("regen_atoms.py");
+ println!("cargo:rerun-if-changed={}", script.display());
+ let status = Command::new(&*PYTHON)
+ .arg(&script)
+ .arg(DISTDIR_PATH.as_os_str())
+ .arg(OUTDIR_PATH.as_os_str())
+ .status()
+ .unwrap();
+ if !status.success() {
+ exit(1);
}
}
pub fn generate() {
- use self::common::*;
- use std::fs;
println!("cargo:rerun-if-changed=build_gecko.rs");
fs::create_dir_all(&*OUTDIR_PATH).unwrap();
- bindings::generate();
+ setup_logging();
+ generate_structs();
+ generate_atoms();
+
+ for path in ADDED_PATHS.lock().unwrap().iter() {
+ println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
+ }
}
diff --git a/servo/ports/geckolib/Cargo.toml b/servo/ports/geckolib/Cargo.toml
index c03d646f6845..187e728efdd3 100644
--- a/servo/ports/geckolib/Cargo.toml
+++ b/servo/ports/geckolib/Cargo.toml
@@ -9,7 +9,6 @@ name = "geckoservo"
path = "lib.rs"
[features]
-bindgen = ["style/use_bindgen"]
gecko_debug = ["style/gecko_debug", "nsstring/gecko_debug"]
gecko_profiler = ["style/gecko_profiler"]
gecko_refcount_logging = ["style/gecko_refcount_logging", "servo_arc/gecko_refcount_logging"]
diff --git a/toolkit/library/gtest/rust/Cargo.toml b/toolkit/library/gtest/rust/Cargo.toml
index 49cf7969ec6d..0735ec221758 100644
--- a/toolkit/library/gtest/rust/Cargo.toml
+++ b/toolkit/library/gtest/rust/Cargo.toml
@@ -6,8 +6,6 @@ license = "MPL-2.0"
description = "Testing code for libgkrust"
[features]
-bindgen = ["gkrust-shared/bindgen"]
-servo = ["gkrust-shared/servo"]
quantum_render = ["gkrust-shared/quantum_render"]
cubeb-remoting = ["gkrust-shared/cubeb-remoting"]
cubeb_coreaudio_rust = ["gkrust-shared/cubeb_coreaudio_rust"]
diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml
index 2f67e593444e..854a708f6c1a 100644
--- a/toolkit/library/rust/Cargo.toml
+++ b/toolkit/library/rust/Cargo.toml
@@ -6,8 +6,6 @@ license = "MPL-2.0"
description = "Rust code for libxul"
[features]
-bindgen = ["gkrust-shared/bindgen"]
-servo = ["gkrust-shared/servo"]
quantum_render = ["gkrust-shared/quantum_render"]
webrender_debugger = ["gkrust-shared/webrender_debugger"]
cubeb-remoting = ["gkrust-shared/cubeb-remoting"]
diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild
index bf8e73c98da6..26a092cae05c 100644
--- a/toolkit/library/rust/gkrust-features.mozbuild
+++ b/toolkit/library/rust/gkrust-features.mozbuild
@@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-gkrust_features = ['servo', 'bindgen']
+gkrust_features = []
if CONFIG['MOZ_DEBUG']:
gkrust_features += [
diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml
index 49ff9d8291f6..874260de5543 100644
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -6,7 +6,7 @@ license = "MPL-2.0"
description = "Shared Rust code for libxul"
[dependencies]
-geckoservo = { path = "../../../../servo/ports/geckolib", optional = true }
+geckoservo = { path = "../../../../servo/ports/geckolib" }
kvstore = { path = "../../../components/kvstore" }
lmdb-rkv-sys = { version = "0.8.4", features = ["mdb_idl_logn_9"] }
mp4parse_capi = { path = "../../../../media/mp4parse-rust/mp4parse_capi" }
@@ -47,8 +47,6 @@ rustc_version = "0.2"
[features]
default = []
-bindgen = ["geckoservo/bindgen"]
-servo = ["geckoservo"]
quantum_render = ["webrender_bindings"]
webrender_debugger = ["webrender_bindings/webrender_debugger"]
cubeb-remoting = ["cubeb-sys", "audioipc-client", "audioipc-server"]
diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs
index 1e544632b20e..430643e7dbc9 100644
--- a/toolkit/library/rust/shared/lib.rs
+++ b/toolkit/library/rust/shared/lib.rs
@@ -4,7 +4,6 @@
#![cfg_attr(feature = "oom_with_hook", feature(alloc_error_hook))]
-#[cfg(feature="servo")]
extern crate geckoservo;
extern crate kvstore;