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
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct Args {
pub forwarded_args: Vec<OsString>,
/// "debug", "release" etc.
pub profile: String,
/// The target architecture. None for native builds.
pub arch: Option<String>,
/// The absolute path to the Cargo.toml file. Currently the --manifest-path option is not implemented.
pub manifest_path: PathBuf,
}
Expand Down Expand Up @@ -60,6 +62,10 @@ impl ArgsOrHelp {
String::from("debug")
};

let arch = args
.opt_value_from_str("--target")?
.or_else(|| std::env::var("CARGO_BUILD_TARGET").ok());

let build_base = args
.opt_value_from_str("--target-dir")?
.unwrap_or_else(|| "target".into());
Expand All @@ -78,6 +84,7 @@ impl ArgsOrHelp {
build_base,
forwarded_args,
profile,
arch,
manifest_path,
};

Expand Down Expand Up @@ -222,9 +229,15 @@ pub fn install_binaries(
build_base: impl AsRef<Path>,
package_name: &str,
profile: &str,
arch: Option<&str>,
binaries: &[Product],
) -> Result<()> {
let src_dir = build_base.as_ref().join(profile);
let src_dir = if let Some(arch) = arch {
build_base.as_ref().join(arch).join(profile)
} else {
build_base.as_ref().join(profile)
};

let dest_dir = install_base.as_ref().join("lib").join(package_name);
if dest_dir.is_dir() {
std::fs::remove_dir_all(&dest_dir)?;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ fn fallible_main() -> Result<bool> {
&args.build_base,
package_name,
&args.profile,
args.arch.as_deref(),
// Unwrap is safe since complete_from_path() has been called
&manifest.bin,
)?;
Expand Down
Loading