-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow build scripts to stage final artifacts #13663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Going to close in favor of #2729. While there might be differences in solution, the root problem is the same and it would be good to focus the conversation on how to solve the problem in one place with one coherent solution, regardless of what is initially mentioned in the original issue. If there is a reason for us to keep this open separately, let us know! |
@epage that issue is almost completely orthogonal. if i had decided to just not mention my main issue is with external tools being unable to easily access files created by build scripts. |
Made an edit to the issue to try to clarify that. Is that right? If I'm understanding the main issue, it is one of the use cases brought up in #9661, see #9661 (comment) for the summary of the discussion, particularly "Staging files for the --out-dir so they are next to the cargo-built final artifacts". Is that right? |
yes, precisely. i think producing the files in OUT_DIR and having cargo conditionally copy them over is the best solution, it maintains isolation, which is quite important for edge cases like hybrid lib+bin crates that also have a build script that produces shell completions. |
Copying over from #9661 as this issue is apparently a better fit. I have the same issue for man pages and shell completion, and my use case is not related to cargo install (as I have essentially given up on that for anything except simple standalone programs, and even then you get a subpar experience without completion and documentation). This is what I currently do:
This is quite hacky on the PKGBUILD side:
This breaks down if there are multiple out dirs as happens when you are developing and changing the package. During development it can look like this: ❯ find target/debug/ -name paketkoll.1 | wc -l
26 (A better approach is sorely needed. Since I soon have to learn bazel anyway for work, maybe switching away from cargo will be the solution for my open source projects too. Shame about the worse integration with the rest of the ecosystem though.) |
Some kind of predictable out dir, staging dir, or specified artifact destination dir would be interesting to cargo-deb.
|
The cargo-install part was crossed out for its own issue. Also, we wouldn't specialize this for specific file types. Good call on mentioning |
Problem
i was trying to create an idiomatic template that uses
clap_complete
withinbuild.rs
in order to generate and install shell completions, when i realized it is basically impossible.because
cargo install
only installs binaries, you have to use a Makefile, which is fine, but there's a problem:build.rs
is only supposed to create files under$OUT_DIR
$OUT_DIR
is not easily accessible to outside programsProposed Solution
$CARGO_TARGET_DIR
(or a fixed subdir thereof, such astarget/release/aux
)(low priority) add a(see Support installing manpages (and potentially other files) #2729)cargo::install
instruction that allows directingcargo install
to install files relative to a configured prefix (eg..local
,/usr
, or/usr/local
). usingcargo::install=$OUT_DIR/CMDNAME.bash=share/bash/bash-completions/completions/CMDNAME
would install the completion in the specified completion dir.Notes
No response
The text was updated successfully, but these errors were encountered: