Skip to content

Commit d5cd7e3

Browse files
committed
move to osstring
1 parent 8fef0eb commit d5cd7e3

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(warnings)]
66

77
use std::collections::HashMap;
8-
use std::ffi::OsStr;
8+
use std::ffi::{OsStr, OsString};
99
use std::fmt::{Debug, Formatter};
1010
use std::hash::{DefaultHasher, Hash, Hasher};
1111
use std::path::Path;
@@ -69,9 +69,9 @@ impl OutputMode {
6969
/// [allow_failure]: BootstrapCommand::allow_failure
7070
/// [delay_failure]: BootstrapCommand::delay_failure
7171
pub struct BootstrapCommand {
72-
program: String,
73-
args: Vec<String>,
74-
envs: Vec<(String, String)>,
72+
program: OsString,
73+
args: Vec<OsString>,
74+
envs: Vec<(OsString, OsString)>,
7575
cwd: Option<PathBuf>,
7676

7777
command: Command,
@@ -90,8 +90,7 @@ impl<'a> BootstrapCommand {
9090
}
9191

9292
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
93-
let arg_str = arg.as_ref().to_string_lossy().into_owned();
94-
self.args.push(arg_str.clone());
93+
self.args.push(arg.as_ref().to_os_string());
9594
self.command.arg(arg.as_ref());
9695
self
9796
}
@@ -112,9 +111,7 @@ impl<'a> BootstrapCommand {
112111
K: AsRef<OsStr>,
113112
V: AsRef<OsStr>,
114113
{
115-
let key_str = key.as_ref().to_string_lossy().into_owned();
116-
let val_str = val.as_ref().to_string_lossy().into_owned();
117-
self.envs.push((key_str.clone(), val_str.clone()));
114+
self.envs.push((key.as_ref().to_os_string(), val.as_ref().to_os_string()));
118115
self.command.env(key, val);
119116
self
120117
}
@@ -249,7 +246,7 @@ impl From<Command> for BootstrapCommand {
249246
let program = command.get_program().to_owned();
250247

251248
Self {
252-
program: program.clone().into_string().unwrap(),
249+
program: program.clone(),
253250
args: Vec::new(),
254251
envs: Vec::new(),
255252
cwd: None,

src/bootstrap/src/utils/execution_context.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ impl ExecutionContext {
158158

159159
let output = self.start(command, stdout, stderr).wait_for_output(self);
160160

161-
self.command_cache.insert(cache_key, output.clone());
162-
163-
// if output != CommandOutput::default() {
164-
// self.command_cache.insert(cache_key, output.clone());
165-
// }
161+
if !self.dry_run() || command.run_always {
162+
self.command_cache.insert(cache_key, output.clone());
163+
}
166164

167165
output
168166
}

0 commit comments

Comments
 (0)