Skip to content

Commit 39ce7c1

Browse files
committed
Add bin/cdylib/staticlib suffix for artifact deps
1 parent a702f90 commit 39ce7c1

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/cargo/core/package.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use serde::Serialize;
1919
use tracing::debug;
2020

2121
use crate::core::compiler::{CompileKind, RustcTargetData};
22-
use crate::core::dependency::DepKind;
22+
use crate::core::dependency::{ArtifactKind, DepKind};
2323
use crate::core::resolver::features::ForceAllTargets;
2424
use crate::core::resolver::{HasDevUnits, Resolve};
2525
use crate::core::{
@@ -167,6 +167,14 @@ impl Package {
167167
pub fn proc_macro(&self) -> bool {
168168
self.targets().iter().any(|target| target.proc_macro())
169169
}
170+
// TODO fix this. For now, just wanted it to return a plausible value. Must figure out why .kinds() returns a Vec.
171+
/// Gets crate-type in { .., artifact = <crate-type> } of this package
172+
pub fn artifact_kind(&self) -> Option<&ArtifactKind> {
173+
let found = self.dependencies().iter().find_map(|dep| dep.artifact());
174+
175+
// TODO for now just returns the first ArtifactKind in the Vec<ArtifactKind>
176+
found?.kinds().iter().next()
177+
}
170178
/// Gets the package's minimum Rust version.
171179
pub fn rust_version(&self) -> Option<&RustVersion> {
172180
self.manifest().rust_version()

src/cargo/ops/tree/format/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,21 @@ impl<'a> fmt::Display for Display<'a> {
7575
} else {
7676
""
7777
};
78+
// TODO this is probably NOT the right way to get the ArtifactKind
79+
//
80+
let artifact_suffix =
81+
if let Some(artifact_kind) = package.artifact_kind() {
82+
format!(" ({})", artifact_kind.crate_type())
83+
} else {
84+
"".to_string()
85+
};
7886
write!(
7987
fmt,
80-
"{} v{}{}",
88+
"{} v{}{}{}",
8189
package.name(),
8290
package.version(),
83-
proc_macro_suffix
91+
proc_macro_suffix,
92+
artifact_suffix,
8493
)?;
8594

8695
let source_id = package.package_id().source_id();

tests/testsuite/artifact_dep.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ fn dependencies_of_dependencies_work_in_artifacts() {
15211521
.with_stdout_data(str![[r#"
15221522
foo v0.0.0 ([ROOT]/foo)
15231523
[build-dependencies]
1524-
└── bar v0.5.0 ([ROOT]/foo/bar)
1524+
└── bar v0.5.0 (bin) ([ROOT]/foo/bar)
15251525
└── baz v1.0.0
15261526
15271527
"#]])
@@ -1572,13 +1572,16 @@ fn artifact_dep_target_specified() {
15721572
.masquerade_as_nightly_cargo(&["bindeps"])
15731573
.with_stdout_data(str![[r#"
15741574
foo v0.0.0 ([ROOT]/foo)
1575-
└── bindep v0.0.0 ([ROOT]/foo/bindep)
1575+
└── bindep v0.0.0 (bin) ([ROOT]/foo/bindep)
15761576
15771577
"#]])
15781578
.with_status(0)
15791579
.run();
15801580
}
15811581

1582+
// TODO
1583+
// fn tree_suffix_bin_cdlib_staticlib() {}
1584+
15821585
/// From issue #10061
15831586
/// The case where:
15841587
/// * artifact dep is { target = <specified> }

0 commit comments

Comments
 (0)