Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 8938495

Browse files
committed
Update Cargo to latest 0.48 version
Adapt to changes made in rust-lang/cargo#8236 by redirecting output through Cargo's `Shell` type rather than stdio.
1 parent 4673112 commit 8938495

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license-file = "LICENSE"
1111
edition = "2018"
1212

1313
[dependencies]
14-
cargo = "0.45"
14+
cargo = "0.48"
1515
crates-io = "0.32"
1616
curl = "0.4.21"
1717
env_logger = "0.7"

src/bin/cargo-semver.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,15 @@ impl<'a> WorkInfo<'a> {
481481
// we need the build plan to find our build artifacts
482482
opts.build_config.build_plan = true;
483483

484-
if let Some(target) = matches.opt_str("target") {
485-
let target = cargo::core::compiler::CompileTarget::new(&target);
486-
if let Ok(target) = target {
487-
let kind = cargo::core::compiler::CompileKind::Target(target);
488-
opts.build_config.requested_kind = kind;
489-
}
490-
}
484+
let compile_kind = if let Some(target) = matches.opt_str("target") {
485+
let target = cargo::core::compiler::CompileTarget::new(&target)?;
486+
487+
let kind = cargo::core::compiler::CompileKind::Target(target);
488+
opts.build_config.requested_kinds = vec![kind];
489+
kind
490+
} else {
491+
cargo::core::compiler::CompileKind::Host
492+
};
491493

492494
if let Some(s) = matches.opt_str("features") {
493495
opts.features = s.split(' ').map(str::to_owned).collect();
@@ -512,11 +514,14 @@ impl<'a> WorkInfo<'a> {
512514

513515
// redirection gang
514516
let outfile = File::create(&outdir)?;
515-
let old_stdio = std::io::set_print(Some(Box::new(outfile)));
516517

517-
let _ = cargo::ops::compile(&self.workspace, &opts)?;
518+
let mut file_write = cargo::core::Shell::from_write(Box::new(outfile));
519+
file_write.set_verbosity(cargo::core::Verbosity::Quiet);
520+
let old_shell = std::mem::replace(&mut *config.shell(), file_write);
518521

519-
std::io::set_print(old_stdio);
522+
cargo::ops::compile(&self.workspace, &opts)?;
523+
524+
let _ = std::mem::replace(&mut *config.shell(), old_shell);
520525

521526
// actually compile things now
522527
opts.build_config.build_plan = false;
@@ -530,7 +535,9 @@ impl<'a> WorkInfo<'a> {
530535
for i in &build_plan.invocations {
531536
if let Some(kind) = i.target_kind.get(0) {
532537
if kind.contains("lib") && i.package_name == name {
533-
return Ok((i.outputs[0].clone(), compilation.deps_output));
538+
let deps_output = &compilation.deps_output[&compile_kind];
539+
540+
return Ok((i.outputs[0].clone(), deps_output.clone()));
534541
}
535542
}
536543
}

0 commit comments

Comments
 (0)