mmstick / cargo-deb

A cargo subcommand that generates Debian packages from information in Cargo.toml
615 stars 50 forks source link

Support finding assets in Cargo's OUT_DIR #154

Closed nirvdrum closed 4 years ago

nirvdrum commented 4 years ago

First off, thanks for this awesome project. It's amazing being able to build a .deb file with very little configuration.

Recently, I've been looking to add in shell completions for my small CLI app. A common approach I've found is using a build.rs script to generate the shell completions from Clap. However, there doesn't seem to be a way to reference those files in the package.metadata.deb assets list. Since build scripts are limited to writing to Cargo's OUT_DIR, it'd be very helpful if that location was another candidate in the search path for listed assets.

I think adding support for this would address part of the problem in #67. ripgrep is another project I came across that can't build a deb via cargo deb directly, relying on a separate script to stage the data before the command can be run. Unless I'm mistaken, it'd also allow this project's example build script to adhere to the restrictions in the Rust docs on build scripts: "Build scripts may save any output files in the directory specified in the OUT_DIR environment variable. Scripts should not modify any files outside of that directory."

Of course, this all presupposes that there's a way for OUT_DIR to be exposed to cargo-deb. If not, I'm sorry for the noise.

kornelski commented 4 years ago

It would be an awesome feature. Unfortunately, I don't think this location is exposed outside of Cargo.

I've asked about it before https://github.com/rust-lang/cargo/issues/5457 and the larger issue is completely stalled https://github.com/rust-lang/cargo/issues/545

There was an attempt to replace build tasks with xtask, but xtask has chosen a design that is also a black box from outside, so it's incompatible with cargo-deb https://github.com/matklad/cargo-xtask/issues/10

nirvdrum commented 4 years ago

Thanks for those links. I spent a while searching for information, but I was mostly limiting the search to cargo-deb. It's an unfortunate situation without a great solution. The simplest approach, like the one taken in the example build script, is subject to breaking without notification. Trying to find the "out" directory is tedious and error-prone.

Since it looks like you've already extensively investigated this and there's a limitation in Cargo, please feel free to close this issue as you see fit.