HMIProject / open62541-sys

2 stars 2 forks source link

Avoid unnecessary rebuilds when rebuilt files change #16

Closed sgoll closed 3 months ago

sgoll commented 3 months ago

Description

This adjusts the rerun-if-changed directives issued by build.rs so that files generated by CMake are not rebuild triggers anymore. Instead, the source files in the bundled directory open62541/ themselves are used as triggers.

This avoids rebuild loops: until now, when build.rs was run, it would run a second time afterwards (on the next cargo check, cargo build, etc.) because it would see that the files generated by CMake in the first run were changed recently.

The effect can be seen by running cargo clean, followed by two times cargo check. Before the changes, the second cargo would rebuild the crate a second time, now it doesn't. Touching a file in open62541/ or wrapper.c/wrapper.h or build.rs itself still triggers a rebuild as intended.

sgoll commented 3 months ago

Alternatively, to verify, you can also inspect target/debug/build/open62541-sys-(…)/output and check the lines rerun-if-changed manually before and after the change.