Browse Source

Use rayon for parallel compilation

vs2017
Nipunn Koorapati 8 years ago
parent
commit
b25a493283
  1. 3
      Cargo.toml
  2. 10
      src/lib.rs

3
Cargo.toml

@ -13,5 +13,8 @@ code.
"""
keywords = ["build-dependencies"]
[dependencies]
rayon = "0.4"
[dev-dependencies]
tempdir = "0.3"

10
src/lib.rs

@ -46,6 +46,8 @@
#![cfg_attr(test, deny(warnings))]
#![deny(missing_docs)]
extern crate rayon;
use std::env;
use std::ffi::{OsString, OsStr};
use std::fs;
@ -53,6 +55,8 @@ use std::io;
use std::path::{PathBuf, Path};
use std::process::{Command, Stdio};
use rayon::prelude::*;
#[cfg(windows)]
mod registry;
pub mod windows_registry;
@ -325,7 +329,7 @@ impl Config {
let dst = self.get_out_dir();
let mut objects = Vec::new();
for file in self.files.iter() {
self.files.par_iter().map(|file| {
let obj = dst.join(file).with_extension("o");
let obj = if !obj.starts_with(&dst) {
dst.join(obj.file_name().unwrap())
@ -333,8 +337,8 @@ impl Config {
obj
};
self.compile_object(file, &obj);
objects.push(obj);
}
obj
}).collect_into(&mut objects);
self.assemble(lib_name, &dst.join(output), &objects);

Loading…
Cancel
Save