File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change
1
+ # witx-bindgen
2
+
3
+ Generate Rust code matching a witx interface.
4
+
5
+ ### Use
6
+
7
+ ```
8
+ cargo run [path to witx file]
9
+ ```
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ use std::env;
2
2
use std:: path:: PathBuf ;
3
3
4
4
fn main ( ) {
5
- let wasi_dir: PathBuf = env:: args_os ( ) . nth ( 1 ) . unwrap ( ) . into ( ) ;
6
- let witx_path = wasi_dir. join ( "phases/snapshot/witx/wasi_snapshot_preview1.witx" ) ;
5
+ let witx_path: PathBuf = env:: args_os ( ) . nth ( 1 ) . unwrap ( ) . into ( ) ;
7
6
print ! ( "{}" , witx_bindgen:: generate( & [ witx_path] ) ) ;
8
7
}
Original file line number Diff line number Diff line change 1
1
#[ test]
2
2
fn assert_same_as_src ( ) {
3
3
let actual = include_str ! ( "../../../src/lib_generated.rs" ) ;
4
- let expected =
5
- witx_bindgen:: generate ( & [ "WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx" ] ) ;
4
+ let witx_path = "WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx" ;
5
+ let expected = witx_bindgen:: generate ( & [ witx_path ] ) ;
6
6
if actual == expected {
7
7
return ;
8
8
}
9
9
panic ! (
10
10
"
11
11
12
- the generate `raw.rs` does not match the actual source `raw.rs`, it's
12
+ the generated `raw.rs` does not match the actual source `raw.rs`, it's
13
13
recommended to run this command from the root of the repository:
14
14
15
- cargo run -p witx-bindgen crates/witx-bindgen/WASI > src/lib_generated.rs
15
+ cargo run -p witx-bindgen crates/witx-bindgen/{} > src/lib_generated.rs
16
16
17
- "
17
+ " ,
18
+ witx_path
18
19
) ;
19
20
}
You can’t perform that action at this time.
0 commit comments