From b77742005486825ea1899d5641ea644674bc595b Mon Sep 17 00:00:00 2001 From: James Wilson Date: Fri, 10 Dec 2021 11:54:07 +0000 Subject: [PATCH] Rebuild test-runtime if `substrate` binary is updated (#362) * Re-run test-runtime build script if the substrate binary changes * cargo fmt * Can => Cannot --- test-runtime/Cargo.toml | 1 + test-runtime/build.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/test-runtime/Cargo.toml b/test-runtime/Cargo.toml index 0094dd13cd..3b10fbc37b 100644 --- a/test-runtime/Cargo.toml +++ b/test-runtime/Cargo.toml @@ -12,3 +12,4 @@ codec = { package = "parity-scale-codec", version = "2", default-features = fals subxt = { path = ".." } sp-core = { package = "sp-core", git = "https://github.com/paritytech/substrate/", branch = "master" } async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } +which = "4.2.2" diff --git a/test-runtime/build.rs b/test-runtime/build.rs index e0b2c33ba4..5b4da8c647 100644 --- a/test-runtime/build.rs +++ b/test-runtime/build.rs @@ -113,6 +113,14 @@ async fn run() { fs::write(&runtime_path, runtime_api_contents) .expect("Couldn't write runtime rust output"); + let substrate_path = + which::which(substrate_bin).expect("Cannot resolve path to substrate binary"); + + // Re-build if the substrate binary we're pointed to changes (mtime): + println!( + "cargo:rerun-if-changed={}", + substrate_path.to_string_lossy() + ); // Re-build if we point to a different substrate binary: println!("cargo:rerun-if-env-changed={}", SUBSTRATE_BIN_ENV_VAR); // Re-build if this file changes: