Fix extern_process args
This commit is contained in:
parent
177becea98
commit
b4c5ee33ae
2 changed files with 22 additions and 8 deletions
|
@ -12,6 +12,7 @@ pub mod msg;
|
|||
use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
|
||||
use ra_tt::{SmolStr, Subtree};
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
@ -56,10 +57,14 @@ pub struct ProcMacroClient {
|
|||
}
|
||||
|
||||
impl ProcMacroClient {
|
||||
pub fn extern_process<T: AsRef<str>>(
|
||||
pub fn extern_process<I, S>(
|
||||
process_path: &Path,
|
||||
args: &[T],
|
||||
) -> Result<ProcMacroClient, std::io::Error> {
|
||||
args: I,
|
||||
) -> Result<ProcMacroClient, std::io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
|
||||
Ok(ProcMacroClient {
|
||||
kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTas
|
|||
use io::{BufRead, BufReader};
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
ffi::OsStr,
|
||||
io::{self, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::{Child, Command, Stdio},
|
||||
|
@ -44,9 +45,13 @@ impl Drop for Process {
|
|||
}
|
||||
|
||||
impl Process {
|
||||
fn run<T: AsRef<str>>(process_path: &Path, args: &[T]) -> Result<Process, io::Error> {
|
||||
fn run<I, S>(process_path: &Path, args: I) -> Result<Process, io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let child = Command::new(process_path.clone())
|
||||
.args(args.iter().map(|it| it.as_ref()))
|
||||
.args(args)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::null())
|
||||
|
@ -75,10 +80,14 @@ impl Process {
|
|||
}
|
||||
|
||||
impl ProcMacroProcessSrv {
|
||||
pub fn run<T: AsRef<str>>(
|
||||
pub fn run<I, S>(
|
||||
process_path: &Path,
|
||||
args: &[T],
|
||||
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> {
|
||||
args: I,
|
||||
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let process = Process::run(process_path, args)?;
|
||||
|
||||
let (task_tx, task_rx) = bounded(0);
|
||||
|
|
Loading…
Add table
Reference in a new issue