-
Couldn't load subscription status.
- Fork 2.7k
Description
Describe the problem you are trying to solve
It seems now the build scripts like build.rs are not necessarily run before checking all codes in the project. That leads to a potential dependency issue. The problem I encountered is that in my code, a macro tries to load a file statically, which is generated in build.rs, then since build.rs is not run at the very beginning, rustc complains, when dealing with this macro, that it cannot find the need file.
The macro I used in main is wgpu::include_spirv!("shaders/shader.spv"), which is to "load a SPIR-V module statically" according to its doc. And in the build script, basically I just compile shader files(like shader.vert) into spv files. The workaround I used is to clean all compile cache and run cargo run directly. In this case, the build script seems to be run first, then everything is fine. But, if I run cargo build without the presence of the needed file, rustc will complain.
I didn't find out any methods that can run build scripts separately or at very least make sure build scripts are run before everything else starts in the cargo book nor on the web nor in the community(see this). Correct me if you know any methods to do so and thanks in advance.
Describe the solution you'd like
Give us a cargo command to run build scripts separately or a cargo flag that ensures build scripts will run first before anything starts.
Notes