From 8c0146eac63516fb28a7eb78eaefe103ee3ac014 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 14 Jun 2023 14:38:46 +0200 Subject: [PATCH] Don't recompile the `dora-operator-api-c` crate on every build/run By default, cargo reruns build scripts whenever any file of the package changes. This led to lots of unnecessary rebuilds of the `dora-operator-api-c` crate. The reason is that crate has a build script that updates the `operator_types.h` file, which is considered as a modification by cargo. So it reruns the build script on the next `cargo build` or `cargo run` command, which leads to subsequent rebuilds of all crates that depend on `dora-operator-api-c`. This commit fixes this issue by instructing cargo to never rerun the build script (through a special `println`). This way the package is considered 'fresh' on rebuilds. Cargo will still rerun the build script when the `dora_operator_api_types` crate changes, so the `operator_types.h` file still stays up-to-date. --- apis/c/operator/build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apis/c/operator/build.rs b/apis/c/operator/build.rs index d159adb1..a9b4adfd 100644 --- a/apis/c/operator/build.rs +++ b/apis/c/operator/build.rs @@ -3,4 +3,9 @@ use std::path::Path; fn main() { dora_operator_api_types::generate_headers(Path::new("operator_types.h")) .expect("failed to create operator_api.h"); + + // don't rebuild on changes (otherwise we rebuild on every run as we're + // writing the `operator_types.h` file; cargo will still rerun this script + // when the `dora_operator_api_types` crate changes) + println!("cargo:rerun-if-changed="); }