Skip to content

Allow build scripts to stage final artifacts #13663

@lolbinarycat

Description

@lolbinarycat

Problem

i was trying to create an idiomatic template that uses clap_complete within build.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
  • the value of $OUT_DIR is not easily accessible to outside programs
  • the makefile needs to know where the files are in order to install them

Proposed Solution

  1. add a mechanism for the main crate (i.e. the one the user said to build, not any of its dependancies) built to produce outputs in $CARGO_TARGET_DIR (or a fixed subdir thereof, such as target/release/aux)
  2. (low priority) add a cargo::install instruction that allows directing cargo install to install files relative to a configured prefix (eg. .local, /usr, or /usr/local). using cargo::install=$OUT_DIR/CMDNAME.bash=share/bash/bash-completions/completions/CMDNAME would install the completion in the specified completion dir. (see Support installing manpages (and potentially other files) #2729)

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions