From 91be6c31c3fd037d7c3521487f290a3f6bd0cca0 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sat, 21 Apr 2018 00:38:08 +1000 Subject: [PATCH] style: Not copy generated binding files into dist. Bug: 1455623 Reviewed-by: emilio MozReview-Commit-ID: GBnkmwjDS8Y --- components/style/build_gecko.rs | 52 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 30 deletions(-) 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());