Skip to content

Commit

Permalink
feat: add optional dep-kind parameter (#102)
Browse files Browse the repository at this point in the history
* feat: add optional dep-kind parameter

allows filtering dev or build dependencies

* fix: ensure tests are working after update

note that once_cell becomes a normal dependency
because it is required by a tempfile v3.13.0

* refactor: include review comments and docs

* Update src/dep_kinds_filtering.rs

Co-authored-by: Colin Walters <[email protected]>

* docs: correct parameter names to kebab-case

---------

Co-authored-by: Colin Walters <[email protected]>
  • Loading branch information
piotr-sk and cgwalters authored Oct 19, 2024
1 parent 5fec445 commit bf3bf5c
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 13 deletions.
198 changes: 194 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ vendored-openssl = ["openssl/vendored"]

[dev-dependencies]
once_cell = "1.17.1"
serial_test = "3.1.1"
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ However, it doesn't offer any filtering; today cargo includes
all platforms, but some projects only care about Linux
for example.

More information: https://github.com/rust-lang/cargo/issues/7058
More information: <https://github.com/rust-lang/cargo/issues/7058>

Additionally some projects are not interested by vendoring test code
or development dependencies of used crates and these filters
are also not supported with no development planned yet.

More information: <https://github.com/rust-lang/cargo/issues/13474>
or <https://github.com/rust-lang/cargo/issues/7065>

## Generating a vendor/ directory with filtering

Expand All @@ -26,13 +33,15 @@ $ cargo vendor-filterer --tier=2
Currently this will drop out crates such as `redox_syscall`.

You can also declaratively specify the desired vendor configuration via the [Cargo metadata](https://doc.rust-lang.org/cargo/reference/manifest.html#the-metadata-table)
key `package.metadata.vendor-filter`. In this example, we include only tier 1 and 2 Linux platforms, and additionally remove some vendored C sources and `tests` folders from all crates:
key `package.metadata.vendor-filter`. In this example, we include only tier 1 and 2 Linux platforms, and additionally remove some vendored C sources, `tests` folders
and development dependencies from all crates:

```toml
[package.metadata.vendor-filter]
platforms = ["*-unknown-linux-gnu"]
tier = "2"
all-features = true
keep-dep-kinds = "no-dev"
exclude-crate-paths = [ { name = "curl-sys", exclude = "curl" },
{ name = "libz-sys", exclude = "src/zlib" },
{ name = "libz-sys", exclude = "src/smoke.c" },
Expand All @@ -51,6 +60,8 @@ key `workspace.metadata.vendor-filter`.
and `*` wildcards are supported. For example, `*-unknown-linux-gnu`.
- `tier`: This can be either "1" or "2". It may be specified in addition to `platforms`.
- `all-features`: Enable all features of the current crate when vendoring.
- `keep-dep-kinds`: Specify which dependencies kinds to keep.
Can be one of: all, normal, build, dev, no-normal, no-build, no-dev
- `exclude-crate-paths`: Remove files and directories from target crates. A key
use case for this is removing the vendored copy of C libraries embedded in
crates like `libz-sys`, when you only want to support dynamically linking.
Expand Down
Loading

0 comments on commit bf3bf5c

Please sign in to comment.