File tree Expand file tree Collapse file tree 7 files changed +95
-1
lines changed Expand file tree Collapse file tree 7 files changed +95
-1
lines changed Original file line number Diff line number Diff line change 19
19
- run : cargo build --no-default-features
20
20
- run : cargo build --target wasm32-wasi
21
21
- run : cargo build --target wasm32-wasi --no-default-features
22
+ - run : cargo build -p wasi-ephemeral
22
23
23
24
rustfmt :
24
25
name : Rustfmt
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ readme = "README.md"
12
12
documentation = " https://docs.rs/wasi"
13
13
14
14
[workspace ]
15
- members = [' crates/generate-raw' ]
15
+ members = [' crates/generate-raw' , ' crates/wasi-ephemeral ' ]
16
16
17
17
[dependencies ]
18
18
# When built as part of libstd
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " wasi-ephemeral"
3
+ version = " 0.0.0"
4
+ publish = false
5
+ authors = [" Bytecode Alliance" ]
6
+ license = " Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
7
+ description = " Experimental WASI API bindings for Rust"
8
+ edition = " 2018"
9
+ categories = [" no-std" , " wasm" ]
10
+ keywords = [" webassembly" , " wasm" ]
11
+ repository = " https://github.com/bytecodealliance/wasi"
12
+
13
+ [build-dependencies ]
14
+ generate-raw = { path = " ../generate-raw" }
15
+
16
+ [features ]
17
+ default = [" std" ]
18
+ std = []
19
+
20
+ [badges ]
21
+ maintenance = { status = " experimental" }
Original file line number Diff line number Diff line change
1
+ This crate contains API bindings for the [ ephemeral
2
+ phase] ( https://github.com/WebAssembly/WASI/blob/master/phases/README.md ) of
3
+ [ WASI] ( https://github.com/WebAssembly/WASI ) . The ephemeral phase exists for
4
+ experimentation prior to snapshotting.
5
+
6
+ This crate will never be released, and should only be used by path dependency
7
+ or git dependency. By default, this crate provides bindings for the ephemeral
8
+ phase from the included git submodule of the [ WASI
9
+ repository] ( https://github.com/WebAssembly/WASI ) , but you can set the
10
+ ` WASI_EPHEMERAL_WITX ` environment variable to the full path to a witx file to
11
+ build bindings for that witx file instead.
12
+
13
+ This crate makes it easier to test bindings to arbitrary witx interfaces. Note
14
+ that WebAssembly runtimes typically do not implement the ephemeral phase of
15
+ WASI, so a WebAssembly program built against the default wasi-ephemeral may not
16
+ load. Instead, for development, you may want to build with
17
+ ` WASI_EPHEMERAL_WITX ` pointing to an edited version of the latest snapshot, and
18
+ a correspondingly modified version of a WebAssembly runtime.
Original file line number Diff line number Diff line change
1
+ use std:: { env, fs:: File , io:: Write , path:: PathBuf } ;
2
+
3
+ fn main ( ) {
4
+ let out_path: PathBuf = env:: var_os ( "OUT_DIR" ) . unwrap ( ) . into ( ) ;
5
+ let mut f = File :: create ( out_path. join ( "lib_generated.rs" ) ) . unwrap ( ) ;
6
+ const WASI_EPHEMERAL_WITX : & str =
7
+ "../generate-raw/WASI/phases/ephemeral/witx/wasi_ephemeral_preview.witx" ;
8
+ let witx_path: PathBuf = env:: var_os ( "WASI_EPHEMERAL_WITX" )
9
+ . unwrap_or_else ( || WASI_EPHEMERAL_WITX . into ( ) )
10
+ . into ( ) ;
11
+ let out = generate_raw:: generate ( & witx_path) ;
12
+ write ! ( f, "{}" , out) . unwrap ( ) ;
13
+ println ! ( "cargo:rerun-if-env-changed=WASI_EPHEMERAL_WITX" ) ;
14
+ println ! ( "cargo:rerun-if-changed={}" , witx_path. display( ) ) ;
15
+ println ! (
16
+ "cargo:rerun-if-changed={}" ,
17
+ witx_path. with_file_name( "typenames.witx" ) . display( ) ,
18
+ ) ;
19
+ // TODO: Account for changes in use directives.
20
+ }
Original file line number Diff line number Diff line change
1
+ ../../../src/error.rs
Original file line number Diff line number Diff line change
1
+ //! Raw API bindings to the WebAssembly System Interface (WASI)
2
+ //!
3
+ //! This crate provides Rust API bindings to WASI APIs. All WASI APIs are
4
+ //! exported from this crate and provided with the appropriate type signatures.
5
+ //! This crate is entirely procedurally generated from the `*.witx` files that
6
+ //! describe the WASI API.
7
+ //!
8
+ //! # WASI API Version
9
+ //!
10
+ //! The WASI API is evolving over time. It is both gaining new features as well
11
+ //! as tweaking the ABI of existing features. As a result it's important to
12
+ //! understand what version of this crate you're using and how it relates to
13
+ //! the WASI version of the spec.
14
+ //!
15
+ //! The WASI specification is organized into phases where there is a snapshot
16
+ //! at any one point in time describing the current state of the specification.
17
+ //! This crate implements the latest "ephemeral" version, not yet snapshotted.
18
+ //!
19
+ //! This crate will never be released, and should only be used by path
20
+ //! dependency or git dependency.
21
+ //!
22
+ //! # Crate Features
23
+ //!
24
+ //! This crate supports one feature, `std`, which implements the standard
25
+ //! `Error` trait for the exported [`Error`] type in this crate. This is
26
+ //! enabled by default but can be disabled to make the library `no_std`
27
+ //! compatible.
28
+
29
+ #![ no_std]
30
+
31
+ mod error;
32
+
33
+ include ! ( concat!( env!( "OUT_DIR" ) , "/lib_generated.rs" ) ) ;
You can’t perform that action at this time.
0 commit comments