matklad / cargo-xtask

840 stars 23 forks source link

How to not build xtask? #18

Closed pickfire closed 2 years ago

pickfire commented 2 years ago

xtask was added to helix but seemed like everytime something (one of the xtask dependency) is changed, xtask gets built. https://github.com/helix-editor/helix

Is there any way for cargo build to ignore xtask workspace? I think it is better to only be built when cargo xtask is called, since we only use cargo xtask docgen for documentation generation and is rarely runned unlike cargo b.

Seemed like cargo run won't build xtask but still cargo build will build xtask.

I think there is cargo b -p helix-term but I wonder if there is config to just exclude xtask so can run cargo b like usual.

pickfire commented 2 years ago

Adding alias to .cargo/config seemed to do the job.

[alias]
b = "build --workspace --exclude xtask"
c = "check --workspace --exclude xtask"
pickfire commented 2 years ago

We figured out how to solve this without using the alias hack. https://github.com/helix-editor/helix/commit/79caa7b72bef94bd820758b2ebc20887324f7416

Can use default-members in root Cargo.toml.

default-members = ["helix-term"]

I guess maybe we should put it in the README somewhere around Not Using xtasks so that people not using every time don't need to keep building it?

matklad commented 2 years ago

I’d say the best way to avoid building xtask is to not make it a part of workspace:

If you don't want to use a workspace, you can use run --manifest-path ./xtask/Cargo.toml -- for the alias, but this is not recommended.

matklad commented 2 years ago

See also https://github.com/helix-editor/helix/commit/71292f9f11bd2b50568efd111239f693be26a36a#r68116111

pickfire commented 2 years ago

I guess for now we can close this and discuss it there.