Skip to content

Commit 11097b1

Browse files
Port previous to non-Win32
1 parent 1b3772b commit 11097b1

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/non_windows.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use self::super::{ParameterBundle, env_target_and_rc, apply_parameters};
22
use std::process::{Command, Stdio};
3+
use std::ffi::{OsString, OsStr};
34
use std::path::{PathBuf, Path};
4-
use std::{env, fs, mem};
55
use std::borrow::Cow;
6-
use std::ffi::OsStr;
6+
use std::{fs, mem};
77
use memchr::memmem;
88

99

@@ -64,7 +64,7 @@ impl Compiler {
6464
if is_runnable(&executable) {
6565
return Ok(Compiler {
6666
tp: CompilerType::WindRes,
67-
executable: executable.into(),
67+
executable: OsString::from(executable).into(),
6868
});
6969
} else {
7070
return Err(executable.into());
@@ -80,7 +80,7 @@ impl Compiler {
8080
.map(|out| memmem::find(&out.stdout, b"no-preprocess").is_some())
8181
.unwrap_or(false),
8282
},
83-
executable: "llvm-rc".into(),
83+
executable: OsStr::new("llvm-rc").into(),
8484
});
8585
} else {
8686
return Err("llvm-rc".into());
@@ -105,7 +105,7 @@ impl Compiler {
105105
.include(out_dir)
106106
.expand()).map_err(|e| e.to_string())?;
107107

108-
try_command(Command::new(&self.executable[..])
108+
try_command(Command::new(&self.executable)
109109
.args(&["/fo", &out_file])
110110
.args(&["/C", "65001"]) // UTF-8, cf. https://github.com/nabijaczleweli/rust-embed-resource/pull/73
111111
.args(if has_no_preprocess {
@@ -119,18 +119,18 @@ impl Compiler {
119119
.args(&["--", &preprocessed_path])
120120
.stdin(Stdio::piped())
121121
.current_dir(or_curdir(Path::new(resource).parent().expect("Resource parent nonexistent?"))),
122-
Path::new(&self.executable[..]),
122+
Path::new(&self.executable),
123123
"compile",
124124
&preprocessed_path,
125125
&out_file)?;
126126
}
127127
CompilerType::WindRes => {
128-
try_command(apply_parameters(Command::new(&self.executable[..])
128+
try_command(apply_parameters(Command::new(&self.executable)
129129
.args(&["--input", resource, "--output-format=coff", "--output", &out_file, "--include-dir", out_dir]),
130130
"-D",
131131
"--include-dir",
132132
parameters),
133-
Path::new(&self.executable[..]),
133+
Path::new(&self.executable),
134134
"compile",
135135
resource,
136136
&out_file)?;
@@ -198,10 +198,10 @@ fn guess_compiler_variant(s: OsString) -> Result<Compiler, Cow<'static, str>> {
198198
tp: CompilerType::LlvmRc { has_no_preprocess: memmem::find(&out.stdout, b"no-preprocess").is_some() },
199199
})
200200
} else {
201-
Err(format!("Unknown RC compiler variant: {}", s).into())
201+
Err(format!("Unknown RC compiler variant: {}", s.display()).into())
202202
}
203203
}
204-
Err(err) => Err(format!("Couldn't execute {}: {}", s, err).into()),
204+
Err(err) => Err(format!("Couldn't execute {}: {}", s.display(), err).into()),
205205
}
206206
}
207207

0 commit comments

Comments
 (0)