Skip to content

Commit 5290d92

Browse files
committed
shorten build dir for windows
1 parent b401f77 commit 5290d92

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

crates/cargo-gpu/src/spirv_source.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ impl core::fmt::Display for SpirvSource {
5555
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
5656
match self {
5757
Self::CratesIO(version) => version.fmt(f),
58-
Self::Git { url, rev } => f.write_str(&format!("{url}+{rev}")),
58+
Self::Git { url, rev } => {
59+
// shorten rev to 8 chars, prevents windows compile errors due to too long paths... seriously
60+
if let Some(short_rev) = rev.get(..8) {
61+
write!(f, "{url}+{short_rev}")
62+
} else {
63+
write!(f, "{url}+{rev}")
64+
}
65+
}
5966
Self::Path {
6067
rust_gpu_repo_root,
6168
version,
62-
} => f.write_str(&format!("{rust_gpu_repo_root}+{version}")),
69+
} => write!(f, "{rust_gpu_repo_root}+{version}"),
6370
}
6471
}
6572
}
@@ -109,9 +116,7 @@ impl SpirvSource {
109116
} => Ok(rust_gpu_repo_root.as_std_path().to_owned()),
110117
Self::CratesIO { .. } | Self::Git { .. } => {
111118
let dir = crate::to_dirname(self.to_string().as_ref());
112-
Ok(crate::cache_dir()?
113-
.join("rustc_backend_spirv_install")
114-
.join(dir))
119+
Ok(crate::cache_dir()?.join("codegen").join(dir))
115120
}
116121
}
117122
}
@@ -269,9 +274,6 @@ mod test {
269274
.to_str()
270275
.map(std::string::ToString::to_string)
271276
.unwrap();
272-
assert_eq!(
273-
"https___github_com_Rust-GPU_rust-gpu+82a0f69008414f51d59184763146caa6850ac588",
274-
&name
275-
);
277+
assert_eq!("https___github_com_Rust-GPU_rust-gpu+82a0f690", &name);
276278
}
277279
}

0 commit comments

Comments
 (0)