summaryrefslogtreecommitdiff
path: root/codegen/bindings.rs
blob: d6b7e0d3f58ff9cae96e6f951d3640b29115d4e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::error::Error;
use std::path::Path;

use bindgen::{CodegenConfig, MacroTypeVariation};

pub fn generate_bindings(dest_file: &Path) -> Result<(), Box<dyn Error>>
{
    println!("cargo:rerun-if-changed=gl.h");

    let bindings = bindgen::Builder::default()
        .header("gl.h")
        .default_macro_constant_type(MacroTypeVariation::Signed)
        .with_codegen_config(CodegenConfig::all() & !CodegenConfig::FUNCTIONS)
        .allowlist_type("GL.*")
        .allowlist_type("_cl_.*")
        .allowlist_var("GL_.*")
        .blocklist_item("GL_Z4.*")
        .blocklist_item("GL_Z6.*")
        .generate()?;

    bindings.write_to_file(dest_file)?;

    Ok(())
}