pax_global_header00006660000000000000000000000064147213054430014515gustar00rootroot0000000000000052 comment=9a96012a0d712460118a2ed7f6f4537e37d49f4a leptonica-sys-0.4.9/000077500000000000000000000000001472130544300143215ustar00rootroot00000000000000leptonica-sys-0.4.9/.github/000077500000000000000000000000001472130544300156615ustar00rootroot00000000000000leptonica-sys-0.4.9/.github/workflows/000077500000000000000000000000001472130544300177165ustar00rootroot00000000000000leptonica-sys-0.4.9/.github/workflows/rust.yml000066400000000000000000000007201472130544300214350ustar00rootroot00000000000000name: Rust on: push: branches: [ main ] pull_request: branches: [ main ] env: CARGO_TERM_COLOR: always jobs: build: runs-on: ubuntu-latest steps: - name: Install Leptonica run: sudo apt-get install libleptonica-dev clang - uses: actions/checkout@v2 - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose --lib - name: Check formatting run: cargo fmt -- --check leptonica-sys-0.4.9/.gitignore000066400000000000000000000000361472130544300163100ustar00rootroot00000000000000/target **/*.rs.bk Cargo.lock leptonica-sys-0.4.9/Cargo.toml000066400000000000000000000010671472130544300162550ustar00rootroot00000000000000[package] name = "leptonica-sys" version = "0.4.9" authors = ["Chris Couzens "] edition = "2018" links = "lept" build = "build.rs" description = "FFI bindings for Leptonica" license = "MIT" repository = "https://github.com/ccouzens/leptonica-sys" keywords = ["leptonica"] categories = ["api-bindings", "multimedia::images"] [build-dependencies] bindgen = "0.64.0" [target.'cfg(windows)'.build-dependencies] vcpkg = "0.2.15" [target.'cfg(any(target_os="macos", target_os="linux", target_os="freebsd"))'.build-dependencies] pkg-config = "0.3.25" leptonica-sys-0.4.9/LICENSE000066400000000000000000000020561472130544300153310ustar00rootroot00000000000000MIT License Copyright (c) 2019 Chris Couzens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. leptonica-sys-0.4.9/README.md000066400000000000000000000035071472130544300156050ustar00rootroot00000000000000# leptonica-sys Rust FFI bindings to [Leptonica](http://www.leptonica.org/). Types and functions generated from the functions listed in [allheaders.h](https://github.com/DanBloomberg/leptonica/blob/master/src/allheaders.h). ## Help wanted [Windows and Mac maintainers wanted](https://github.com/ccouzens/leptonica-sys/issues/17). ## Building This links to the C library Leptonica. On Fedora 30 the build dependencies can be installed by running: ```bash sudo dnf install leptonica-devel clang ``` On Termux 2019 (Android, Android on Chromebooks) the additional dependencies can be installed by running: ```bash pkg install libclang leptonica-dev ``` ### Building on Windows On Windows, this library uses Microsoft's [vcpkg](https://github.com/microsoft/vcpkg) to provide leptonica. Please install [vcpkg](https://github.com/microsoft/vcpkg) and **set up user wide integration** or [vcpkg crate](https://crates.io/crates/vcpkg) won't be able to find the library. By default vcpkg installs 32 bit libraries. If you need 64 bit libraries then set following environment variable ```cmd SET VCPKG_DEFAULT_TRIPLET=x64-windows ``` To install leptonica ```cmd REM from the vcpkg directory .\vcpkg install leptonica ``` vcpkg allows building either dynamically or statically linked application if you prefer dynamic linking ```cmd SET VCPKGRS_DYNAMIC=true ``` for statically linked libraries ```cmd SET RUSTFLAGS=-Ctarget-feature=+crt-static ``` If you prefer to compile tesseract yourself (Because, for example, you could not get vcpkg to build using clang-cl.exe), you can set these environment variables: `LEPTONICA_INCLUDE_PATH`, `LEPTONICA_LINK_PATHS` and `LEPTONICA_LINK_LIBS`. For example: ``` set LEPTONICA_INCLUDE_PATH=D:\leptonica\build\include set LEPTONICA_LINK_PATHS=D:\leptonica\build\lib set LEPTONICA_LINK_LIBS=leptonica-1.83.0 ``` leptonica-sys-0.4.9/build.rs000066400000000000000000000060551472130544300157740ustar00rootroot00000000000000extern crate bindgen; use std::env; use std::path::PathBuf; #[cfg(windows)] use vcpkg; // const MINIMUM_LEPT_VERSION: &str = "1.80.0"; #[cfg(windows)] fn find_leptonica_system_lib() -> Option { println!("cargo:rerun-if-env-changed=LEPTONICA_INCLUDE_PATH"); println!("cargo:rerun-if-env-changed=LEPTONICA_LINK_PATHS"); println!("cargo:rerun-if-env-changed=LEPTONICA_LINK_LIBS"); let vcpkg = || { let lib = vcpkg::Config::new().find_package("leptonica").unwrap(); let include = lib .include_paths .iter() .map(|x| x.to_string_lossy()) .collect::(); Some(include) }; let include_path = env::var("LEPTONICA_INCLUDE_PATH").ok(); let link_paths = env::var("LEPTONICA_LINK_PATHS").ok(); let link_paths = link_paths.as_deref().map(|x| x.split(',')); let link_libs = env::var("LEPTONICA_LINK_LIBS").ok(); let link_libs = link_libs.as_deref().map(|x| x.split(',')); if let (Some(include_path), Some(link_paths), Some(link_libs)) = (include_path, link_paths, link_libs) { for link_path in link_paths { println!("cargo:rustc-link-search={}", link_path) } for link_lib in link_libs { println!("cargo:rustc-link-lib={}", link_lib) } Some(include_path) } else { vcpkg() } } // we sometimes need additional search paths, which we get using pkg-config // we can use leptonica installed anywhere on Linux. // if you change install path(--prefix) to `configure` script. // set `export PKG_CONFIG_PATH=/path-to-lib/pkgconfig` before. #[cfg(any(target_os = "macos", target_os = "linux", target_os = "freebsd"))] fn find_leptonica_system_lib() -> Option { let pk = pkg_config::Config::new().probe("lept").unwrap(); // Tell cargo to tell rustc to link the system proj shared library. println!("cargo:rustc-link-search=native={:?}", pk.link_paths[0]); println!("cargo:rustc-link-lib={}", pk.libs[0]); let mut include_path = pk.include_paths[0].clone(); if include_path.ends_with("leptonica") { include_path.pop(); } Some(include_path.to_str().unwrap().into()) } #[cfg(all( not(windows), not(target_os = "macos"), not(target_os = "linux"), not(target_os = "freebsd") ))] fn find_leptonica_system_lib() -> Option { println!("cargo:rustc-link-lib=lept"); None } fn main() { let clang_extra_include = find_leptonica_system_lib(); let mut bindings = bindgen::Builder::default().header("wrapper.h"); if let Some(include_path) = clang_extra_include { bindings = bindings.clang_arg(format!("-I{}", include_path)); } bindings = bindings.blocklist_type("max_align_t"); let bindings = bindings .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); } leptonica-sys-0.4.9/src/000077500000000000000000000000001472130544300151105ustar00rootroot00000000000000leptonica-sys-0.4.9/src/lib.rs000066400000000000000000000014511472130544300162250ustar00rootroot00000000000000#![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); #[cfg(test)] mod tests { use super::{pixFreeData, pixGetHeight, pixGetWidth, pixRead}; #[test] fn image_size() { unsafe { let image = pixRead(b"../test image.png\0".as_ptr().cast()); assert_eq!(pixGetWidth(image), 1000); assert_eq!(pixGetHeight(image), 500); pixFreeData(image); } } #[test] #[allow(path_statements)] fn defined_constants() { super::IFF_UNKNOWN; super::IFF_BMP; } #[test] #[allow(path_statements)] fn defined_functions() { super::boxCreateValid; super::boxDestroy; super::boxGetGeometry; } } leptonica-sys-0.4.9/test image.png000066400000000000000000000326721472130544300170630ustar00rootroot00000000000000PNG  IHDR(-iCCPICC profile(}=H@_S"(dNDE EjVL.& IZpc⬫ ~:)HK -b=8ǻ{wP-2j46JWt`/3˘8Z{zY9ՌH< & ޴ !Us1.Hu792ykbYԈêSXY+YuCaK BAa#BNG[]D.\0r, Z /)_c|;N?Wz_3WZ.\Olʮ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