-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Full implementation of rust.workspace() #15223
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
Draft
bonzini
wants to merge
28
commits into
mesonbuild:master
Choose a base branch
from
bonzini:cargo-object-full
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5a4897d to
077fcec
Compare
5689c94 to
5427fdf
Compare
Member
Hmmm? |
Collaborator
Author
It's a draft. :) it will go away when I rebase before making it non-draft. I often have merge commits locally when something builds on top of other PRs. |
8d09d29 to
0056c4c
Compare
It should be added even if unexpected_cfgs is not part of Cargo.toml. Signed-off-by: Paolo Bonzini <[email protected]>
d19c696 to
fc8bc05
Compare
Make the implicit `xyz = ["dep:xyz"]` declaration explicit in the Manifest.
This also makes it possible to implement correctly the part of the spec where
"If you specify the optional dependency with the dep: prefix anywhere in
the [features] table, that disables the implicit feature."
Unfortunately, this can only be done after target-specific configurations
are resolved, which makes it hard to write a unit test for this. Rustix
requires it, though; without this patch, something like
[package]
name = "rustix"
edition = "2021"
rust-version = "1.63"
version = "0.38.34"
[dependencies]
alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
libc = { version = "0.2.0", optional = true, package = "libc" }
libc_errno = { version = "0.3.8", optional = true, package = "errno" }
[features]
alloc = []
default = ["std"]
rustc-dep-of-std = ["dep:alloc"]
std = ["alloc"]
use-libc = ["libc_errno", "libc"]
would incorrectly request the rustc-std-workspace-alloc crate via the
chain default->std->alloc. The patch blocks it because it finds the
"dep:alloc" dependency of feature rustc-dep-of-std.
Signed-off-by: Paolo Bonzini <[email protected]>
Some projects may want to override Meson's AST generation for Cargo projects. This was not really doable before without hard coding the results of feature resolution; however, now it will be possible by accessing the results of the global feature resolution from the Rust module's workspace object. At the same time, the subproject must keep using the Cargo method, which is forced by the workspace object's subproject() method, because otherwise the interpreter is not propagated. So just skip the interpretation phase if a Meson.build is present. Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
rust.workspace() is the entry point for global feature resolution. It loads a Cargo.toml file and ensures that all dependencies will be built with the correct set of features. Fixes: mesonbuild#13404
Add features property to cargo.Interpreter to make default features configurable; customization of which features are enabled by default is triggered by rust.workspace(). Fixes: mesonbuild#14290
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
This is up to 2x faster because it avoids checks for pkg-config and cmake. Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Note that, as shown in the testcase, package() works in the subproject as well. This means that in the future the Cargo code generator can be changed to reduce the amount of generated code and instead rely on the package object. Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
…rgets Add rustc_args(), env(), and rust_dependency_map() methods to the RustPackage class. They simply delegate to PackageState and PackageConfiguration.
Signed-off-by: Paolo Bonzini <[email protected]>
Move the logic for system dependencies outside Cargo.interpreter and into the rust module, so that it can be reused by the workspace object. Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
fc8bc05 to
6444de9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the spec see #14639.
This adds a Cargo package object that can provide rustc arguments and dependencies&mdashbut also nice shortcuts
pkg.executable(),pkg.library(),pkg.proc_macro(),pkg.shared_module()that can basically reduce a Rust crate to just:Based on #15158.
Fixes: #14639