#Build.rs with example code

8 messages · Page 1 of 1 (latest)

past cobalt
#

My build.rs generates protobuf files for my example code. How do I make sure this code doesn’t run if I am doing a release build?

last trout
#

Spin the examples off into separate packages in a workspace and have build.rs files in those packages

past cobalt
#

Are you suggesting one crate per example or one crate with all the examples?

past cobalt
#

Okay. So what’s the purpose of example code in an examples/ directory? Like I specifically have examples of how to use the crate and demonstrate it using ‘cargo run —example <file name>’

last trout
#

but when you need advanced functionality like build scripts, a workspace is better

past cobalt
#

Ah, okay