Skip to content

Commit 1c467c0

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

2 files changed

Lines changed: 29 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: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::ArgMatches;
2+
use std::io::{Error, ErrorKind};
23
use std::path::{Component, Path, PathBuf};
34

45
use cargo::core::Workspace;
@@ -298,7 +299,31 @@ 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(
309+
dst.parent().expect("Source path is not complete"),
310+
) {
311+
Ok(()) => Ok(()),
312+
Err(v) => {
313+
if v.kind() == ErrorKind::AlreadyExists {
314+
Ok(())
315+
} else {
316+
Err(v)
317+
}
318+
}
319+
}?;
320+
copy(ws, src, dst)?;
321+
}
322+
} else if debug_info.is_file() {
323+
copy(ws, debug_info, destination_path)?;
324+
} else {
325+
return Err(Error::from(ErrorKind::InvalidInput).into());
326+
}
302327
} else {
303328
ws.gctx()
304329
.shell()

0 commit comments

Comments
 (0)