Skip to content

Commit

Permalink
Fix display - turns out Path::display is platform-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Feb 9, 2025
1 parent 0a320b8 commit 5808936
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cargo/cargo_toml_variable_extractor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ use cargo_util_schemas::manifest::{
fn main() {
let args: Vec<_> = args_os().collect();
let (out_path, manifest, workspace) = match &args[..] {
[_, out_path, manifest_path] => (out_path, parse_manifest(manifest_path), None),
[_, out_path, manifest_path] => (
out_path,
parse_manifest(manifest_path),
None,
),
[_, out_path, manifest_path, workspace_manifest_path] => (
out_path,
parse_manifest(manifest_path),
Expand Down Expand Up @@ -177,7 +181,7 @@ fn print_manifest_env_vars(
);
}

fn parse_manifest<P: AsRef<Path>>(path: P) -> TomlManifest {
fn parse_manifest<P: AsRef<Path>>(path: &P) -> TomlManifest {
let path = path.as_ref();
let content = read_to_string(path)
.unwrap_or_else(|err| panic!("Failed to read {}: {}", path.display(), err));
Expand Down Expand Up @@ -223,7 +227,13 @@ fn print_inheritable_path(
) {
(Some(InheritableString::Value(path)), _) => Some(path.to_owned()),
(Some(InheritableString::Inherit(_)), Some((relpath, value_path))) => {
Some(format!("{}", relpath.join(value_path).display()))
let path = relpath.join(value_path);
let joined = path
.components()
.map(|c| c.as_os_str().to_string_lossy().into_owned())
.collect::<Vec<_>>()
.join(std::path::MAIN_SEPARATOR_STR);
Some(format!("{}", joined))
}
(Some(InheritableString::Inherit(_)), None) => {
panic!("Can't inherit a {key} which was missing from the workspace")
Expand Down

0 comments on commit 5808936

Please sign in to comment.