Running just build.rs

I'm not very familiar with build.rs.

I have read through Build Scripts - The Cargo Book but it doesn't answer my question of:

"How do I run build.rs and do nothing else?"

(I am interested in the output that build.rs generates.)

You can run cargo build, but that will also build your program, but not execute it.

I'm not quiet sure, but I don't know way to only execute build.rs.

cargo saves a file with the build script output in the build directory. It should be something like target/debug/build/{crate name}-{hash}/output.

You can also use println!("cargo:warning=your text"); in the build script to output something during the build.

4 Likes

Is this documented anywhere? I was looking for such possibility not so long time ago and I didn't find anything. Are there other special prints to be used in build.rs?

https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script

2 Likes

Got it; thanks cargo build seems like the simplest solution.