Running just build.rs


#1

I’m not very familiar with build.rs.

I have read through https://doc.rust-lang.org/cargo/reference/build-scripts.html 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.)


#2

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.


#3

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

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?


#5

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


#6

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