From 2a6631f3da6f45bb11760b46c7caedde139723e3 Mon Sep 17 00:00:00 2001 From: uncor3 Date: Fri, 19 Dec 2025 20:10:42 -0800 Subject: [PATCH] fix offline build (#47) --- ffi/build.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ffi/build.rs b/ffi/build.rs index a6d1b5d..fa36fdf 100644 --- a/ffi/build.rs +++ b/ffi/build.rs @@ -35,14 +35,22 @@ fn main() { .expect("Unable to generate bindings") .write_to_file("idevice.h"); - // download plist.h - let h = ureq::get("https://raw.githubusercontent.com/libimobiledevice/libplist/refs/heads/master/include/plist/plist.h") - .call() - .expect("failed to download plist.h"); - let h = h - .into_body() - .read_to_string() - .expect("failed to get string content"); + // Check if plist.h exists locally first, otherwise download + let plist_h_path = "plist.h"; + let h = if std::path::Path::new(plist_h_path).exists() { + std::fs::read_to_string(plist_h_path) + .expect("failed to read plist.h") + } else { + // download plist.h + let h = ureq::get("https://raw.githubusercontent.com/libimobiledevice/libplist/refs/heads/master/include/plist/plist.h") + .call() + .expect("failed to download plist.h"); + h + .into_body() + .read_to_string() + .expect("failed to get string content") + }; + let mut f = OpenOptions::new().append(true).open("idevice.h").unwrap(); f.write_all(b"\n\n\n").unwrap(); f.write_all(&h.into_bytes())