Spawn thread for building, allows for multiple build at the same time

This commit is contained in:
Thomas Forgione 2018-11-23 09:47:41 +01:00
parent f65602fb71
commit 749692bb07
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 20 additions and 13 deletions

View File

@ -18,7 +18,6 @@ use mars::{GeneralBuilder, builder_arguments_from_string};
fn main() {
let builder = GeneralBuilder::new();
let (tx, rx) = mpsc::channel();
@ -53,10 +52,16 @@ fn main() {
while let Some(uri) = tasks.pop() {
thread::spawn(move || {
let builder = GeneralBuilder::new();
let uri = percent_decode(uri.path().as_bytes()).decode_utf8().unwrap();
let (path, args) = builder_arguments_from_string(&*uri);
println!("{}", format!("---- STARTING BUILD ---- from {}", uri).bold().green());
let path_string = path.to_str().unwrap();
let start_string = format!("---- STARTING BUILD ---- from {} {}", path_string, args.join(" "));
println!("{}", start_string.bold().green());
match builder.build(&path, &args) {
Err(_) => {
println!("{}", "--------- FAIL ---------".bold().red());
@ -67,6 +72,8 @@ fn main() {
};
println!();
});
}
}
}