11use std:: env;
2- use std:: fs;
32use std:: path:: PathBuf ;
4- use subprocess:: Exec ;
53
64static PROJECT_ROOT : & str = "../../../" ;
75
8- fn write_bindings ( header_path : & PathBuf ) {
9- let header_path_string = String :: from ( header_path. to_string_lossy ( ) ) ;
10-
6+ fn write_bindings ( ) {
117 // The bindgen::Builder is the main entry point
128 // to bindgen, and lets you build up options for
139 // the resulting bindings.
@@ -19,25 +15,14 @@ fn write_bindings(header_path: &PathBuf) {
1915 // .raw_line("#![allow(non_upper_case_globals)]")
2016 // .raw_line("#![allow(non_camel_case_types)]")
2117 // .raw_line("#![allow(non_snake_case)]")
22- . header ( & header_path_string)
23- . allowlist_file ( & header_path_string)
24- . c_naming ( false )
25- . blocklist_type ( "struct_IMAGE_TLS_DIRECTORY" )
26- . blocklist_type ( "struct_PIMAGE_TLS_DIRECTORY" )
27- . blocklist_type ( "struct_IMAGE_TLS_DIRECTORY64" )
28- . blocklist_type ( "struct_PIMAGE_TLS_DIRECTORY64" )
29- . blocklist_type ( "struct__IMAGE_TLS_DIRECTORY64" )
30- . blocklist_type ( "IMAGE_TLS_DIRECTORY" )
31- . blocklist_type ( "PIMAGE_TLS_DIRECTORY" )
32- . blocklist_type ( "IMAGE_TLS_DIRECTORY64" )
33- . blocklist_type ( "PIMAGE_TLS_DIRECTORY64" )
34- . blocklist_type ( "_IMAGE_TLS_DIRECTORY64" )
35- . allowlist_type ( "evt_.*" )
36- . allowlist_function ( "evt_.*" )
37- . allowlist_var ( "evt_.*" )
38- . allowlist_recursively ( false )
39- . layout_tests ( false )
40- . merge_extern_blocks ( true )
18+ . clang_arg ( format ! ( "-I{}" , PathBuf :: from( PROJECT_ROOT ) . join( "lib/include" ) . display( ) ) )
19+ . header ( "./include/wrapper.hpp" )
20+ //.enable_cxx_namespaces()
21+ . allowlist_type ( "Microsoft::Applications::Events::LogManagerProvider" )
22+ . allowlist_recursively ( true )
23+ // STL types must be marked as 'opaque' as bindgen can't handle the internals of these types.
24+ . opaque_type ( "std::(.*)" )
25+ //.blocklist_function("std::*")
4126 // Tell cargo to invalidate the built crate whenever any of the
4227 // included header files changed.
4328 // .wrap_static_fns(true)
@@ -65,20 +50,20 @@ fn main() {
6550 println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
6651 println ! ( "cargo:rustc-link-lib=ClientTelemetry" ) ;
6752
68- // TODO use clang crate instead of invoking CLI directly
69- let header_out = Exec :: cmd ( "clang" )
70- . arg ( "-E" )
71- . arg ( mat_h_location)
72- . arg ( "-D" )
73- . arg ( "HAVE_DYNAMIC_C_LIB" )
74- . capture ( )
75- . expect ( "Failed to open clang process" )
76- . stdout_str ( ) ;
53+ // // TODO use clang crate instead of invoking CLI directly
54+ // let header_out = Exec::cmd("clang")
55+ // .arg("-E")
56+ // .arg(mat_h_location)
57+ // .arg("-D")
58+ // .arg("HAVE_DYNAMIC_C_LIB")
59+ // .capture()
60+ // .expect("Failed to open clang process")
61+ // .stdout_str();
7762
78- let out_dir = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
79- let mat_out_path = out_dir. join ( "mat.out.h" ) ;
63+ // let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
64+ // let mat_out_path = out_dir.join("mat.out.h");
8065
81- fs:: write ( & mat_out_path, header_out) . unwrap ( ) ;
66+ // fs::write(&mat_out_path, header_out).unwrap();
8267
83- write_bindings ( & mat_out_path ) ;
68+ write_bindings ( ) ;
8469}
0 commit comments