From e31cce89209b40d8de31c85cbbee52fb28d77826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sun, 27 Oct 2024 09:38:10 +0900 Subject: [PATCH] build: Use CARGO_MANIFEST_DIR and decrease scope of files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/build.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/build.rs b/src/build.rs index 0ffac8a7..38c4adef 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,4 +1,8 @@ -use std::process::{exit, Command}; +use std::{ + env, + path::Path, + process::{exit, Command}, +}; use vergen_gix::{BuildBuilder, CargoBuilder, DependencyKind, GixBuilder}; @@ -64,7 +68,11 @@ fn install_trunk() -> Result<(), Box> { } fn main() -> Result<(), Box> { - println!("cargo:rerun-if-changed=./src/webpage/"); + let out_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + for path in ["src", "assets", "index.html"].iter() { + let p = Path::new(&out_dir).join(format!("src/webpage/{}", path)); + println!("cargo:rerun-if-changed={}", p.display()); + } vergen_gix::Emitter::default() .add_instructions(&BuildBuilder::all_build()?)?