MACRO: support env!("OUT_DIR") in include macro calls#4542
Conversation
42e2eed to
43311cb
Compare
43311cb to
4115087
Compare
|
I've filed a separate issue #4546 related to the corresponding user notification about the absence of expected generated files |
4115087 to
0e0e374
Compare
This value need to support code included via include macro calls like `include!(concat!(env!("OUT_DIR"), "/bindings.rs"))`.
At this moment this info extracted from output of `cargo build --build-plan` command.
0e0e374 to
21862de
Compare
…ROP_UNLOADED_PSI` It should invalidate caches when file is generated by compiler in target dir
21862de to
f185c10
Compare
|
@vlad20012 I've fixed all discussed issues |
|
bors r+ |
4542: MACRO: support `env!("OUT_DIR")` in include macro calls r=vlad20012 a=Undin
Under the hood, it uses output of `cargo build --build-plan` command to get value of `OUT_DIR` variable

Fixes #1908
Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
|
Thought I should drop this here: I've requested a way to get |
| val additionalArgs = mutableListOf("-Z", "unstable-options", "--all-targets", "--build-plan") | ||
| // Hack to make cargo think that current channel is nightly because we need unstable `--build-plan` option here | ||
| val envs = EnvironmentVariablesData.create(mapOf( | ||
| RUSTC_BOOTSTRAP to "1" |
There was a problem hiding this comment.
This means that this functionality can break at any moment.
There was a problem hiding this comment.
We are closely monitoring changes in the rust toolchain and ready for breaking changes in the build-plan or other nightly features that we use. We'd want a more explicit way to unlock all nightly command-line options on the stable toolchain but now there is only "RUSTC_BOOTSTRAP" magic.
|
@CAD97 thanks for the comment! Now we're going to disable the feature because of this. (the feature has not yet been released) |
|
@vlad20012 Maybe enable it only when the user is actually using a nightly compiler. Or do you want to not diverge the supported features between stable and nightly users? |
|
@bjorn3 Umm, I'm about the issue that build-plan invocation forces cargo to make full rebuild on the next build. I don't see differences between stable and nightly compiler in this case. But we'll make some option to enable this feature back |
…ault Recently supported name resolution for included files uses `cargo build --build-plan` to fetch value of `OUT_DIR` environment variable (see #4542). Found out that `cargo build --build-plan` force next `build` command to recompile whole project (including dependencies). See rust-lang/cargo#5579 (comment). At this moment it is part of refresh, i.e. it is invoked on each `Cargo.toml` change, project reopening, etc. So this command is invoked quite frequently. It can be rather unexpected for large project to make full compilation after each project reopening So we decided to disable it by default until it will be fixed from cargo side or we'll find better way to get `OUT_DIR` value
4573: MACRO: disable name resolution for include with env("OUT_DIR") by default r=Undin a=Undin
Recently supported name resolution for included files uses `cargo build --build-plan` to fetch value of `OUT_DIR` environment variable (see #4542).
Found out that `cargo build --build-plan` force next `build` command to recompile whole project (including dependencies).
See rust-lang/cargo#5579 (comment).
At this moment it is part of refresh, i.e. it is invoked on each `Cargo.toml` change, project reopening, etc. So this command is invoked quite frequently.
It can be rather unexpected for large project to make full compilation after each project reopening
So we decided to disable it by default until it will be fixed from cargo side or we'll find better way to get `OUT_DIR` value
Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
8012: CARGO: improve work with generated sources r=vlad20012 a=Undin In Rust ecosystem, it's quite common to generate some source via build scripts during compilation. Usually, such generated sources are included into project via `include!` macro. The plugin can work with such sources but the corresponding support is currently under `org.rust.cargo.evaluate.build.scripts` [experimental feature](https://plugins.jetbrains.com/plugin/8182-rust/docs/rust-faq.html#experimental-features). See #1908 for more context and details Since #4542, the plugin added all `out` directories of all packages as source roots into project content root entry. And it worked in general, but this approach has some disadvantages: - each `out` directory is displayed in `Project Structure` settings. If a project uses many libraries that produce a lot of own `out` directories, `Project Structure` becomes too large and complicated for manual editing - it doesn't work if `out` directory is located outside of the project directory (for example, because of the custom path of `target` directory) The new approach just provides all `out` directories via `IndexableSetContributor` API to make IDE index generated sources that solve all described issues Fixes #6808 Fixes #6844 Fixes #6998 Fixes #7583 Fixes #7934 changelog: Improve work with generated sources provided via `org.rust.cargo.evaluate.build.scripts` [experimental feature](https://plugins.jetbrains.com/plugin/8182-rust/docs/rust-faq.html#experimental-features). Now the plugin doesn't pollute `Project Structure` view with entries for generated `out` directories. Also, the custom paths of target directories are also supported Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
Under the hood, it uses output of
cargo build --build-plancommand to get value ofOUT_DIRvariableFixes #1908