Skip to content

Commit 1216b17

Browse files
committed
fix: handle Windows paths
1 parent a6c1a8b commit 1216b17

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

test/unit/extra_outdirs/proc_macro.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ pub fn write_to_outdirs(_item: TokenStream) -> TokenStream {
1616
// Write to the output directories declared by Bazel
1717
for entry in outdirs_paths.split(',') {
1818
if let Some((_dir, path)) = entry.split_once(':') {
19-
let dir_path = PathBuf::from(path.trim());
20-
19+
let path_str = path.trim();
20+
// PathBuf will normalize the path correctly for the current platform
21+
// On Windows, ensure forward slashes are converted to backslashes
22+
let dir_path = if cfg!(windows) {
23+
// Convert forward slashes to backslashes for Windows
24+
PathBuf::from(path_str.replace('/', "\\"))
25+
} else {
26+
PathBuf::from(path_str)
27+
};
28+
2129
// Create the directory if it doesn't exist
30+
// create_dir_all creates all parent directories as needed
2231
if let Err(e) = fs::create_dir_all(&dir_path) {
2332
panic!("Failed to create directory {}: {:?}", dir_path.display(), e);
2433
}

0 commit comments

Comments
 (0)