Output binding files to dist dir in addition.

This commit is contained in:
Xidorn Quan 2017-03-31 00:22:15 +11:00
parent 3993f8d7fe
commit f3a5e28949

View file

@ -35,7 +35,7 @@ mod bindings {
use std::cmp; use std::cmp;
use std::collections::HashSet; use std::collections::HashSet;
use std::env; use std::env;
use std::fs::File; use std::fs::{self, File};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Mutex; use std::sync::Mutex;
@ -59,6 +59,11 @@ mod bindings {
pub static ref LAST_MODIFIED: Mutex<SystemTime> = pub static ref LAST_MODIFIED: Mutex<SystemTime> =
Mutex::new(get_modified_time(&env::current_exe().unwrap()) Mutex::new(get_modified_time(&env::current_exe().unwrap())
.expect("Failed to get modified time of executable")); .expect("Failed to get modified time of executable"));
static ref BINDING_DISTDIR_PATH: PathBuf = {
let path = DISTDIR_PATH.join("rust_bindings/style");
fs::create_dir_all(&path).expect("Fail to create bindings dir in dist");
path
};
} }
fn get_modified_time(file: &Path) -> Option<SystemTime> { fn get_modified_time(file: &Path) -> Option<SystemTime> {
@ -229,7 +234,10 @@ mod bindings {
result = Regex::new(&format!(r"\b{}\b", fixup.pat)).unwrap().replace_all(&result, fixup.rep.as_str()) result = Regex::new(&format!(r"\b{}\b", fixup.pat)).unwrap().replace_all(&result, fixup.rep.as_str())
.into_owned().into(); .into_owned().into();
} }
File::create(&out_file).unwrap().write_all(&result.into_bytes()).expect("Unable to write output"); let bytes = result.into_bytes();
File::create(&out_file).unwrap().write_all(&bytes).expect("Unable to write output");
File::create(&BINDING_DISTDIR_PATH.join(file)).unwrap()
.write_all(&bytes).expect("Unable to write output to binding dist");
} }
fn get_arc_types() -> Vec<String> { fn get_arc_types() -> Vec<String> {
@ -523,7 +531,6 @@ mod bindings {
pub fn setup_logging() { pub fn setup_logging() {
use log; use log;
use std::fs;
struct BuildLogger { struct BuildLogger {
file: Option<Mutex<fs::File>>, file: Option<Mutex<fs::File>>,