bin+lib cargo-add-dynamic

Cargo-add command to make dependencies into dylibs

3 releases

0.1.2 Oct 2, 2022
0.1.1 Sep 10, 2022
0.1.0 Sep 9, 2022

#281 in Cargo plugins

21 downloads per month

MIT license

452 lines

cargo add-dynamic


This cargo command allows to wrap dependencies as dylibs.

For why you might want this see Speeding up incremental Rust compilation with dylibs.


cargo install cargo-add-dynamic


To add a new dependency as a dylib to the current project run for example

cargo add-dynamic polars --features csv-file,lazy,list,describe,rows,fmt,strings,temporal

This will create a sub-package polars-dynamic with the following content.


name = "polars-dynamic"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

polars = { version = "0.23.2", features = ["csv-file", "lazy", "list", "describe", "rows", "fmt", "strings", "temporal"] }

crate-type = ["dylib"]


pub use polars::*;

And it will add polars = { version = "0.1.0", path = "polars-dynamic", package = "polars-dynamic" } to the dependencies of the current package.


Cargo command similar to `cargo add` that will add a dependency <DEP> as a dynamic library (dylib)
crate by creating a new sub-package whose only dependency is the specified <DEP> and whose
crate-type is ["dylib"].

    cargo-add-dynamic [OPTIONS] <DEP>


    -F, --features <FEATURES>...    Space or comma separated list of features to activate
    -h, --help                      Print help information
        --lib-dir <DIR>             Directory for the new sub-package. Defaults to <DEP>-dynamic
    -n, --name <NAME>               Name of the dynamic library, defaults to <DEP>-dynamic
        --no-default-features       Disable the default features
        --offline                   Run without accessing the network
        --optional                  Mark the dependency as optional. The package name will be
                                    exposed as feature of your crate.
    -p, --package <SPEC>            Package to modify
        --path <PATH>               Filesystem path to local crate to add
        --rename <NAME>             Rename the dependency
                                    Example uses:
                                    - Depending on multiple versions of a crate
                                    - Depend on crates with the same name from different registries
    -v, --verbose                   Additional (debug) logging.


~136K SLoC