pdfium-render 0.4.0

A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
// Copyright 2021 pdfium-sys Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

// AJRC - 3/1/22 - adjusted from pdfium-sys version by removing explicit linking to
// system-provided pdfium. We still want the bindings generated by rust-bindgen,
// since they provide various constants that are useful, but we will load functions
// dynamically at runtime using libloading.

extern crate bindgen;

fn main() {
    // Tell cargo to invalidate the built crate whenever the wrapper changes
    println!("cargo:rerun-if-changed=wrapper.h");

    let bindings = bindgen::Builder::default()
        // The input header we would like to generate
        // bindings for.
        .header("wrapper.h")
        // Tell cargo to invalidate the built crate whenever any of the
        // included header files changed.
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        // Try to keep original comments for docs
        .clang_args(
            [
                "-fretain-comments-from-system-headers",
                "-fparse-all-comments",
            ]
            .iter(),
        )
        .generate_comments(true)
        // Finish the builder and generate the bindings.
        .generate()
        // Unwrap the Result and panic on failure.
        .expect("Unable to generate bindings");

    // Write the bindings to the src/bindgen.rs file.
    let out_path = std::path::PathBuf::from("src");

    bindings
        .write_to_file(out_path.join("bindgen.rs"))
        .expect("Couldn't write bindings!");
}