Proposal: Build shell completion with build script#72
Conversation
Signed-off-by: Rafael Passos <rafael@rcpassos.me>
|
@weriomat ping
This is not a Rust library, and thus should not be packaged as such. Irrelevant. |
weriomat
left a comment
There was a problem hiding this comment.
Halo Rafael,
this seems like a reasonable solution to your problem. As I only use nix/ build from source this is not a concern for my setup.
The overhead generating these at build time should be ignorable imo.
| clap_complete = "4" | ||
|
|
||
| [build-dependencies] | ||
| clap = { version = "4", features = ["derive"] } |
There was a problem hiding this comment.
Why is the workspace dependency not used?
| include!("src/opts.rs"); | ||
|
|
||
| fn main() -> std::io::Result<()> { | ||
| let outdir = "./target"; |
There was a problem hiding this comment.
Is there a reason not to respect CARGO_TARGET_DIR?
There was a problem hiding this comment.
I just did not know about it! Applied it. Thanks!
There was a problem hiding this comment.
After reading the docs a bit more broadly I noticed that CARGO_TARGET_DIR is used for configuring cargo itself and that OUT_DIR should be used in a build file. Like it is done in the example you linked for generate_to.
Pardon me :)
There was a problem hiding this comment.
They have different behaviors. The OUT_DIR creates a different folder per build, while the former puts the file in the "root of the build folder".
I'll test both with the debian packaging tools (maybe tomorrow).
Check it out:
Using OUT_DIR:
cargo build
Compiling siomon v0.2.3 (/siomon)
warning: siomon@0.2.3: shell completions generated in /siomon/target/debug/build/siomon-05022c59d4204aad/out/
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64sUsing CARGO_TARGET_DIR:
cargo build
Compiling siomon v0.2.3 (/siomon)
warning: siomon@0.2.3: shell completions generated in ./target/
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64sSigned-off-by: Rafael Passos <rafael@rcpassos.me>
Signed-off-by: Rafael Passos <rafael@rcpassos.me>
|
Just to be sure, the |
|
I would be in favor of bumping the version of siomon after the merge of this PR so that the nixpkgs package can be updated to the new shell completion location |
|
Hi @emansom
To clarify the context: the Debian Rust team uses Because Debian builds from the published crate tarball, files excluded from the crate publication (such as the Moving the shell completion generation to For reference on the process, this is documented in the Debian rust-team guide: https://rust-team.pages.debian.net/book/process-single.html I hope this clarifies things. |
Good point. I didn't find anything specific in the docs. Note: this warning is optional. It is used the the example for |
|
Good to know that this rebuild it every time (as expected). |
"A comprehensive Linux hardware information and real-time sensor monitoring tool. Single static binary, no runtime dependencies."
What about after? using the
I do not entirely agree with this rationale, as the shell completions are not essential to the function of |
It still is. Debian packages all dependencies separately, but for rust they are just build dependencies.
crates.io is involved in the source fetching process, not during build.
It helps! That's why I opened the PR. I'm only trying to help here. |
How will the release cycle look like? Does debian have some sort of bot that looks for new crates.io publications? |
It does. Not only for crates.io. https://tracker.debian.org/pkg/rust-alacritty Check the "action needed" section: |
Hi,
I am packaging
siomonfor Debian [1], and would like to propose a change that would make things easier there: generating the shell completions using the build script (build.rs, this PR).Why it helps:
Rust packages on Debian are being built from the sources published in crates.io. Since the current
xtaskscript is not part of thesiomonpackage (thecargo package --listshows the included files), we are unable to just grab the files from source.I understand if you don't want the completions to be built every time (although it is a small build).
On the other side, it makes the packaging process simpler for you too (I updated the packaging scripts too).
As always, this is optional. If you decide not to take this contribution, I will find another way, just not the simplest one.
[1] Posted on the forums: https://forum.level1techs.com/t/packaging-siomon-for-upstream-debian/251448/6
Thanks,
Rafael.