ferd tomale
ferd tomale

Reputation: 903

How do I configure cargo to build projects to a specific directory?

I am creating an application that will allow plugins to add/modify features. For now it is cli application with multiple plugins for the data backends. Each plugin is implemented as a different project in a cargo workspace. How do I configure cargo or the package manifest to build the library project into a subdirectory where the output directory of the build is found?

Upvotes: 4

Views: 2591

Answers (2)

subbu963
subbu963

Reputation: 21

A small correction to @Fabian's answer, we need to add the following config to .cargo/config.toml folder in your rust project's folder or in your home folder.

[build]
target-dir = "/some/directory/rust-builds"

You can also add other configuration which are mentioned here - https://doc.rust-lang.org/cargo/reference/config.html

Upvotes: 2

Fabián Montero
Fabián Montero

Reputation: 1794

Add the following to your Cargo.toml:

[build]
target-dir = "/desired/path" # path of where to place all generated artifacts

Source: https://doc.rust-lang.org/cargo/reference/config.html

Also read: https://doc.rust-lang.org/cargo/commands/cargo-build.html#output-options

Upvotes: 1

Related Questions