3

I have a Rust project with two executables:

src
└── bin
    ├── app.rs
    └── tool.rs

The tool program is run as a subprocess of app. (The separation is needed because tool is run with different permissions than app.)

To run app I need to first ensure that tool has been built, so I currently do something like this:

cargo build && cargo run --bin app

Ideally I would be able to add something to my Cargo.toml so that it knows that app depends on tool being built so that I could just run this:

cargo run --bin app

Is there a way to do this?

Nicholas Bishop
  • 1,141
  • 9
  • 21
  • 1
    Would [this question](https://stackoverflow.com/questions/33025887/how-to-use-a-local-unpublished-crate) be what you're looking for? It's based on [this part](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies) of the cargo docs. Should handle building `tool` and all of it's dependencies when you run `app`. – Tomas Farias Dec 27 '19 at 16:56

1 Answers1

1

Not currently, without hacky approaches, but there is some work in progress getting close: https://github.com/rust-lang/cargo/issues/9096

Simon Buchan
  • 12,707
  • 2
  • 48
  • 55