Skip to content

Commit d0ffa22

Browse files
authored
Prep release (#266)
1 parent c64807d commit d0ffa22

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
## [Unreleased] - ReleaseDate
1111
### Added
1212
- [PR#261](https://github.com/EmbarkStudios/cargo-about/pull/261) resolved [#246](https://github.com/EmbarkStudios/cargo-about/issues/246) by adding an `--offline` (as well as `--locked` and `--frozen`) option to the `generate` command.
13+
- [PR#266](https://github.com/EmbarkStudios/cargo-about/pull/266) resolved [#230](https://github.com/EmbarkStudios/cargo-about/issues/230) by adding a `--target` option to `generate`, allowing one to specify one or more targets to filter the dependency graph by, overriding the `targets` configuration option.
14+
15+
### Changed
16+
- [PR#262](https://github.com/EmbarkStudios/cargo-about/pull/262) resolved [#258](https://github.com/EmbarkStudios/cargo-about/issues/258) by using LTO for release builds, slightly decreasing binary sizes.
17+
18+
### Fixed
19+
- [PR#263](https://github.com/EmbarkStudios/cargo-about/pull/263) resolved [#238](https://github.com/EmbarkStudios/cargo-about/issues/238) by adding the `native-certs` feature to use the native certificate store. This feature is not enabled by default as it is only required for corporate environments that man in the middle network traffic.
20+
- [PR#265](https://github.com/EmbarkStudios/cargo-about/pull/265) resolved [#198](https://github.com/EmbarkStudios/cargo-about/issues/198) by detecting if the parent process is powershell and exiting with an error if cargo-about's output is being redirected instead of using the `-o` option, as powershell is terrible and doesn't use utf-8 encoding by default.
21+
- [PR#266](https://github.com/EmbarkStudios/cargo-about/pull/266) resolved [#222](https://github.com/EmbarkStudios/cargo-about/issues/222) by adding some additional documentation on <https://clearlydefined.io>.
1322

1423
## [0.6.4] - 2024-08-12
1524
### Fixed

docs/src/cli/clarify.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- markdownlint-disable no-duplicate-heading -->
2+
13
# clarify
24

35
Computes a clarification for a file

docs/src/cli/generate/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Prevents Cargo and `cargo-about` from accessing the network for any reason. With
2929

3030
Beware that this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. See the cargo-fetch(1) command to download dependencies before going offline.
3131

32-
`cargo-about` will also not query clearlydefined.io for license information, meaning that user provided clarifications won't be used, and some ambiguous/complicated license files might be missed by `cargo-about`. Additionally, clarifications that use license files from the crate's source repository will not be applied, meaning that `cargo-about` will fallback to using the default license text rather than the one in the source repository, losing eg. copyright or other unique information.
32+
`cargo-about` will also not query <https://clearlydefined.io> for license information, meaning that user provided clarifications won't be used, and some ambiguous/complicated license files might be missed by `cargo-about`. Additionally, clarifications that use license files from the crate's source repository will not be applied, meaning that `cargo-about` will fallback to using the default license text rather than the one in the source repository, losing eg. copyright or other unique information.
3333

3434
### [`--frozen`](https://doc.rust-lang.org/cargo/commands/cargo-fetch.html#option-cargo-fetch---frozen)
3535

docs/src/cli/generate/config.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,21 @@ ignore-transitive-dependencies = true
5252

5353
## The `no-clearly-defined` field (optional)
5454

55-
If true, will not attempt to lookup licensing information for any crate from <https://clearlydefined.io>, only user clarifications, workarounds, and local file scanning will be used to determine licensing information.
55+
If true, will not attempt to lookup licensing information for any crate from [clearlydefined.io], only user clarifications, workarounds, and local file scanning will be used to determine licensing information.
56+
57+
By default, `cargo-about` will use [clearlydefined.io] to augment the license information that can be gathered by scanning local files, as it has more advanced license detection (eg. it can detect multiple license in the same file unlike askalono), and can have [curations](https://docs.clearlydefined.io/docs/get-involved/data-curation) applied that benefit all users of a crate, rather than the project-specific clarifications supported by `cargo-about`.
58+
59+
[clearlydefined.io] does have some downsides however, in that it is an external source of information that can be missing or updated, which can result in different output given the same dependency graph input.
60+
61+
It will also show warnings for when the license information for a crate cannot be retrieved, the most common of which is
62+
63+
> the definition for <crate> has not been harvested
64+
65+
which indicates that the particular crate version has not been scanned and indexed by [clearlydefined.io] yet. Simply by making a request for a crate version from cargo-about, [clearlydefined.io] will automatically queue it to be harvested, but depending on load may take several hours or more before it is available.
5666

5767
## The `filter-noassertion` field (optional)
5868

59-
If using <https://clearlydefined.io> to gather license information, that service will conservatively add [`NOASSERTION`](https://docs.clearlydefined.io/curation-guidelines) to the expression for files that contain license like data, but an SPDX license ID could not be confidently ascribed to it. This can result in the license expression for the crate to contain 1 or more `NOASSERTION` identifiers, which would require the user to accept that (not really valid) ID to pass the license check. By setting this field to `true`, files that have a `NOASSERTION` id will instead be scanned locally, which will generally either figure out the license, or else skip that file.
69+
If using [clearlydefined.io] to gather license information, that service will conservatively add [`NOASSERTION`](https://docs.clearlydefined.io/curation-guidelines) to the expression for files that contain license like data, but an SPDX license ID could not be confidently ascribed to it. This can result in the license expression for the crate to contain 1 or more `NOASSERTION` identifiers, which would require the user to accept that (not really valid) ID to pass the license check. By setting this field to `true`, files that have a `NOASSERTION` id will instead be scanned locally, which will generally either figure out the license, or else skip that file.
6070

6171
For a real world example of what this looks like, [`webpki:0.22.0`](https://crates.io/crates/webpki/0.22.0)'s [LICENSE](https://clearlydefined.io/file/5b698ca13897be3afdb7174256fa1574f8c6892b8bea1a66dd6469d3fe27885a) file is an ISC license, however it has a preamble that is not part of the ISC license that trips up clearly defined's inspection, causing it to be attributed with `ISC AND NOASSERTION`. Locally scanning the file will be more tolerant and just attribute it with `ISC`.
6272

@@ -197,3 +207,5 @@ In some cases, crates concatenate multiple licenses together into a single file,
197207
##### The `end` field (optional)
198208

199209
Just as with start, this is just a simple substring find, however, it will only match text that comes _after_ the position the start text (or beginning of the file) was found.
210+
211+
[clearlydefined.io]: https://clearlydefined.io

src/cargo-about/generate.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ pub struct Args {
5252
/// Do not activate the `default` feature
5353
#[clap(long)]
5454
no_default_features: bool,
55+
/// The target triples to use for dependency graph filtering.
56+
///
57+
/// Overrides the `targets` configuration value, and note that unlike cargo
58+
/// itself this can take multiple targets instead of just one.
59+
#[clap(long)]
60+
target: Vec<String>,
5561
/// Run without accessing the network.
5662
///
5763
/// In addition to cargo not fetching crates, this will mean that only
@@ -63,13 +69,13 @@ pub struct Args {
6369
/// copyright information in the license that would be retrieved from
6470
/// the original git repo for the crate in question
6571
#[arg(long)]
66-
pub(crate) offline: bool,
72+
offline: bool,
6773
/// Assert that `Cargo.lock` will remain unchanged
6874
#[arg(long)]
69-
pub(crate) locked: bool,
75+
locked: bool,
7076
/// Equivalent to specifying both `--locked` and `--offline`
7177
#[arg(long)]
72-
pub(crate) frozen: bool,
78+
frozen: bool,
7379
/// The path of the Cargo.toml for the root crate.
7480
///
7581
/// Defaults to the current crate or workspace in the current working directory
@@ -194,6 +200,7 @@ pub fn cmd(args: Args, color: crate::Color) -> anyhow::Result<()> {
194200
offline: args.offline,
195201
},
196202
&cfg,
203+
&args.target,
197204
));
198205
});
199206
s.spawn(|_| {

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl std::ops::Deref for Krate {
9494

9595
pub type Krates = krates::Krates<Krate>;
9696

97+
#[allow(clippy::too_many_arguments)]
9798
pub fn get_all_crates(
9899
cargo_toml: &krates::Utf8Path,
99100
no_default_features: bool,
@@ -102,6 +103,7 @@ pub fn get_all_crates(
102103
workspace: bool,
103104
lock_opts: krates::LockOptions,
104105
cfg: &licenses::config::Config,
106+
target_overrdes: &[String],
105107
) -> anyhow::Result<Krates> {
106108
let mut mdc = krates::Cmd::new();
107109
mdc.manifest_path(cargo_toml);
@@ -139,7 +141,15 @@ pub fn get_all_crates(
139141
builder.ignore_kind(krates::DepKind::Build, krates::Scope::NonWorkspace);
140142
}
141143

142-
builder.include_targets(cfg.targets.iter().map(|triple| (triple.as_str(), vec![])));
144+
if target_overrdes.is_empty() {
145+
builder.include_targets(cfg.targets.iter().map(|triple| (triple.as_str(), vec![])));
146+
} else {
147+
builder.include_targets(
148+
target_overrdes
149+
.iter()
150+
.map(|triple| (triple.as_str(), vec![])),
151+
);
152+
}
143153

144154
let graph = builder.build(mdc, |filtered: cm::Package| {
145155
if let Some(src) = filtered.source {

0 commit comments

Comments
 (0)