GithubHelp home page GithubHelp logo

dyu / cargo-wasi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bytecodealliance/cargo-wasi

0.0 1.0 0.0 836 KB

A lightweight Cargo subcommand to build Rust code for the `wasm32-wasi` target

Home Page: https://bytecodealliance.github.io/cargo-wasi/

License: Apache License 2.0

Rust 100.00%

cargo-wasi's Introduction

cargo wasi

A Bytecode Alliance project

A lightweight Cargo subcommand to build code for the wasm32-wasi target.

Crates.io version Download docs.rs docs

Installation

To install this Cargo subcommand, first you'll want to install Rust and then you'll execute:

$ cargo install cargo-wasi

After that you can verify it works via:

$ cargo wasi --version

Read more about installation in the guide!

Usage

The cargo wasi subcommand is a thin wrapper around cargo subcommands, providing optimized defaults for the wasm32-wasi target. Using cargo wasi looks very similar to using cargo:

  • cargo wasi build — build your code in debug mode for the wasi target.

  • cargo wasi build --release — build the optimized version of your *.wasm.

  • cargo wasi run — execute a binary.

  • cargo wasi test — run your tests in wasm32-wasi.

  • cargo wasi bench — run your benchmarks in wasm32-wasi.

In general, if you'd otherwise execute cargo foo --flag you can likely execute cargo wasi foo --flag and everything will "just work" for the wasm32-wasi target.

To give it a spin yourself, try out the hello-world versions of programs!

$ 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!

Or a library with some tests:

$ 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

Read more about cargo wasi usage in the guide!

License

This project is license under the Apache 2.0 license with the LLVM exception. See [LICENSE] for more details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

See the contributing section of the guide to start hacking on cargo wasi!

cargo-wasi's People

Contributors

alexcrichton avatar chenks12138 avatar dependabot-preview[bot] avatar fitzgen avatar ibaryshnikov avatar jeffcharles avatar kubkon avatar markmccaskey avatar pchickey avatar piotrsikora avatar smndtrl avatar tschneidereit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.