mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Not copy generated binding files into dist.
Bug: 1455623 Reviewed-by: emilio MozReview-Commit-ID: GBnkmwjDS8Y
This commit is contained in:
parent
cf8f371bdb
commit
91be6c31c3
1 changed files with 22 additions and 30 deletions
|
@ -3,31 +3,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
mod common {
|
mod common {
|
||||||
use std::{env, fs, io};
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref OUTDIR_PATH: PathBuf =
|
pub static ref OUTDIR_PATH: PathBuf =
|
||||||
PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("gecko");
|
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<P, Q, F>(from: P, to: Q, callback: F) -> io::Result<()>
|
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
Q: AsRef<Path>,
|
|
||||||
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")]
|
#[cfg(feature = "bindgen")]
|
||||||
|
@ -613,23 +595,33 @@ mod bindings {
|
||||||
generate_bindings(),
|
generate_bindings(),
|
||||||
generate_atoms(),
|
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"))]
|
#[cfg(not(feature = "bindgen"))]
|
||||||
mod bindings {
|
mod bindings {
|
||||||
use std::env;
|
use std::{env, fs, io};
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use super::common::*;
|
use super::common::*;
|
||||||
|
|
||||||
|
/// Copy contents of one directory into another.
|
||||||
|
/// It currently only does a shallow copy.
|
||||||
|
fn copy_dir<P, Q, F>(from: P, to: Q, callback: F) -> io::Result<()>
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
Q: AsRef<Path>,
|
||||||
|
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() {
|
pub fn generate() {
|
||||||
let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated");
|
let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated");
|
||||||
println!("cargo:rerun-if-changed={}", dir.display());
|
println!("cargo:rerun-if-changed={}", dir.display());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue