1
- use std:: env;
2
- use std:: ffi:: OsStr ;
3
- use std:: fmt:: Write as _;
4
- use std:: fs;
5
- use std:: path:: { Path , PathBuf } ;
1
+ use std:: { env, ffi:: OsStr , fs, path:: PathBuf } ;
6
2
7
3
static WASM3_SOURCE : & str = "wasm3/source" ;
8
4
const WHITELIST_REGEX_FUNCTION : & str = "([A-Z]|m3_).*" ;
@@ -12,36 +8,12 @@ const PRIMITIVES: &[&str] = &[
12
8
"f64" , "f32" , "u64" , "i64" , "u32" , "i32" , "u16" , "i16" , "u8" , "i8" ,
13
9
] ;
14
10
15
- fn gen_wrapper ( out_path : & Path ) -> PathBuf {
16
- // TODO: we currently need the field definitions of the structs of wasm3. These aren't exposed
17
- // in the wasm3.h header so we have to generate bindings for more.
18
- let wrapper_file = out_path. join ( "wrapper.h" ) ;
19
-
20
- let mut buffer = String :: new ( ) ;
21
- fs:: read_dir ( WASM3_SOURCE )
22
- . unwrap_or_else ( |_| panic ! ( "failed to read {} directory" , WASM3_SOURCE ) )
23
- . filter_map ( Result :: ok)
24
- . map ( |entry| entry. path ( ) )
25
- . filter ( |path| path. extension ( ) . and_then ( OsStr :: to_str) == Some ( "h" ) )
26
- . for_each ( |path| {
27
- writeln ! (
28
- & mut buffer,
29
- "#include \" {}\" " ,
30
- path. file_name( ) . unwrap( ) . to_str( ) . unwrap( )
31
- )
32
- . unwrap ( )
33
- } ) ;
34
- fs:: write ( & wrapper_file, buffer) . expect ( "failed to create wasm3 wrapper file" ) ;
35
- wrapper_file
36
- }
37
-
38
11
fn gen_bindings ( ) {
39
12
let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
40
13
41
- let wrapper_file = gen_wrapper ( & out_path) ;
42
-
43
14
let mut bindgen = bindgen:: builder ( )
44
- . header ( wrapper_file. to_str ( ) . unwrap ( ) )
15
+ . header ( "wasm3/source/wasm3.h" )
16
+ . header ( "wasm3/source/m3_env.h" )
45
17
. use_core ( )
46
18
. ctypes_prefix ( "cty" )
47
19
. layout_tests ( false )
@@ -69,13 +41,8 @@ fn gen_bindings() {
69
41
) ,
70
42
& format ! (
71
43
"-Dd_m3HasFloat={}" ,
72
- if cfg!( feature = "floats" ) {
73
- 1
74
- } else {
75
- 0
76
- }
44
+ if cfg!( feature = "floats" ) { 1 } else { 0 }
77
45
) ,
78
- "-Dd_m3LogOutput=0" ,
79
46
"-Dd_m3VerboseErrorMessages=0" ,
80
47
"-Iwasm3/source" ,
81
48
]
@@ -101,7 +68,6 @@ fn main() {
101
68
) ;
102
69
103
70
cfg. cpp ( false )
104
- . define ( "d_m3LogOutput" , Some ( "0" ) )
105
71
. warnings ( false )
106
72
. extra_warnings ( false )
107
73
. include ( WASM3_SOURCE ) ;
@@ -130,10 +96,6 @@ fn main() {
130
96
} ;
131
97
}
132
98
133
- if cfg ! ( feature = "wasi" ) {
134
- cfg. define ( "d_m3HasWASI" , None ) ;
135
- }
136
-
137
99
cfg. define (
138
100
"d_m3Use32BitSlots" ,
139
101
if cfg ! ( feature = "use-32bit-slots" ) {
0 commit comments