Skip to content

A fast, helpful, and open-source document parser

simplify builds

Logan Markewich69de0db73dd7
diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml
index 4f9f457..8f42ae2 100644
--- a/.github/workflows/ci-python.yml
+++ b/.github/workflows/ci-python.yml
@@ -79,11 +79,11 @@ jobs:
working-directory: packages/python
before-script-linux: |
if command -v yum &> /dev/null; then
- yum install -y clang-devel tesseract-devel leptonica-devel openssl-devel pkgconfig perl-IPC-Cmd glibc-devel || true
+ yum install -y tesseract-devel leptonica-devel openssl-devel pkgconfig perl-IPC-Cmd || true
elif command -v apt-get &> /dev/null; then
- apt-get update && apt-get install -y libclang-dev libtesseract-dev libleptonica-dev libssl-dev pkg-config libc6-dev || true
+ apt-get update && apt-get install -y libtesseract-dev libleptonica-dev libssl-dev pkg-config || true
elif command -v apk &> /dev/null; then
- apk add clang-dev tesseract-ocr-dev leptonica-dev openssl-dev pkgconf musl-dev || true
+ apk add tesseract-ocr-dev leptonica-dev openssl-dev pkgconf || true
fi
- name: Copy pdfium dylib into wheel (Unix)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7985c2f..7d00f13 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,7 +25,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- uses: actions/cache@v4
with:
path: |
@@ -49,7 +49,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
diff --git a/.github/workflows/e2e-output.yml b/.github/workflows/e2e-output.yml
index c9f0ff8..3130100 100644
--- a/.github/workflows/e2e-output.yml
+++ b/.github/workflows/e2e-output.yml
@@ -27,7 +27,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev \
+ sudo apt-get install -y libtesseract-dev libleptonica-dev \
tesseract-ocr libreoffice imagemagick ghostscript
- uses: actions/cache@v4
@@ -111,7 +111,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev \
+ sudo apt-get install -y libtesseract-dev libleptonica-dev \
tesseract-ocr libreoffice imagemagick ghostscript
- uses: actions/cache@v4
diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml
index be859fd..abaeaba 100644
--- a/.github/workflows/release-crates.yml
+++ b/.github/workflows/release-crates.yml
@@ -44,7 +44,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- uses: actions/cache@v4
with:
@@ -92,13 +92,13 @@ jobs:
if: runner.os == 'Linux' && !matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Install system dependencies (macOS)
diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml
index 3e1e9e4..59d66dd 100644
--- a/.github/workflows/release-node.yml
+++ b/.github/workflows/release-node.yml
@@ -218,13 +218,13 @@ jobs:
if: runner.os == 'Linux' && !matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml
index 63240ab..71ac658 100644
--- a/.github/workflows/release-python.yml
+++ b/.github/workflows/release-python.yml
@@ -101,11 +101,11 @@ jobs:
working-directory: packages/python
before-script-linux: |
if command -v yum &> /dev/null; then
- yum install -y clang-devel tesseract-devel leptonica-devel openssl-devel pkgconfig perl-IPC-Cmd glibc-devel || true
+ yum install -y tesseract-devel leptonica-devel openssl-devel pkgconfig perl-IPC-Cmd || true
elif command -v apt-get &> /dev/null; then
- apt-get update && apt-get install -y libclang-dev libtesseract-dev libleptonica-dev libssl-dev pkg-config libc6-dev || true
+ apt-get update && apt-get install -y libtesseract-dev libleptonica-dev libssl-dev pkg-config || true
elif command -v apk &> /dev/null; then
- apk add clang-dev tesseract-ocr-dev leptonica-dev openssl-dev pkgconf musl-dev || true
+ apk add tesseract-ocr-dev leptonica-dev openssl-dev pkgconf || true
fi
- name: Copy pdfium dylib into wheel (Unix)
@@ -311,13 +311,13 @@ jobs:
if: runner.os == 'Linux' && !matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev
+ sudo apt-get install -y libtesseract-dev libleptonica-dev
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.use-cross
run: |
sudo apt-get update
- sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Install system dependencies (macOS)
diff --git a/crates/pdfium-sys/Cargo.toml b/crates/pdfium-sys/Cargo.toml
index 28c2b40..b2d4f9d 100644
--- a/crates/pdfium-sys/Cargo.toml
+++ b/crates/pdfium-sys/Cargo.toml
@@ -7,8 +7,12 @@ repository.workspace = true
description = "Raw FFI bindings to PDFium for liteparse"
links = "pdfium"
+[features]
+default = []
+bindgen = ["dep:bindgen"]
+
[build-dependencies]
-bindgen = "0.71"
+bindgen = { version = "0.71", optional = true }
flate2 = "1"
tar = "0.4"
ureq = "3"
diff --git a/crates/pdfium-sys/build.rs b/crates/pdfium-sys/build.rs
index 7e59261..98e3f62 100644
--- a/crates/pdfium-sys/build.rs
+++ b/crates/pdfium-sys/build.rs
@@ -231,25 +231,42 @@ fn copy_dylib_to_target_deps(lib_dir: &Path) {
}
fn run_bindgen(include_dir: &Path) {
- let bindings = bindgen::Builder::default()
- .header("wrapper.h")
- .clang_arg(format!("-I{}", include_dir.display()))
- .allowlist_function("FPDF.*")
- .allowlist_function("FPDFText_.*")
- .allowlist_function("FPDFPage.*")
- .allowlist_function("FPDFLink_.*")
- .allowlist_function("FPDFFont_.*")
- .allowlist_type("FPDF.*")
- .allowlist_type("FS_.*")
- .allowlist_var("FPDF.*")
- .derive_debug(true)
- .derive_default(true)
- .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
- .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!");
+ let out_file = out_path.join("bindings.rs");
+
+ #[cfg(feature = "bindgen")]
+ {
+ let bindings = bindgen::Builder::default()
+ .header("wrapper.h")
+ .clang_arg(format!("-I{}", include_dir.display()))
+ .allowlist_function("FPDF.*")
+ .allowlist_function("FPDFText_.*")
+ .allowlist_function("FPDFPage.*")
+ .allowlist_function("FPDFLink_.*")
+ .allowlist_function("FPDFFont_.*")
+ .allowlist_type("FPDF.*")
+ .allowlist_type("FS_.*")
+ .allowlist_var("FPDF.*")
+ .derive_debug(true)
+ .derive_default(true)
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
+ .generate()
+ .expect("Unable to generate bindings");
+
+ bindings
+ .write_to_file(&out_file)
+ .expect("Couldn't write bindings!");
+ }
+
+ #[cfg(not(feature = "bindgen"))]
+ {
+ let _ = include_dir;
+ let pregenerated = Path::new(env!("CARGO_MANIFEST_DIR")).join("bindings.rs");
+ fs::copy(&pregenerated, &out_file).unwrap_or_else(|e| {
+ panic!(
+ "Failed to copy pre-generated bindings from {}: {e}",
+ pregenerated.display()
+ )
+ });
+ }
}