|
|
@ -41,9 +41,18 @@ type ProgressSender = progress::ProgressSender;
|
|
|
|
#[cfg(not(feature="progress"))]
|
|
|
|
#[cfg(not(feature="progress"))]
|
|
|
|
type ProgressSender = ();
|
|
|
|
type ProgressSender = ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="collect_err")]
|
|
|
|
|
|
|
|
struct Error
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pub internal: process::Error,
|
|
|
|
|
|
|
|
pub stack: fixed_stack::FixedStack<(bool, String)>,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(feature="collect_err"))]
|
|
|
|
|
|
|
|
type Error = process::Error;
|
|
|
|
|
|
|
|
|
|
|
|
#[allow(unused_mut)]
|
|
|
|
#[allow(unused_mut)]
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
async fn do_work(process: impl AsRef<Process>, file: impl AsRef<OsStr>, mut prog: ProgressSender) -> Result<fixed_stack::IntoIter<String>, process::Error>
|
|
|
|
async fn do_work(process: impl AsRef<Process>, file: impl AsRef<OsStr>, mut prog: ProgressSender) -> Result<fixed_stack::IntoIter<(bool, String)>, Error>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let file = file.as_ref();
|
|
|
|
let file = file.as_ref();
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +65,10 @@ async fn do_work(process: impl AsRef<Process>, file: impl AsRef<OsStr>, mut prog
|
|
|
|
tokio::spawn(async move {
|
|
|
|
tokio::spawn(async move {
|
|
|
|
let mut stack = fixed_stack::FixedStack::new(100);
|
|
|
|
let mut stack = fixed_stack::FixedStack::new(100);
|
|
|
|
while let Some((err, value)) = rx.recv().await {
|
|
|
|
while let Some((err, value)) = rx.recv().await {
|
|
|
|
|
|
|
|
cfg_if! {
|
|
|
|
|
|
|
|
if #[cfg(feature="collect_err")] {
|
|
|
|
|
|
|
|
stack.push((err, value));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if err {
|
|
|
|
if err {
|
|
|
|
cfg_if!{
|
|
|
|
cfg_if!{
|
|
|
|
if #[cfg(feature="progress")] {
|
|
|
|
if #[cfg(feature="progress")] {
|
|
|
@ -68,7 +81,9 @@ async fn do_work(process: impl AsRef<Process>, file: impl AsRef<OsStr>, mut prog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stack.push(value);
|
|
|
|
stack.push((false, value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stack
|
|
|
|
stack
|
|
|
@ -78,7 +93,18 @@ async fn do_work(process: impl AsRef<Process>, file: impl AsRef<OsStr>, mut prog
|
|
|
|
//let _ = opt_await.await;
|
|
|
|
//let _ = opt_await.await;
|
|
|
|
match process::contained_spawn(process, std::iter::once(file), tx).await {
|
|
|
|
match process::contained_spawn(process, std::iter::once(file), tx).await {
|
|
|
|
Ok(_) => Ok(collector.await.expect("Child panic").into_iter()),
|
|
|
|
Ok(_) => Ok(collector.await.expect("Child panic").into_iter()),
|
|
|
|
Err(error) => Err(error),
|
|
|
|
Err(error) => {
|
|
|
|
|
|
|
|
cfg_if! {
|
|
|
|
|
|
|
|
if #[cfg(feature="collect_err")] {
|
|
|
|
|
|
|
|
Err(Error{
|
|
|
|
|
|
|
|
internal: error,
|
|
|
|
|
|
|
|
stack: collector.await.expect("Child panic"),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Err(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +114,7 @@ where I: IntoIterator<Item=T>,
|
|
|
|
T: AsRef<OsStr> + Send + Sync + 'static + Clone,
|
|
|
|
T: AsRef<OsStr> + Send + Sync + 'static + Clone,
|
|
|
|
U: Into<PathBuf>
|
|
|
|
U: Into<PathBuf>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let (tx,mut rx) = mpsc::channel::<(T, fixed_stack::IntoIter<String>, usize)>(children.as_ref().map(|&x| usize::from(x)).unwrap_or(16));
|
|
|
|
let (tx,mut rx) = mpsc::channel::<(T, fixed_stack::IntoIter<(bool, String)>, usize)>(children.as_ref().map(|&x| usize::from(x)).unwrap_or(16));
|
|
|
|
let semaphore = children.map(|children| Arc::new(Semaphore::new(children.into())));
|
|
|
|
let semaphore = children.map(|children| Arc::new(Semaphore::new(children.into())));
|
|
|
|
let process = Arc::new(Process::new(process, flags.leanify_flags.clone()));
|
|
|
|
let process = Arc::new(Process::new(process, flags.leanify_flags.clone()));
|
|
|
|
|
|
|
|
|
|
|
@ -109,20 +135,28 @@ where I: IntoIterator<Item=T>,
|
|
|
|
cfg_if!{
|
|
|
|
cfg_if!{
|
|
|
|
if #[cfg(feature="progress")] {
|
|
|
|
if #[cfg(feature="progress")] {
|
|
|
|
let mut builder =progress.builder();
|
|
|
|
let mut builder =progress.builder();
|
|
|
|
for line in values.into_iter()
|
|
|
|
for (err, line) in values.into_iter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if err {
|
|
|
|
|
|
|
|
builder.eprintln(format!("[{}] {:?}: {}", colour::style(colour!(Color::BrightYellow), "!"), file.as_ref(), colour::style(colour!(Color::Yellow),line)));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
let line = format!(" -> ({}) {:?}: {}", i, file.as_ref(), line);
|
|
|
|
let line = format!(" -> ({}) {:?}: {}", i, file.as_ref(), line);
|
|
|
|
builder.println(line);
|
|
|
|
builder.println(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
let _ = builder.send().await;
|
|
|
|
let _ = builder.send().await;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for line in values.into_iter()
|
|
|
|
for (err, line) in values.into_iter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if err {
|
|
|
|
|
|
|
|
eprintln!("[{}] {:?}: {}", colour::style(colour!(Color::BrightYellow), "!"), file.as_ref(), colour::style(colour!(Color::Yellow),line));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
println!(" -> ({}) {:?}: {}", i, file.as_ref(), line);
|
|
|
|
println!(" -> ({}) {:?}: {}", i, file.as_ref(), line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let mut i=0usize;
|
|
|
|
let mut i=0usize;
|
|
|
@ -152,7 +186,7 @@ where I: IntoIterator<Item=T>,
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
#[cfg(nightly)] type NoReturn = !;
|
|
|
|
#[cfg(nightly)] type NoReturn = !;
|
|
|
|
#[cfg(not(nightly))] type NoReturn = ();
|
|
|
|
#[cfg(not(nightly))] type NoReturn = ();
|
|
|
|
(Option::<NoReturn>::None, do_work(process.as_ref(), &filename, ()).await)
|
|
|
|
(Option::<NoReturn>::None, do_work(&process, &filename, ()).await)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -160,6 +194,13 @@ where I: IntoIterator<Item=T>,
|
|
|
|
match worker.1 {
|
|
|
|
match worker.1 {
|
|
|
|
Ok(strings) => tx.send((filename, strings, i)).await.map_err(|_| "Child panic").unwrap(),
|
|
|
|
Ok(strings) => tx.send((filename, strings, i)).await.map_err(|_| "Child panic").unwrap(),
|
|
|
|
Err(error) => {
|
|
|
|
Err(error) => {
|
|
|
|
|
|
|
|
#[cfg(feature="collect_err")] let error = {
|
|
|
|
|
|
|
|
let Error{internal, stack} = error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send((filename.clone(), stack.into_iter(), i)).await.map_err(|_| "Child panic").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal
|
|
|
|
|
|
|
|
};
|
|
|
|
#[cfg(not(feature="progress"))] eprintln!("[{}] {:?}: {}", colour::style(colour!(Color::Yellow),"!"), filename.as_ref(), colour::style(colour!(Color::Yellow), error));
|
|
|
|
#[cfg(not(feature="progress"))] eprintln!("[{}] {:?}: {}", colour::style(colour!(Color::Yellow),"!"), filename.as_ref(), colour::style(colour!(Color::Yellow), error));
|
|
|
|
#[cfg(feature="progress")] let _ = progress.eprintln(format!("[{}] ({}) {:?}: {}", colour::style(colour!(Color::Yellow),"!"),i, filename.as_ref(), colour::style(colour!(Color::Yellow), error))).await
|
|
|
|
#[cfg(feature="progress")] let _ = progress.eprintln(format!("[{}] ({}) {:?}: {}", colour::style(colour!(Color::Yellow),"!"),i, filename.as_ref(), colour::style(colour!(Color::Yellow), error))).await
|
|
|
|
.or_else(|e| {
|
|
|
|
.or_else(|e| {
|
|
|
|