Skip to content

Commit 9c5ae9c

Browse files
committed
release: 0.6.7
2 parents da12f9b + 64136b6 commit 9c5ae9c

File tree

7 files changed

+229
-180
lines changed

7 files changed

+229
-180
lines changed

CREDITS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Project Dependencies
22
Package: cargo-bashman
3-
Version: 0.6.6
3+
Version: 0.6.7
44
Target: x86_64-unknown-linux-gnu
5-
Generated: 2024-11-08 19:20:06 UTC
5+
Generated: 2024-11-11 20:33:44 UTC
66

77
| Package | Version | Author(s) | License |
88
| ---- | ---- | ---- | ---- |
9-
| [**adbyss_psl**](https://github.com/Blobfolio/adbyss) | 0.14.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
9+
| [**adbyss_psl**](https://github.com/Blobfolio/adbyss) | 0.15.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1010
| [**argyle**](https://github.com/Blobfolio/argyle) | 0.10.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
1111
| [bitflags](https://github.com/bitflags/bitflags) | 2.6.0 | The Rust Project Developers | MIT OR Apache-2.0 |
1212
| [cc](https://github.com/rust-lang/cc-rs) ⚒️ | 1.1.37 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 |
@@ -15,7 +15,7 @@
1515
| [displaydoc](https://github.com/yaahc/displaydoc) | 0.2.5 | [Jane Lusby](mailto:jlusby@yaah.dev) | MIT OR Apache-2.0 |
1616
| [fastrand](https://github.com/smol-rs/fastrand) | 2.2.0 | [Stjepan Glavina](mailto:stjepang@gmail.com) | Apache-2.0 OR MIT |
1717
| [form_urlencoded](https://github.com/servo/rust-url) | 1.2.1 | The rust-url developers | MIT OR Apache-2.0 |
18-
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 1.1.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
18+
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 1.2.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1919
| [icu_collections](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
2020
| [icu_locid](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
2121
| [icu_locid_transform](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
@@ -39,13 +39,13 @@
3939
| [percent-encoding](https://github.com/servo/rust-url/) | 2.3.1 | The rust-url developers | MIT OR Apache-2.0 |
4040
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.89 | [David Tolnay](mailto:dtolnay@gmail.com) and [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 |
4141
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
42-
| [rustix](https://github.com/bytecodealliance/rustix) | 0.38.39 | [Dan Gohman](mailto:dev@sunfishcode.online) and [Jakub Konka](mailto:kubkon@jakubkonka.com) | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT |
42+
| [rustix](https://github.com/bytecodealliance/rustix) | 0.38.40 | [Dan Gohman](mailto:dev@sunfishcode.online) and [Jakub Konka](mailto:kubkon@jakubkonka.com) | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT |
4343
| [ryu](https://github.com/dtolnay/ryu) | 1.0.18 | [David Tolnay](mailto:dtolnay@gmail.com) | Apache-2.0 OR BSL-1.0 |
4444
| [**semver**](https://github.com/dtolnay/semver) | 1.0.23 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
4545
| [**serde**](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
4646
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
4747
| [**serde_json**](https://github.com/serde-rs/json) | 1.0.132 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
48-
| [shlex](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 |
48+
| [shlex](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 |
4949
| [smallvec](https://github.com/servo/rust-smallvec) | 1.13.2 | The Servo Project Developers | MIT OR Apache-2.0 |
5050
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:n210241048576@gmail.com) | MIT OR Apache-2.0 |
5151
| [syn](https://github.com/dtolnay/syn) | 2.0.87 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-bashman"
3-
version = "0.6.6"
3+
version = "0.6.7"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2021"
@@ -71,9 +71,9 @@ argyle = "0.10.*"
7171

7272
[dependencies]
7373
argyle = "0.10.*"
74-
adbyss_psl = "0.14.*"
74+
adbyss_psl = "0.15.*"
7575
dactyl = "0.7.4"
76-
fyi_msg = "1.1.*"
76+
fyi_msg = "1.2.*"
7777
oxford_join = "0.4.*"
7878
trimothy = "0.3.*"
7979
utc2k = "0.11.*"

release/man/cargo-bashman.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.TH "CARGO BASHMAN" "1" "November 2024" "cargo\-bashman v0.6.6" "User Commands"
1+
.TH "CARGO BASHMAN" "1" "November 2024" "cargo\-bashman v0.6.7" "User Commands"
22
.SH NAME
3-
CARGO BASHMAN \- Manual page for cargo\-bashman v0.6.6.
3+
CARGO BASHMAN \- Manual page for cargo\-bashman v0.6.7.
44
.SH DESCRIPTION
55
A Cargo plugin to generate bash completions, man pages, and/or crate credits.
66
.SS USAGE:

skel/metadata.credits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
| [**serde**](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
4848
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
4949
| [**serde_json**](https://github.com/serde-rs/json) | 1.0.132 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
50-
| [shlex](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 |
50+
| [shlex](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp&#43;git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 |
5151
| [smallvec](https://github.com/servo/rust-smallvec) | 1.13.2 | The Servo Project Developers | MIT OR Apache-2.0 |
5252
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:n210241048576@gmail.com) | MIT OR Apache-2.0 |
5353
| [syn](https://github.com/dtolnay/syn) | 2.0.87 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |

src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,14 @@ fn _main() -> Result<(), BashManError> {
260260

261261
// Print the skipped.
262262
if skipped != 0 {
263-
Msg::custom("Skipped", 11, &format!(
263+
Msg::skipped(format!(
264264
"{}; no corresponding bashman manifest sections found.",
265265
match skipped {
266266
SKIPPED_BASH => "Bash completions",
267267
SKIPPED_MAN => "Man page(s)",
268268
_ => "Bash completions and man page(s)",
269269
}
270-
))
271-
.with_newline(true)
272-
.eprint();
270+
)).eprint();
273271
}
274272

275273
#[expect(clippy::option_if_let_else, reason = "Too messy.")]

src/parse/cargo.rs

Lines changed: 111 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ pub(super) fn fetch(src: &Path, target: Option<TargetTriple>)
5959

6060
// Query without features first.
6161
let raw1 = cargo.exec()?;
62-
let Raw { packages, mut resolve } = serde_json::from_slice(&raw1)
63-
.map_err(|e| BashManError::ParseCargoMetadata(e.to_string()))?;
64-
65-
// Clean up unused nodes.
66-
prune_resolve(&mut resolve, cargo.exec_tree(&packages).unwrap_or_default());
62+
let (packages, resolve) = serde_json::from_slice::<Raw>(&raw1)
63+
.map_err(|e| BashManError::ParseCargoMetadata(e.to_string()))?
64+
.finalize(Some(cargo));
6765

6866
// Build the dependency list (and find the main package).
6967
let flags = resolve.flags(target.is_some());
@@ -93,10 +91,7 @@ pub(super) fn fetch(src: &Path, target: Option<TargetTriple>)
9391
if features {
9492
cargo = cargo.with_features(true);
9593
if let Ok(raw2) = cargo.exec() {
96-
if let Ok(Raw { packages, mut resolve }) = serde_json::from_slice(&raw2) {
97-
// Clean up unused nodes.
98-
prune_resolve(&mut resolve, cargo.exec_tree(&packages).unwrap_or_default());
99-
94+
if let Ok((packages, resolve)) = serde_json::from_slice::<Raw>(&raw2).map(|r| r.finalize(Some(cargo))) {
10095
// Build the dependency list (and find the main package).
10196
let flags = resolve.flags(target.is_some());
10297
for p in packages {
@@ -127,9 +122,9 @@ pub(super) fn fetch_test(target: Option<TargetTriple>)
127122
// Parse the static data.
128123
let raw1 = std::fs::read("skel/metadata.json")
129124
.map_err(|_| BashManError::Read("skel/metadata.json".to_owned()))?;
130-
let Raw { packages, mut resolve } = serde_json::from_slice(&raw1)
131-
.map_err(|e| BashManError::ParseCargoMetadata(e.to_string()))?;
132-
prune_resolve(&mut resolve, HashSet::new());
125+
let (packages, resolve) = serde_json::from_slice::<Raw>(&raw1)
126+
.map_err(|e| BashManError::ParseCargoMetadata(e.to_string()))?
127+
.finalize(None);
133128

134129
// Build the dependency list (and find the main package).
135130
let flags = resolve.flags(target.is_some());
@@ -302,11 +297,115 @@ struct Raw<'a> {
302297
/// # Packages.
303298
packages: Vec<RawPackage<'a>>,
304299

300+
#[serde(borrow)]
301+
/// # Workspace Members.
302+
workspace_members: HashSet<&'a str>,
303+
305304
#[serde(borrow)]
306305
/// # Resolved Nodes.
307306
resolve: RawResolve<'a>,
308307
}
309308

309+
impl<'a> Raw<'a> {
310+
/// # Finalize!
311+
///
312+
/// This takes care of a few big-picture tasks post-deserialization and
313+
/// returns the packages and node lists.
314+
fn finalize(self, cargo: Option<CargoMetadata<'_>>)
315+
-> (Vec<RawPackage<'a>>, RawResolve<'a>) {
316+
let Self { packages, workspace_members, mut resolve } = self;
317+
let mut used = cargo.and_then(|c| c.exec_tree(&packages))
318+
.unwrap_or_default();
319+
320+
// If cargo tree couldn't help us figure out which dependencies are
321+
// actually used, let's take a guess by traversing the root
322+
// dependencies, then each of their dependencies, and so on.
323+
let mut queue = Vec::new();
324+
if used.is_empty() || ! used.contains(resolve.root) {
325+
used.clear();
326+
queue.push(resolve.root);
327+
while let Some(next) = queue.pop() {
328+
// Only enqueue a given package's dependencies once to avoid infinite
329+
// loops.
330+
if used.insert(next) {
331+
// Add its children, if any.
332+
if let Some(next) = resolve.nodes.get(next) {
333+
queue.extend(next.iter().map(|nd| nd.id));
334+
}
335+
}
336+
}
337+
}
338+
339+
// Remove unused node chains and dependencies.
340+
resolve.nodes.retain(|k, _| used.contains(k));
341+
for v in resolve.nodes.values_mut() {
342+
v.retain(|nd| used.contains(nd.id));
343+
}
344+
345+
// Now let's traverse what remains to find the "normal" dependencies so
346+
// we can recurisvely propagate build flags to build-only
347+
// sub-dependencies.
348+
used.clear();
349+
queue.push(resolve.root);
350+
while let Some(next) = queue.pop() {
351+
if used.insert(next) {
352+
// Add its children, if any.
353+
if let Some(next) = resolve.nodes.get(next) {
354+
for nd in next {
355+
if Dependency::FLAG_CTX_NORMAL == nd.dep_kinds & Dependency::FLAG_CTX_NORMAL {
356+
queue.push(nd.id);
357+
}
358+
}
359+
}
360+
}
361+
}
362+
for (k, v) in &mut resolve.nodes {
363+
if ! used.contains(k) {
364+
for nd in v {
365+
nd.dep_kinds = (nd.dep_kinds & ! Dependency::MASK_CTX) | Dependency::FLAG_CTX_BUILD;
366+
}
367+
}
368+
}
369+
370+
// Same as above, but this time we're looking for untargeted
371+
// dependencies so we can propagate conditionality where appropriate.
372+
used.clear();
373+
queue.push(resolve.root);
374+
while let Some(next) = queue.pop() {
375+
if used.insert(next) {
376+
// Add its children, if any.
377+
if let Some(next) = resolve.nodes.get(next) {
378+
for nd in next {
379+
if Dependency::FLAG_TARGET_ANY == nd.dep_kinds & Dependency::FLAG_TARGET_ANY {
380+
queue.push(nd.id);
381+
}
382+
}
383+
}
384+
}
385+
}
386+
for (k, v) in &mut resolve.nodes {
387+
if ! used.contains(k) {
388+
for nd in v {
389+
nd.dep_kinds = (nd.dep_kinds & ! Dependency::MASK_TARGET) | Dependency::FLAG_TARGET_CFG;
390+
}
391+
}
392+
}
393+
394+
// Lastly, mark all direct dependencies of workspace members as being
395+
// directly required.
396+
for id in workspace_members {
397+
if let Some(v) = resolve.nodes.get_mut(id) {
398+
for nd in v {
399+
nd.dep_kinds |= Dependency::FLAG_DIRECT;
400+
}
401+
}
402+
}
403+
404+
// Done!
405+
(packages, resolve)
406+
}
407+
}
408+
310409

311410

312411
#[derive(Debug, Deserialize)]
@@ -1086,94 +1185,6 @@ where D: Deserializer<'de> {
10861185
Ok(out)
10871186
}
10881187

1089-
/// # Prune Resolve.
1090-
///
1091-
/// Remove dependencies that aren't being used, and clean up build/cfg flags
1092-
/// for sub-dependencies.
1093-
fn prune_resolve<'a>(resolve: &'a mut RawResolve, mut used: HashSet<&'a str>) {
1094-
let mut queue = Vec::new();
1095-
1096-
// If cargo tree couldn't help us, build up the "used" dependencies
1097-
// manually.
1098-
if used.is_empty() || ! used.contains(resolve.root) {
1099-
used.clear();
1100-
queue.push(resolve.root);
1101-
while let Some(next) = queue.pop() {
1102-
// Only enqueue a given package's dependencies once to avoid infinite
1103-
// loops.
1104-
if used.insert(next) {
1105-
// Add its children, if any.
1106-
if let Some(next) = resolve.nodes.get(next) {
1107-
queue.extend(next.iter().map(|nd| nd.id));
1108-
}
1109-
}
1110-
}
1111-
}
1112-
1113-
// And with that, let's remove all unused node chains entirely.
1114-
resolve.nodes.retain(|k, _| used.contains(k));
1115-
for v in resolve.nodes.values_mut() {
1116-
v.retain(|nd| used.contains(nd.id));
1117-
}
1118-
1119-
// Now let's do something similar, this time building up a list of "normal"
1120-
// runtime dependencies. We'll use this to mark the direct children of any
1121-
// non-normal node parents as build-only.
1122-
used.clear();
1123-
queue.push(resolve.root);
1124-
while let Some(next) = queue.pop() {
1125-
if used.insert(next) {
1126-
// Add its children, if any.
1127-
if let Some(next) = resolve.nodes.get(next) {
1128-
for nd in next {
1129-
if Dependency::FLAG_CTX_NORMAL == nd.dep_kinds & Dependency::FLAG_CTX_NORMAL {
1130-
queue.push(nd.id);
1131-
}
1132-
}
1133-
}
1134-
}
1135-
}
1136-
for (k, v) in &mut resolve.nodes {
1137-
if ! used.contains(k) {
1138-
for nd in v {
1139-
nd.dep_kinds = (nd.dep_kinds & ! Dependency::MASK_CTX) | Dependency::FLAG_CTX_BUILD;
1140-
}
1141-
}
1142-
}
1143-
1144-
// One more time around! Here, we're looking for "any" targets so that we
1145-
// can mark the direct children of non-any targets as being
1146-
// target-specific.
1147-
used.clear();
1148-
queue.push(resolve.root);
1149-
while let Some(next) = queue.pop() {
1150-
if used.insert(next) {
1151-
// Add its children, if any.
1152-
if let Some(next) = resolve.nodes.get(next) {
1153-
for nd in next {
1154-
if Dependency::FLAG_TARGET_ANY == nd.dep_kinds & Dependency::FLAG_TARGET_ANY {
1155-
queue.push(nd.id);
1156-
}
1157-
}
1158-
}
1159-
}
1160-
}
1161-
for (k, v) in &mut resolve.nodes {
1162-
if ! used.contains(k) {
1163-
for nd in v {
1164-
nd.dep_kinds = (nd.dep_kinds & ! Dependency::MASK_TARGET) | Dependency::FLAG_TARGET_CFG;
1165-
}
1166-
}
1167-
}
1168-
1169-
// Lastly, let's mark direct dependencies.
1170-
if let Some(v) = resolve.nodes.get_mut(resolve.root) {
1171-
for nd in v {
1172-
nd.dep_kinds |= Dependency::FLAG_DIRECT;
1173-
}
1174-
}
1175-
}
1176-
11771188

11781189

11791190
#[cfg(test)]

0 commit comments

Comments
 (0)