Skip to content
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

Be able to specify which targets are valid in a workspace #41

Open
2 tasks
Tracked by #84
repi opened this issue Sep 12, 2019 · 3 comments
Open
2 tasks
Tracked by #84

Be able to specify which targets are valid in a workspace #41

repi opened this issue Sep 12, 2019 · 3 comments
Labels

Comments

@repi
Copy link
Contributor

repi commented Sep 12, 2019

It would be great to be able to specify which targets are valid and can be used in a project and workspace. Ideally both on the workspace overall as well as on individual projects.

Both to give users an explicit error when trying to build for an unsupported target (instead of a link or compile error somewhere in the code, or worse: runtime panic), as well as to avoid bringing in dependencies for platforms that are not used into Cargo.lock and when vendoring.

We currently have both issues.

  1. We have crates that can only compile and only makes sense for certain targets, specifically native arch vs WASM, some of our crates work for both and some of them only work for one of them. And it is hard to "compile out" the code for the incompatible target in 50+ crates.

  2. Reduce amount of listed dependencies for targets we do not use. We want keep our dependencies as clear and few as possible to be able to review and manage everything we use, and then it is additional work if dependencies that we don't even use from platforms we don't use or support are brought in.

    For example the following targets we do not support: fuchsia, redox, emscripten, freebsd, android, cloudabi.

    And here are a few dependencies in our current Cargo.lock from these unused platforms/targets that we haven't been to get rid of: stdweb, android_glue, errno-dragonfly, fuchsia-zircon, fuchsia-zircon-sys, redox_syscall.

Issues:

@repi repi added the cargo label Sep 12, 2019
@repi
Copy link
Contributor Author

repi commented Dec 22, 2019

Still really want this, have so many extra dependencies lingering in our Cargo.lock that makes it harder to manage and get a good overview. And it also triggers cargo-deny more often than it should.

@GuillaumeGomez
Copy link

Might be worth opening an issue on cargo if not already done as it sounds like a very good idea.

@jayvdb
Copy link

jayvdb commented Aug 30, 2024

Regarding cargo-deny, it now supports --target or config like below to filter out crates that are present in Cargo.lock if they are not active in the selected targets.

[graph]
# By specifying allowed targets here, bans like "wasm-bindgen" can be added even though
# those crates exist in Cargo.lock for de-selected targets.
targets = [
    "x86_64-unknown-linux-gnu",
    "aarch64-apple-darwin",
    "x86_64-apple-darwin",
    "x86_64-pc-windows-msvc",
]

[[bans.deny]]
name = "wasm-bindgen"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants