2022-03-02 20:01:48 +11:00
# NIH-plug: bundler and other utilities
2022-07-04 03:49:20 +10:00
This is NIH-plug's `cargo xtask` command, as a library. This way you can use it
in your own projects without having to either fork this repo or vendor the
2022-03-02 21:19:35 +11:00
binary into your own repo. This is necessary until Cargo supports [running
binaries from dependencies
directly](https://github.com/rust-lang/rfcs/pull/3168).
2022-03-02 20:01:48 +11:00
2022-07-04 03:49:20 +10:00
To use this, add an `xtask` binary to your project using `cargo new --bin xtask` . Then add that binary to the Cargo workspace in your repository's main
`Cargo.toml` file like so:
2022-03-02 20:01:48 +11:00
```toml
# Cargo.toml
[workspace]
members = ["xtask"]
```
2022-07-04 03:49:20 +10:00
Add `nih_plug_xtask` to the new xtask package's dependencies, and call its main
function from the new xtask binary:
2022-03-02 20:01:48 +11:00
```toml
# xtask/Cargo.toml
[dependencies]
2022-05-24 23:24:33 +10:00
nih_plug_xtask = { git = "https://github.com/robbert-vdh/nih-plug.git" }
2022-03-02 20:01:48 +11:00
```
```rust
2022-07-04 03:49:20 +10:00
// xtask/src/main.rs
2022-03-02 20:01:48 +11:00
fn main() -> nih_plug_xtask::Result< ()> {
nih_plug_xtask::main()
}
```
2022-07-04 03:49:20 +10:00
Lastly, create a `.cargo/config` file in your repository and add a Cargo alias.
This allows you to run the binary using `cargo xtask` :
2022-03-02 20:01:48 +11:00
```toml
# .cargo/config
[alias]
xtask = "run --package xtask --release --"
```