Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSet CARGO_TARGET_DIR for build scripts #5457
Comments
alexcrichton
added
the
C-feature-request
label
May 2, 2018
This comment has been minimized.
This comment has been minimized.
inferiorhumanorgans
commented
May 25, 2018
|
This would be useful for library integration tests as well. For example -- building a plugin library and having an external (non-rust) program load the library for testing. |
This comment has been minimized.
This comment has been minimized.
|
This would be useful for debcargo as well, we're having the same issue with ripgrep. cargo's documentation says build scripts should modify anything not in Currently what we're doing in Debian is running this ugly shell snippet (taken from ripgrep's own scripts) right after we run
Then the rest of the Debian packaging can find the outputs in the static location |
This comment has been minimized.
This comment has been minimized.
|
Note that unfortunately the above does not generalise, since "ripgrep-stamp" is a file specifically created by ripgrep's build.rs |
This comment has been minimized.
This comment has been minimized.
nertpinx
commented
Jan 5, 2019
|
This would be useful and is really needed in my opinion. Build scripts must have configurable output the same way cargo does. I have to parse the target dir out of the out dir just to figure out where to put the result. My particular reason is integration in autotools project where VPATH builds must work. It would also help to have something like |
kornelski commentedMay 2, 2018
From tmccombs:
Cargo exports an “OUT_DIR” environment variable to build scripts so that build scripts can store outputs there. And for generated source code this is fine. However when generating final artifacts that should be distributed with the binary, such as documentation (man pages) or shell completion scripts, storing them in the OUT_DIR is somewhat problematic. Not only is OUT_DIR different per package, but the path has some kind of hash in it, and isn’t included in the output of cargo metadata. Which makes such artifacts difficult to discover with tools like cargo-deb or to write robust packaging scripts.
As a specific example, ripgrep uses clap to generate shell completion scripts, which it stores in the OUT_DIR, and the maintainer uses cargo-deb to produce debian packages. However, the resulting debs don’t contain the completion scripts. cargo-deb has a way to specify additional assets by path to include, but since the OUT_DIR isn’t fixed, it isn’t possible to specify a fixed path for the completion scripts.
Currently
CARGO_TARGET_DIRis read by Cargo. It would be useful if Cargo also set it (if not set already) to the actual value it uses.