diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs
index b5dd2ed4126..95bb1622942 100644
--- a/components/style/build_gecko.rs
+++ b/components/style/build_gecko.rs
@@ -3,31 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
mod common {
- use std::{env, fs, io};
- use std::path::{Path, PathBuf};
+ use std::env;
+ use std::path::PathBuf;
lazy_static! {
pub static ref OUTDIR_PATH: PathBuf =
PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("gecko");
}
-
- /// Copy contents of one directory into another.
- /// It currently only does a shallow copy.
- pub 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(())
- }
}
#[cfg(feature = "bindgen")]
@@ -613,23 +595,33 @@ mod bindings {
generate_bindings(),
generate_atoms(),
}
-
- // Copy all generated files to dist for the binding package
- let path = DISTDIR_PATH.join("rust_bindings/style");
- if path.exists() {
- fs::remove_dir_all(&path).expect("Fail to remove binding dir in dist");
- }
- fs::create_dir_all(&path).expect("Fail to create bindings dir in dist");
- copy_dir(&*OUTDIR_PATH, &path, |_| {}).expect("Fail to copy generated files to dist dir");
}
}
#[cfg(not(feature = "bindgen"))]
mod bindings {
- use std::env;
- use std::path::PathBuf;
+ use std::{env, fs, io};
+ use std::path::{Path, PathBuf};
use super::common::*;
+ /// 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(())
+ }
+
pub fn generate() {
let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated");
println!("cargo:rerun-if-changed={}", dir.display());