Skip to content

Commit 37219ae

Browse files
committed
Implement installing dSYMs if available
1 parent c6ab69e commit 37219ae

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/build_targets.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ impl FileNames {
171171
"macos" | "ios" | "tvos" | "visionos" => {
172172
let static_lib = targetdir.join(format!("lib{lib_name}.a"));
173173
let shared_lib = targetdir.join(format!("lib{lib_name}.dylib"));
174-
(shared_lib, static_lib, None, None, None)
174+
let pdb = Some(targetdir.join(format!("{lib_name}.dSYM")));
175+
(shared_lib, static_lib, None, pdb, None)
175176
}
176177
"windows" => {
177178
let shared_lib = targetdir.join(format!("{lib_name}.dll"));
@@ -194,9 +195,8 @@ impl FileNames {
194195
} else {
195196
targetdir.join(format!("{lib_name}.dll.a"))
196197
};
197-
let pdb = None;
198198

199-
(shared_lib, static_lib, Some(impl_lib), pdb, Some(def))
199+
(shared_lib, static_lib, Some(impl_lib), None, Some(def))
200200
}
201201
}
202202
_ => return None,

src/install.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::ArgMatches;
2+
use std::io::{ErrorKind, Error};
23
use std::path::{Component, Path, PathBuf};
34

45
use cargo::core::Workspace;
@@ -298,7 +299,29 @@ pub fn cinstall(ws: &Workspace, packages: &[CPackage]) -> anyhow::Result<()> {
298299
};
299300

300301
create_dir_all(destination_path.parent().unwrap())?;
301-
copy(ws, debug_info, destination_path)?;
302+
if debug_info.is_dir() {
303+
let files = debug_info.read_dir()?.collect::<Result<Vec<_>, _>>()?;
304+
for f in files.iter() {
305+
let src = f.path();
306+
let file_name = src.strip_prefix(debug_info)?;
307+
let dst = destination_path.join(file_name);
308+
match std::fs::create_dir_all(dst.parent().expect("Source path is not complete")) {
309+
Ok(()) => Ok(()),
310+
Err(v) => {
311+
if v.kind() == ErrorKind::AlreadyExists {
312+
Ok(())
313+
} else {
314+
Err(v)
315+
}
316+
},
317+
}?;
318+
copy(ws, src, dst)?;
319+
}
320+
} else if debug_info.is_file() {
321+
copy(ws, debug_info, destination_path)?;
322+
} else {
323+
return Err(Error::from(ErrorKind::InvalidInput).into());
324+
}
302325
} else {
303326
ws.gctx()
304327
.shell()

0 commit comments

Comments
 (0)