cargo-add command to make dependencies into dylibs

Overview

cargo add-dynamic

Crates.io

This cargo command allows to wrap dependencies as dylibs.

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

Installation

cargo install cargo-add-dynamic

Example

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.

polars-dynamic/Cargo.toml

[package]
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

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

[lib]
crate-type = ["dylib"]

polars-dynamic/src/lib.rs

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.

Usage

add-dynamic 
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"].

USAGE:
    cargo-add-dynamic [OPTIONS] <DEP>

ARGS:
    <DEP>    

OPTIONS:
    -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.
You might also like...
Rust, cargo and QEMU setup for multi-architecture OS development.

rust-osdev-jumpstart Rust, cargo and QEMU setup for multi-architecture OS development. Goal This repo should give you a boost in starting a bare-metal

A cargo plugin for showing a tree-like overview of a crate's modules.

cargo-modules Synopsis A cargo plugin for showing an overview of a crate's modules. Motivation With time, as your Rust projects grow bigger and bigger

A cargo subcommand to fetch the $OUT_DIR environment variable from build scripts

cargo-outdir A cargo subcommand to fetch the $OUT_DIR variable from build scripts. This is extremely useful to inspect the output of automatically gen

probe-run is a custom Cargo runner that transparently runs Rust firmware on an embedded device

probe-run Runs embedded programs just like native ones probe-run is a custom Cargo runner that transparently runs Rust firmware on an embedded device.

An inquiry into nondogmatic software development. An experiment showing double performance of the code running on JVM comparing to equivalent native C code.
An inquiry into nondogmatic software development. An experiment showing double performance of the code running on JVM comparing to equivalent native C code.

java-2-times-faster-than-c An experiment showing double performance of the code running on JVM comparing to equivalent native C code ⚠️ The title of t

A translation of akaritakai/AdventOfCode2021 into Rust

Advent Of Code 2021 Solutions This repo contains my Advent Of Code 2021 solutions in Rust. This repo is a learning opportunity (a "my first Rust proje

A tool to deserialize data from an input encoding, transform it and serialize it back into an output encoding.

dts A simple tool to deserialize data from an input encoding, transform it and serialize it back into an output encoding. Requires rust = 1.56.0. Ins

Bitpack a boolean into a pointer using bit magic.

ptr-bool tl;dr: a pointer and boolean with the same size as a pointer. A convenience crate used to bitpack a boolean and pointer into the same eight b

Static-checked parsing of regexes into structs

Statically-checked regex parsing into structs. This avoids common regex pitfalls like Off by one capture indexes Trying to get nonexistent captures De

Comments
  • [Question] fail to build serde_json dylib

    [Question] fail to build serde_json dylib

    Thanks for this cool tool!

    I tried to build serde_json dylib with serde dylib, but failed. If I change crate-type to rlib for the serde_json-dynamic sub-package, then it works. simple project is here.

    Not sure whether rlib works like dylib here or not as expected?

    opened by huahouye 7
  • Cannot execute test.sh

    Cannot execute test.sh

    Hi,

    Nice work! I'm trying to run test.sh. I get:

    $ ./test.sh
    error: Found argument 'foo' which wasn't expected, or isn't valid in this context
    
    USAGE:
        cargo rm [OPTIONS]
    
    For more information try --help
    

    Which version of cargo-rm are you using? I've installed latest with cargo install cargo-rm.

    Seems my version doesn't take any args (see stderr) as needed here.

    opened by mihaigalos 1
  • Unable to run with nightly

    Unable to run with nightly

    I'm trying to dynamically link sysexits to my cat implementation using this, but when I run it:

    # LD_PRELOAD=target/release-helpful/libsysexits_dynamic.so target/release-helpful/cat /etc/pacman.conf
    target/release-helpful/cat: error while loading shared libraries: libstd-08c52b3d112d8849.so: cannot open shared object file: No such file or directory
    
    opened by emmatebibyte 3
Owner
Robert Krahn
Staff Software Engineer at Datadog
Robert Krahn
A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!

cabal-pack A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library! To generate bindings, you need to annotate the Rust

Yvan Sraka 18 Dec 31, 2022
Make and use playgrounds locally.

cargo playground Cargo playground opens a local playground in the editor of your choice. Install You can install it directly using cargo $ cargo insta

null 18 Jan 3, 2023
A tool to make grocery lists written in Rust

grusterylist: makes grocery lists, written in Rust grusterylist uses and can add to local libraries of user-added recipes and grocery items to put tog

null 3 Jun 17, 2022
Make a .scratch directory to keep random scribbles in

mkscratch Creates a directory named .scratch in your current working directory which will be ignored by Git. Useful for keeping around miscellaneous f

Kayla 3 Oct 21, 2022
A webring of people who make cool stuff. technology, music, art, writing, anything goes!

a webring of people who make cool stuff. technology, music, art, writing, anything goes!

Kognise 44 Dec 6, 2022
rust database for you to use and help me make!

Welcome To Rust Database! What is this? this is a database for you to git clone and use in your project! Why should i use it? It is fast and it takes

Carghai74 2 Dec 4, 2022
Make your IDs strongly typed!!

About TypedId introduces a single type, aptly named TypedId. This is a generic wrapper any type, often types that you would use as an identifier. Howe

Tyler Bloom 8 Sep 2, 2022
A collection of crates to make minecraft development (client, server) with rust possible.

rust-craft rust-craft is a collection of crates to make minecraft development (client, server) with rust possible. Motivation There's no better way of

João Victor 15 Mar 23, 2023
A typed map which can make sure item exist.

Certain Map A typed map which can make sure item exist. What Problem Does It Solve In Rust, we often use Service abstraction for modular structure des

ihc童鞋@提不起劲 27 Jun 26, 2023
Aim is to make PCBoard clone that's finished on PCboards 100th birthday

icy_board Aim is to make PCBoard clone that's finished on PCboards 100th birthday - for sure it'll take much time. I've started to port a PPL decompil

Mike Krüger 6 May 7, 2024