From 264947a57526e293c3ab23290c76750b5bfffc31 Mon Sep 17 00:00:00 2001 From: CenTdemeern1 Date: Wed, 22 Oct 2025 21:20:29 +0200 Subject: [PATCH] Don't use pacman to detect and track libctru This uses pacman's output incorrectly and ends up scanning significantly more files than it should. libctru is already assumed to be at $DEVKITPRO/libctru earlier in the file. This is slightly more naive because it assumes libctru doesn't place files outside of $DEVKITPRO/libctru, but also it doesn't and obviously shouldn't. For me incremental (hot? warm? the opposite of cold) build times went down from ~20 seconds to <0.2. --- ctru-sys/build.rs | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/ctru-sys/build.rs b/ctru-sys/build.rs index 7d985696..91e1f15a 100644 --- a/ctru-sys/build.rs +++ b/ctru-sys/build.rs @@ -31,6 +31,7 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=DEVKITPRO"); println!("cargo:rustc-link-search=native={devkitpro}/libctru/lib"); + println!("cargo:rerun-if-changed={devkitpro}/libctru"); // https://github.com/rust3ds/cargo-3ds/issues/14#issuecomment-1783991872 // To link properly, this must be the same as the library linked by cargo-3ds when building @@ -215,10 +216,6 @@ fn detect_and_track_libctru() { } Err(err) => println!("cargo:warning=unknown libctru version: {err}"), } - - if let Err(err) = track_libctru_files(&pacman) { - println!("cargo:warning=unable to track `libctru` files for changes: {err}"); - } } fn get_libctru_version(pacman: &Path) -> Result<(String, String, String, String), Box> { @@ -246,33 +243,6 @@ fn parse_libctru_version(version: &str) -> Result<(String, String, String, Strin .ok_or_else(|| format!("unexpected number of version segments: {version:?}")) } -fn track_libctru_files(pacman: &Path) -> Result<(), String> { - let stdout = match Command::new(pacman) - .args(["--query", "--list", "libctru"]) - .stderr(Stdio::inherit()) - .output() - { - Ok(Output { stdout, status, .. }) if status.success() => stdout, - Ok(Output { status, .. }) => { - return Err(format!("pacman query failed with status {status}")); - } - Err(err) => { - return Err(format!("pacman query failed: {err}")); - } - }; - - for line in String::from_utf8_lossy(&stdout).lines() { - let Some((_pkg, file)) = line.split_once(char::is_whitespace) else { - println!("cargo:warning=unexpected line from pacman query: {line:?}"); - continue; - }; - - println!("cargo:rerun-if-changed={file}"); - } - - Ok(()) -} - #[cfg(feature = "layout-tests")] fn generate_layout_tests( output_file: &Path,