We delivered a project to a client and as they were integrating it into their CI they wondered whether there's any risk that the location of the application binary in target-dir might change in the future. I suggested they use cargo install to a custom directory as a means to avoid having to find out, which was acceptable.
But just out of curiosity; I'm wondering if the actual location of application binaries has been set in stone (sans target triplet renaming) in target-dir. Is there some way for a CI to probe exactly where a target binary will be constructed?
rustc can list all the produced artifacts in json format, cargo rustc --message-format=json-render-diagnostics with some extra flags can list all the knows how to call rustc and retains information about some of the artifacts - this includes binary files. cargo-metadata can parse this json into something you can use to get the actual path you want.
Cargo also creates several other directories and files needed for the build process. Their layout is considered internal to Cargo, and is subject to change. Some of these directories are:
That implies everything before that is stable which includes the location of final artifacts. That is also how I've been treating them when working out designs for Cargo features.
As mentioned, watching the output of rustc messages also helps. You can do this with cargo build --message-format=json and escargot (and maybe cargo_metadata) provide an API for this.
As for predicting the location, we don't have that yet though maybe something that a plumbing command would offer.