|
1 | 1 | use std::collections::HashMap; |
2 | 2 | use std::hash::{DefaultHasher, Hash, Hasher}; |
3 | | -use std::io::Read; |
| 3 | +use std::io::{ErrorKind, Read}; |
4 | 4 | use std::path::{Path, PathBuf}; |
5 | 5 | use std::sync::atomic::{AtomicBool, Ordering}; |
6 | 6 | use std::sync::{Arc, Mutex}; |
@@ -1277,7 +1277,32 @@ pub fn cbuild( |
1277 | 1277 | from_build_targets.debug_info.as_ref(), |
1278 | 1278 | build_targets.debug_info.as_ref(), |
1279 | 1279 | ) { |
1280 | | - copy(from_debug_info, to_debug_info)?; |
| 1280 | + if from_debug_info.exists() { |
| 1281 | + create_dir_all(to_debug_info.parent().unwrap())?; |
| 1282 | + if from_debug_info.is_dir() { |
| 1283 | + let files = from_debug_info.read_dir()?.collect::<Result<Vec<_>, _>>()?; |
| 1284 | + for f in files.iter() { |
| 1285 | + let src = f.path(); |
| 1286 | + let file_name = src.strip_prefix(from_debug_info)?; |
| 1287 | + let dst = to_debug_info.join(file_name); |
| 1288 | + match std::fs::create_dir_all( |
| 1289 | + dst.parent().expect("Source path is not complete"), |
| 1290 | + ) { |
| 1291 | + Ok(()) => Ok(()), |
| 1292 | + Err(v) => { |
| 1293 | + if v.kind() == ErrorKind::AlreadyExists { |
| 1294 | + Ok(()) |
| 1295 | + } else { |
| 1296 | + Err(v) |
| 1297 | + } |
| 1298 | + } |
| 1299 | + }?; |
| 1300 | + copy(src, dst)?; |
| 1301 | + } |
| 1302 | + } else { |
| 1303 | + copy(from_debug_info, to_debug_info)?; |
| 1304 | + } |
| 1305 | + } |
1281 | 1306 | } |
1282 | 1307 | } |
1283 | 1308 |
|
|
0 commit comments