Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
- os: macos-latest
tesseract-install: brew install tesseract
- os: windows-latest
tesseract-install: winget install --id=UB-Mannheim.TesseractOCR -e --accept-package-agreements --accept-source-agreements
tesseract-install: |
winget install --id=UB-Mannheim.TesseractOCR -e --accept-package-agreements --accept-source-agreements
echo "C:\Program Files\Tesseract-OCR" >> $env:GITHUB_PATH
Comment on lines -21 to +23
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, tesseract.exe was installed but not on the PATH, causing command-not-found errors in tests.
The new multi-line run step ensures both installation and path exposure are handled consistently on Windows runners.


steps:
- uses: actions/checkout@v4
Expand All @@ -38,6 +40,10 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install additional dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y pkg-config libdbus-1-dev libssl-dev libclang-dev libxcb1-dev libxrandr-dev libpipewire-0.3-dev libwayland-dev libegl-dev

Comment on lines +43 to +46
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some crates (e.g. libxcap, wayshot, pipewire) link against system libraries unavailable in a clean Ubuntu runner.
Adding these packages prevents linker errors and ensures parity with local development environments.

- name: Install Tesseract
run: ${{ matrix.tesseract-install }}

Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ impl OcrEngine {
image: &DynamicImage,
) -> Result<(String, String, Option<f64>)> {
match &self.provider {
#[cfg(target_os = "macos")]
OcrProvider::MacOS => Ok(perform_ocr_apple(image, &self.options.languages)),
OcrProvider::MacOS => {
#[cfg(target_os = "macos")]
{
Ok(perform_ocr_apple(image, &self.options.languages))
}
#[cfg(not(target_os = "macos"))]
{
Err(anyhow::anyhow!(
"macOS OCR is not available on this platform"
))
}
}
Comment on lines -72 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original implementation conditionally compiled the match arm, which caused missing-variant errors on non-macOS builds.
The updated approach keeps the variant present in all builds while using runtime cfg checks to control execution.
This prevents compilation issues and provides a clear runtime error if the macOS engine is selected on unsupported platforms.

OcrProvider::Windows => {
#[cfg(target_os = "windows")]
{
Expand Down