Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::io::Read;
use std::io::{ErrorKind, Read};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -1277,7 +1277,33 @@ pub fn cbuild(
from_build_targets.debug_info.as_ref(),
build_targets.debug_info.as_ref(),
) {
copy(from_debug_info, to_debug_info)?;
if from_debug_info.exists() {
create_dir_all(to_debug_info.parent().unwrap())?;
if from_debug_info.is_dir() {
let files =
from_debug_info.read_dir()?.collect::<Result<Vec<_>, _>>()?;
for f in files.iter() {
let src = f.path();
let file_name = src.strip_prefix(from_debug_info)?;
let dst = to_debug_info.join(file_name);
match std::fs::create_dir_all(
dst.parent().expect("Source path is not complete"),
) {
Ok(()) => Ok(()),
Err(v) => {
if v.kind() == ErrorKind::AlreadyExists {
Ok(())
} else {
Err(v)
}
}
}?;
copy(src, dst)?;
}
} else {
copy(from_debug_info, to_debug_info)?;
}
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/build_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ impl FileNames {
"macos" | "ios" | "tvos" | "visionos" => {
let static_lib = targetdir.join(format!("lib{lib_name}.a"));
let shared_lib = targetdir.join(format!("lib{lib_name}.dylib"));
(shared_lib, static_lib, None, None, None)
let pdb = Some(targetdir.join(format!("lib{lib_name}.dSYM")));
(shared_lib, static_lib, None, pdb, None)
}
"windows" => {
let shared_lib = targetdir.join(format!("{lib_name}.dll"));
Expand All @@ -194,9 +195,8 @@ impl FileNames {
} else {
targetdir.join(format!("{lib_name}.dll.a"))
};
let pdb = None;

(shared_lib, static_lib, Some(impl_lib), pdb, Some(def))
(shared_lib, static_lib, Some(impl_lib), None, Some(def))
}
}
_ => return None,
Expand Down Expand Up @@ -269,7 +269,7 @@ mod test {
static_lib: PathBuf::from("/foo/bar/libferris.a"),
shared_lib: PathBuf::from("/foo/bar/libferris.dylib"),
impl_lib: None,
debug_info: None,
debug_info: Some(PathBuf::from("/foo/bar/libferris.dSYM")),
def: None,
};

Expand Down
39 changes: 35 additions & 4 deletions src/install.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::ArgMatches;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};

use cargo::core::Workspace;
Expand Down Expand Up @@ -285,12 +286,42 @@ pub fn cinstall(ws: &Workspace, packages: &[CPackage]) -> anyhow::Result<()> {
ws.gctx()
.shell()
.status("Installing", "debugging information")?;
let destination_path = build_targets
.debug_info_file_name(&install_path_bin, &install_path_lib)
.unwrap();

Comment thread
amyspark marked this conversation as resolved.
let destination_path = if capi_config.library.install_subdir.is_none() {
build_targets
.debug_info_file_name(&install_path_bin, &install_path_lib)
.unwrap()
} else {
// We assume they are plugins, install them in the custom libdir path
build_targets
.debug_info_file_name(&install_path_lib, &install_path_lib)
.unwrap()
};

create_dir_all(destination_path.parent().unwrap())?;
copy(ws, debug_info, destination_path)?;
if debug_info.is_dir() {
let files = debug_info.read_dir()?.collect::<Result<Vec<_>, _>>()?;
for f in files.iter() {
let src = f.path();
let file_name = src.strip_prefix(debug_info)?;
let dst = destination_path.join(file_name);
match std::fs::create_dir_all(
dst.parent().expect("Source path is not complete"),
) {
Ok(()) => Ok(()),
Err(v) => {
if v.kind() == ErrorKind::AlreadyExists {
Ok(())
} else {
Err(v)
}
}
}?;
copy(ws, src, dst)?;
}
} else {
copy(ws, debug_info, destination_path)?;
}
} else {
ws.gctx()
.shell()
Expand Down
Loading