25 个版本
0.1.28 | 2023 年 6 月 12 日 |
---|---|
0.1.27 | 2023 年 2 月 1 日 |
0.1.26 | 2022 年 7 月 6 日 |
0.1.23 | 2021 年 7 月 29 日 |
0.1.18 | 2019 年 11 月 19 日 |
314 在 Cargo 插件 中
203 每月下载量
在 cargo-wasi 中使用
59KB
1K SLoC
安装
要安装此 Cargo 子命令,首先您需要 安装 Rust,然后执行以下操作:
$ cargo install cargo-wasi
之后,您可以通过以下方式验证它是否正常工作:
$ cargo wasi --version
使用方法
cargo wasi
子命令是围绕 cargo
子命令的一个薄层包装,为 wasm32-wasi
目标提供优化的默认值。使用 cargo wasi
的方式与使用 cargo
类似。
-
cargo wasi build
— 为 wasi 目标构建代码的调试版本。 -
cargo wasi build --release
— 构建优化后的*.wasm
版本。 -
cargo wasi run
— 执行一个二进制文件。 -
cargo wasi test
— 在wasm32-wasi
中运行测试。 -
cargo wasi bench
— 在wasm32-wasi
中运行基准测试。
通常情况下,如果您原本要执行 cargo foo --flag
,那么您很可能执行 cargo wasi foo --flag
,并且所有内容都将为 wasm32-wasi
目标“正常工作”。
要亲自尝试,请尝试程序的hello-world版本!
$ cargo new wasi-hello-world
Created binary (application) `wasi-hello-world` package
$ cd wasi-hello-world
$ cargo wasi run
Compiling wasi-hello-world v0.1.0 (/code/wasi-hello-world)
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
Running `cargo-wasi target/wasm32-wasi/debug/wasi-hello-world.wasm`
Running `target/wasm32-wasi/debug/wasi-hello-world.wasm`
Hello, world!
或者带有一些测试的库
$ cargo new wasi-hello-world --lib
Created library `wasi-hello-world` package
$ cd wasi-hello-world
$ cargo wasi test
Compiling wasi-hello-world v0.1.0 (/code/wasi-hello-world)
Finished dev [unoptimized + debuginfo] target(s) in 0.19s
Running target/wasm32-wasi/debug/deps/wasi_hello_world-9aa88657c21196a1.wasm
Running `/code/wasi-hello-world/target/wasm32-wasi/debug/deps/wasi_hello_world-9aa88657c21196a1.wasm`
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
许可证
本项目采用Apache 2.0许可证,带有LLVM异常。有关更多详细信息,请参阅[LICENSE]。
贡献
除非您明确表示,否则根据Apache-2.0许可证定义的,您提交给本项目以供包含的任何贡献将被许可如上所述,不附加任何额外条款或条件。
依赖项
~11–24MB
~414K SLoC