rust-lang / rust-lang/rust-analyzer

How to track a generated file in build.rs

Open
#10,751 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I generate a file in build.rs using OUT_DIR env and I want to see the result to be able to better understand what is generated.

The only way I found is to search in target dir the file, but if for example I add a dependencies, the build uuid change and so that not the same file anymore.

Would it be possible to track down the "most recent" version of the generate file ? I guess it could be hard.

The way I see it would be able to ask rust-analyzer the result of include!(concat!(env!("OUT_DIR"), "/foo.rs")); or somehow be able to config the IDE to open the file "$OUT_DIR/foo.rs into a window where OUT_DIR can change.

Maybe using print it in build.rs like:

println!("rust-analyzer:generated=foo.rs");

The could allow hint rust-analyzer such file have been generated.

If anyone know a nice solution I would be please to know it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the build.rs workflow and the OUT_DIR path used by include!(concat!(env!("OUT_DIR"), "/foo.rs")). The issue names no implementation file or test, so first determine how rust-analyzer discovers generated files and whether a stable way to track the most recent output can be defined; done means the generated file remains discoverable when build UUIDs change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.