Skip to content

Commit 3c66ac3

Browse files
committed
Fix run_make on Windows
1 parent 561a910 commit 3c66ac3

File tree

6 files changed

+22
-26
lines changed

6 files changed

+22
-26
lines changed

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objdiff-core/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ bindings = [
5252
build = [
5353
"dep:notify",
5454
"dep:notify-debouncer-full",
55-
"dep:path-slash",
5655
"dep:reqwest",
5756
"dep:self_update",
5857
"dep:shell-escape",
@@ -186,7 +185,6 @@ tempfile = { version = "3.15", optional = true }
186185
time = { version = "0.3", optional = true }
187186

188187
[target.'cfg(windows)'.dependencies]
189-
path-slash = { version = "0.2", optional = true }
190188
winapi = { version = "0.3", optional = true }
191189

192190
# For Linux static binaries, use rustls

objdiff-core/src/build/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub mod watcher;
22

33
use std::process::Command;
44

5-
use typed_path::Utf8PlatformPathBuf;
5+
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPath};
66

77
pub struct BuildStatus {
88
pub success: bool,
@@ -31,7 +31,7 @@ pub struct BuildConfig {
3131
pub selected_wsl_distro: Option<String>,
3232
}
3333

34-
pub fn run_make(config: &BuildConfig, arg: &str) -> BuildStatus {
34+
pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
3535
let Some(cwd) = &config.project_dir else {
3636
return BuildStatus {
3737
success: false,
@@ -51,7 +51,6 @@ pub fn run_make(config: &BuildConfig, arg: &str) -> BuildStatus {
5151
let mut command = {
5252
use std::os::windows::process::CommandExt;
5353

54-
use path_slash::PathExt;
5554
let mut command = if config.selected_wsl_distro.is_some() {
5655
Command::new("wsl")
5756
} else {
@@ -61,21 +60,21 @@ pub fn run_make(config: &BuildConfig, arg: &str) -> BuildStatus {
6160
// Strip distro root prefix \\wsl.localhost\{distro}
6261
let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro);
6362
let cwd = match cwd.strip_prefix(wsl_path_prefix) {
64-
Ok(new_cwd) => format!("/{}", new_cwd.to_slash_lossy().as_ref()),
65-
Err(_) => cwd.to_string_lossy().to_string(),
63+
Ok(new_cwd) => Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()),
64+
Err(_) => cwd.with_unix_encoding(),
6665
};
6766

6867
command
6968
.arg("--cd")
70-
.arg(cwd)
69+
.arg(cwd.as_str())
7170
.arg("-d")
7271
.arg(distro)
7372
.arg("--")
7473
.arg(make)
7574
.args(make_args)
76-
.arg(arg.to_slash_lossy().as_ref());
75+
.arg(arg.as_str());
7776
} else {
78-
command.current_dir(cwd).args(make_args).arg(arg.to_slash_lossy().as_ref());
77+
command.current_dir(cwd).args(make_args).arg(arg.as_str());
7978
}
8079
command.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW);
8180
command

objdiff-core/src/jobs/objdiff.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{sync::mpsc::Receiver, task::Waker};
22

3-
use anyhow::{anyhow, Error, Result};
3+
use anyhow::{bail, Error, Result};
44
use time::OffsetDateTime;
55
use typed_path::Utf8PlatformPathBuf;
66

@@ -43,14 +43,20 @@ fn run_build(
4343
.as_ref()
4444
.ok_or_else(|| Error::msg("Missing project dir"))?;
4545
if let Some(target_path) = &config.target_path {
46-
target_path_rel = Some(target_path.strip_prefix(project_dir).map_err(|_| {
47-
anyhow!("Target path '{}' doesn't begin with '{}'", target_path, project_dir)
48-
})?);
46+
target_path_rel = match target_path.strip_prefix(project_dir) {
47+
Ok(p) => Some(p.with_unix_encoding()),
48+
Err(_) => {
49+
bail!("Target path '{}' doesn't begin with '{}'", target_path, project_dir);
50+
}
51+
};
4952
}
5053
if let Some(base_path) = &config.base_path {
51-
base_path_rel = Some(base_path.strip_prefix(project_dir).map_err(|_| {
52-
anyhow!("Base path '{}' doesn't begin with '{}'", base_path, project_dir)
53-
})?);
54+
base_path_rel = match base_path.strip_prefix(project_dir) {
55+
Ok(p) => Some(p.with_unix_encoding()),
56+
Err(_) => {
57+
bail!("Base path '{}' doesn't begin with '{}'", base_path, project_dir);
58+
}
59+
};
5460
};
5561
}
5662

objdiff-gui/src/views/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn object_context_ui(ui: &mut egui::Ui, object: &ObjectConfig) {
384384
.clicked()
385385
{
386386
log::info!("Opening file {}", source_path);
387-
if let Err(e) = open::that_detached(source_path) {
387+
if let Err(e) = open::that_detached(source_path.as_str()) {
388388
log::error!("Failed to open source file: {e}");
389389
}
390390
ui.close_menu();

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl DiffViewState {
281281
state.config.selected_obj.as_ref().and_then(|obj| obj.source_path.as_ref())
282282
{
283283
log::info!("Opening file {}", source_path);
284-
open::that_detached(source_path).unwrap_or_else(|err| {
284+
open::that_detached(source_path.as_str()).unwrap_or_else(|err| {
285285
log::error!("Failed to open source file: {err}");
286286
});
287287
}

0 commit comments

Comments
 (0)