diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/pkcs11-bindings/build.rs | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/pkcs11-bindings/build.rs')
-rw-r--r-- | third_party/rust/pkcs11-bindings/build.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/third_party/rust/pkcs11-bindings/build.rs b/third_party/rust/pkcs11-bindings/build.rs new file mode 100644 index 0000000000..63430147ae --- /dev/null +++ b/third_party/rust/pkcs11-bindings/build.rs @@ -0,0 +1,56 @@ +/* -*- Mode: rust; rust-indent-offset: 4 -*- */ + +extern crate bindgen; + +use bindgen::callbacks::*; +use bindgen::*; + +use std::env; +use std::path::PathBuf; + +#[derive(Debug)] +struct PKCS11TypesParseCallbacks; + +impl ParseCallbacks for PKCS11TypesParseCallbacks { + fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> { + if name == "CK_TRUE" || name == "CK_FALSE" { + Some(IntKind::U8) + } else { + Some(IntKind::ULong) + } + } +} + +fn main() { + println!("cargo:rerun-if-changed=wrapper.h"); + + let bindings = Builder::default() + .header("wrapper.h") + .allowlist_function("C_GetFunctionList") + .allowlist_type("CK_RSA_PKCS_PSS_PARAMS") + .allowlist_type("CK_OBJECT_CLASS") + .allowlist_type("CK_KEY_TYPE") + .allowlist_type("CK_C_INITIALIZE_ARGS_PTR") + .allowlist_var("CK_TRUE") + .allowlist_var("CK_FALSE") + .allowlist_var("CK_UNAVAILABLE_INFORMATION") + .allowlist_var("CK_EFFECTIVELY_INFINITE") + .allowlist_var("CK_INVALID_HANDLE") + .allowlist_var("CKA_.*") + .allowlist_var("CKC_.*") + .allowlist_var("CKD_.*") + .allowlist_var("CKF_.*") + .allowlist_var("CKK_.*") + .allowlist_var("CKM_.*") + .allowlist_var("CKO_.*") + .allowlist_var("CKR_.*") + .derive_default(true) + .parse_callbacks(Box::new(PKCS11TypesParseCallbacks)) + .generate() + .expect("Unable to generate bindings"); + + let out_path = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR should be set in env")); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} |