From 1d74b4dceefccc7a47f1e795dfa54e781240f46a Mon Sep 17 00:00:00 2001 From: Louis Beaumont Date: Thu, 8 Aug 2024 17:46:09 +0200 Subject: [PATCH] fix: apple ocr distribution --- screenpipe-vision/build.rs => build.rs | 8 +++++++- screenpipe-vision/src/ocr.swift | 13 ++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) rename screenpipe-vision/build.rs => build.rs (68%) diff --git a/screenpipe-vision/build.rs b/build.rs similarity index 68% rename from screenpipe-vision/build.rs rename to build.rs index 71a3924ef..b72e19984 100644 --- a/screenpipe-vision/build.rs +++ b/build.rs @@ -1,10 +1,16 @@ use std::env; +use std::path::PathBuf; #[cfg(target_os = "macos")] fn main() { let destination = env::var("DESTINATION").unwrap_or_default(); - println!("cargo:rustc-link-search=native=screenpipe-vision/lib"); + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let lib_path = PathBuf::from(manifest_dir) + .join("screenpipe-vision") + .join("lib"); + + println!("cargo:rustc-link-search=native={}", lib_path.display()); if destination == "brew" { println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../lib"); diff --git a/screenpipe-vision/src/ocr.swift b/screenpipe-vision/src/ocr.swift index d7cdf83d0..da8e60a89 100644 --- a/screenpipe-vision/src/ocr.swift +++ b/screenpipe-vision/src/ocr.swift @@ -81,7 +81,14 @@ public func performOCR(imageData: UnsafePointer, length: Int, width: Int, return strdup(ocrResult.isEmpty ? "No text found" : ocrResult) } -// swiftc -emit-library -o screenpipe-vision/lib/libscreenpipe.dylib screenpipe-vision/src/ocr.swift +// # Compile for x86_64 +// swiftc -emit-library -target x86_64-apple-macosx10.15 -o libscreenpipe_x86_64.dylib screenpipe-vision/src/ocr.swift + +// # Compile for arm64 (aarch64) +// swiftc -emit-library -target arm64-apple-macosx11.0 -o libscreenpipe_arm64.dylib screenpipe-vision/src/ocr.swift + +// # Combine into a universal binary +// lipo -create libscreenpipe_x86_64.dylib libscreenpipe_arm64.dylib -output screenpipe-vision/lib/libscreenpipe.dylib + +// rm libscreenpipe_x86_64.dylib libscreenpipe_arm64.dylib -// or -// swiftc -emit-library -o /usr/local/lib/libscreenpipe.dylib screenpipe-vision/src/ocr.swift