1
1
use std:: env;
2
- use std:: fs;
3
2
use std:: path:: PathBuf ;
4
- use subprocess:: Exec ;
5
3
6
4
static PROJECT_ROOT : & str = "../../../" ;
7
5
8
- fn write_bindings ( header_path : & PathBuf ) {
9
- let header_path_string = String :: from ( header_path. to_string_lossy ( ) ) ;
10
-
6
+ fn write_bindings ( ) {
11
7
// The bindgen::Builder is the main entry point
12
8
// to bindgen, and lets you build up options for
13
9
// the resulting bindings.
@@ -19,25 +15,14 @@ fn write_bindings(header_path: &PathBuf) {
19
15
// .raw_line("#![allow(non_upper_case_globals)]")
20
16
// .raw_line("#![allow(non_camel_case_types)]")
21
17
// .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::*")
41
26
// Tell cargo to invalidate the built crate whenever any of the
42
27
// included header files changed.
43
28
// .wrap_static_fns(true)
@@ -65,20 +50,20 @@ fn main() {
65
50
println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
66
51
println ! ( "cargo:rustc-link-lib=ClientTelemetry" ) ;
67
52
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();
77
62
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");
80
65
81
- fs:: write ( & mat_out_path, header_out) . unwrap ( ) ;
66
+ // fs::write(&mat_out_path, header_out).unwrap();
82
67
83
- write_bindings ( & mat_out_path ) ;
68
+ write_bindings ( ) ;
84
69
}
0 commit comments