-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update OUT_DIR based on cargo check output
#3582
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
Conversation
I am investigating now, and it seem to be due to |
Will that handle a target directory that's not a subdirectory of the crate root? E.g. if you set CARGO_TARGET_DIR to an absolute path |
|
@jyn514 It doesn't yet, but should once I get around to making it add a new vfs root for each out_dir. |
|
Okay pushed a new take on the whole thing. This time it actually works! So I've added a config option to run cargo check when loading a cargo workspace to get the right OUT_DIR paths. It did take some juggling to get the extern source stuff to a reasonable point. It currently doesn't support setting OUT_DIR for sysroot crates, but I don't think any of them should be using build scripts with OUT_DIR? I'll take a look at folding the custom path support into the project model config, so we can eliminate some duplication, and then add OUT_DIR support to the json workspaces. |
|
Okay that wasn't too bad either. @matklad Do you want me to hook up OUT_DIR support for CLI runs of rust-analyzer as well, while I'm at it? |
Yeah, I guess that would be helpful! It should be behind a |
|
|
|
And with that in place I think this is ready for some actual review. |
|
NPM audit check seems to be causing issues upstream, not sure if I can do anything about it. |
cargo check outputcargo check output
|
Rebased to preempt bors hi-jinx due to CI changes |
| ra_arena = { path = "../ra_arena" } | ||
| ra_db = { path = "../ra_db" } | ||
| ra_cfg = { path = "../ra_cfg" } | ||
| ra_cargo_watch = { path = "../ra_cargo_watch" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the right direction of the dependency should be. It would be cool if there were exactly one crate that invokes cargo/rust. Perhaps we need to introduce a ra_toolchain crate... But this is mostly unrelated to the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had the same exact consideration. With VFS changes, we can keep it contained to ra_cargo_watch, but we need a good way to add roots and extern source on-the-go.
The dream scenario would be cargo metadata providing the needed information, but in previous issues the cargo folks don't seem to keen on that.
|
Concerns should be resolved in new commits. Also re-based once again to make it easier on poor bors |
|
bors r+ |
3582: Update OUT_DIR based on `cargo check` output r=matklad a=kiljacken
This entire PR is basically annoying plumbing needed to pass through the correct OUT_DIR from a `cargo check` run to the right place in the crate graph.
It's in a semi working state: It correctly updates OUT_DIR in the crate graph, and get's to the point where macro's depending on `env!("OUT_DIR")` are re-evaluated, but I don't seem to get completion for the `gl` crate still. Not sure why, but decided to get the code public ASAP so we can discuss the right direction to take it.
Things that still need to be done/decided:
* [ ] When/if to schedule a single `cargo check` run on startup to get the correct OUT_DIR values.
* [ ] What's the story with features, targets and `OUT_DIR`?
* [ ] All the other things that I've overlooked
Depends on rust-analyzer/ra_vfs#20 but is currently patched to use my fork so things can work.
Co-authored-by: Emil Lauridsen <mine809@gmail.com>
Build failed |
|
Hm, so it seems like |
This entire PR is basically annoying plumbing needed to pass through the correct OUT_DIR from a
cargo checkrun to the right place in the crate graph.It's in a semi working state: It correctly updates OUT_DIR in the crate graph, and get's to the point where macro's depending on
env!("OUT_DIR")are re-evaluated, but I don't seem to get completion for theglcrate still. Not sure why, but decided to get the code public ASAP so we can discuss the right direction to take it.Things that still need to be done/decided:
cargo checkrun on startup to get the correct OUT_DIR values.OUT_DIR?Depends on rust-analyzer/ra_vfs#20 but is currently patched to use my fork so things can work.