Skip to content

Commit

Permalink
fix: apple ocr distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Aug 8, 2024
1 parent fdf0514 commit 1d74b4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion screenpipe-vision/build.rs → build.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
13 changes: 10 additions & 3 deletions screenpipe-vision/src/ocr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ public func performOCR(imageData: UnsafePointer<UInt8>, 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

0 comments on commit 1d74b4d

Please sign in to comment.