Skip to content

Commit ab747c1

Browse files
committed
move to osstring
1 parent f27e2b5 commit ab747c1

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
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::{Hash, Hasher};
1111
use std::path::Path;
@@ -77,9 +77,9 @@ pub struct CommandCacheKey {
7777
/// [allow_failure]: BootstrapCommand::allow_failure
7878
/// [delay_failure]: BootstrapCommand::delay_failure
7979
pub struct BootstrapCommand {
80-
program: String,
81-
args: Vec<String>,
82-
envs: Vec<(String, String)>,
80+
program: OsString,
81+
args: Vec<OsString>,
82+
envs: Vec<(OsString, OsString)>,
8383
cwd: Option<PathBuf>,
8484

8585
command: Command,
@@ -98,8 +98,7 @@ impl<'a> BootstrapCommand {
9898
}
9999

100100
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
101-
let arg_str = arg.as_ref().to_string_lossy().into_owned();
102-
self.args.push(arg_str.clone());
101+
self.args.push(arg.as_ref().to_os_string());
103102
self.command.arg(arg.as_ref());
104103
self
105104
}
@@ -120,9 +119,7 @@ impl<'a> BootstrapCommand {
120119
K: AsRef<OsStr>,
121120
V: AsRef<OsStr>,
122121
{
123-
let key_str = key.as_ref().to_string_lossy().into_owned();
124-
let val_str = val.as_ref().to_string_lossy().into_owned();
125-
self.envs.push((key_str.clone(), val_str.clone()));
122+
self.envs.push((key.as_ref().to_os_string(), val.as_ref().to_os_string()));
126123
self.command.env(key, val);
127124
self
128125
}
@@ -257,7 +254,7 @@ impl From<Command> for BootstrapCommand {
257254
let program = command.get_program().to_owned();
258255

259256
Self {
260-
program: program.clone().into_string().unwrap(),
257+
program: program.clone(),
261258
args: Vec::new(),
262259
envs: Vec::new(),
263260
cwd: None,

src/bootstrap/src/utils/execution_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl ExecutionContext {
159159

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

162-
if output != CommandOutput::default() {
162+
if !self.dry_run() || command.run_always {
163163
self.command_cache.insert(cache_key, output.clone());
164164
}
165165

0 commit comments

Comments
 (0)