Skip to content

Commit 62cc1e9

Browse files
committed
Rewrite Rust bindings and use wasm3 0.5.0
1 parent f18e3d4 commit 62cc1e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1391
-2024
lines changed

.github/workflows/ci-audit.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-audit
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push modifies one of the matches files.
7+
push:
8+
paths:
9+
- '**/Cargo.toml'
10+
- '**/Cargo.lock'
11+
12+
jobs:
13+
14+
audit:
15+
# NOTE: This name appears in GitHub's Checks API.
16+
name: audit
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
submodules: true
22+
23+
- uses: actions-rs/audit-check@v1
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-lint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-lint
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
# Or when a pull request event occurs for a pull request against one of the
11+
# matched branches.
12+
pull_request:
13+
branches:
14+
- master
15+
16+
jobs:
17+
18+
lint-rust:
19+
# NOTE: This name appears in GitHub's Checks API.
20+
name: lint-rust
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
with:
26+
submodules: true
27+
28+
- name: Set up Rust
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: nightly
32+
components: rustfmt, clippy
33+
override: true
34+
35+
- name: Clippy check
36+
uses: actions-rs/clippy-check@v1
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
args: --all-features -- -D warnings -D clippy::dbg_macro
40+
41+
- name: Formatting check
42+
uses: actions-rs/cargo@v1
43+
with:
44+
command: fmt
45+
args: -- --check

.github/workflows/ci-test.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-test
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
# Or when a pull request event occurs for a pull request against one of the
11+
# matched branches.
12+
pull_request:
13+
branches:
14+
- master
15+
16+
jobs:
17+
18+
test-rust:
19+
# NOTE: This name appears in GitHub's Checks API.
20+
name: test-rust
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
with:
26+
submodules: true
27+
28+
- name: Set up Rust
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: nightly
32+
components: rustfmt # rustfmt is required for macros tests.
33+
override: true
34+
35+
- name: Unit tests with coverage
36+
uses: actions-rs/[email protected]
37+
with:
38+
version: '0.18.0'
39+
args: '--avoid-cfg-tarpaulin -- --test-threads 1'
40+
41+
- name: Upload to codecov.io
42+
uses: codecov/[email protected]
43+
44+
- name: Archive code coverage results
45+
uses: actions/[email protected]
46+
with:
47+
name: code-coverage-report
48+
path: cobertura.xml
49+
50+
test-rust-sgx:
51+
# NOTE: This name appears in GitHub's Checks API.
52+
name: test-rust-sgx
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v2
57+
with:
58+
submodules: true
59+
60+
- name: Install dependencies
61+
run: |
62+
sudo apt-get update
63+
sudo apt-get install gcc-multilib
64+
65+
- name: Set up Rust
66+
uses: actions-rs/toolchain@v1
67+
with:
68+
toolchain: nightly
69+
components: rustfmt # rustfmt is required for macros tests.
70+
target: x86_64-fortanix-unknown-sgx
71+
override: true
72+
73+
- name: Build for SGX
74+
uses: actions-rs/cargo@v1
75+
with:
76+
command: build
77+
args: --target x86_64-fortanix-unknown-sgx

.github/workflows/rust.yml

Lines changed: 0 additions & 86 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/target
22
Cargo.lock
33
wasm3-sys/wrapper.h
4+
rust-toolchain

CHANGELOG.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

Cargo.toml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
[package]
22
name = "wasm3"
3-
version = "0.1.3"
4-
authors = ["Lukas Tobias Wirth <[email protected]>"]
3+
version = "0.2.0"
4+
authors = [
5+
"Oasis Protocol Foundation <[email protected]>",
6+
"Lukas Tobias Wirth <[email protected]>"
7+
]
58
edition = "2018"
69
description = "Rust bindings for wasm3"
7-
homepage = "https://github.com/Veykril/wasm3-rs"
8-
repository = "https://github.com/Veykril/wasm3-rs"
910
license = "MIT"
10-
readme = "README.md"
1111
categories = ["api-bindings"]
12-
exclude = ["examples/*", "tests/*"]
13-
14-
[features]
15-
default = ["wasi", "std", "use-32bit-slots"]
16-
17-
wasi = ["ffi/wasi"]
18-
std = []
19-
use-32bit-slots = ["ffi/use-32bit-slots"]
2012

2113
[dependencies]
2214
cty = "0.2"
15+
thiserror = "1.0"
16+
impl-trait-for-tuples = "0.2.1"
2317

2418
[dependencies.ffi]
2519
path = "wasm3-sys"
2620
package = "wasm3-sys"
21+
default-features = false
2722

28-
[dev-dependencies]
29-
trybuild = "1.0"
23+
[target.x86_64-fortanix-unknown-sgx.dependencies]
24+
rs-libc = "0.2.3"
3025

31-
[package.metadata.docs.rs]
32-
all-features = true
33-
34-
[workspace]
35-
members = ["wasm3-sys"]
26+
[features]
27+
default = []
28+
floats = ["ffi/floats"]

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2020 Lukas Tobias Wirth
4+
Copyright (c) 2021 Oasis Protocol Foundation
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1819
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1920
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2021
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
22+
SOFTWARE.

README.md

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1 @@
11
# wasm3-rs
2-
3-
![Build](https://github.com/Veykril/wasm3-rs/workflows/Rust/badge.svg?branch=master) ![Tokei](https://tokei.rs/b1/github/veykril/wasm3-rs)
4-
[![Crates.io](https://img.shields.io/crates/v/wasm3.svg)](https://crates.io/crates/wasm3)
5-
[![Docs.rs](https://docs.rs/wasm3/badge.svg)](https://docs.rs/wasm3)
6-
7-
## > wasm3-rs is looking for a maintainer <
8-
9-
Rust wrapper for [WASM3](https://github.com/wasm3/wasm3).
10-
11-
This is currently work in progress and may or may not be entirely sound.
12-
13-
## Sample
14-
15-
A simple [example](./examples/call_wasm.rs) that loads a wasm module and executes an exported function to add two `i64`s together.
16-
17-
```rust
18-
use wasm3::Environment;
19-
use wasm3::Module;
20-
21-
fn main() {
22-
let env = Environment::new().expect("Unable to create environment");
23-
let rt = env
24-
.create_runtime(1024 * 60)
25-
.expect("Unable to create runtime");
26-
let module = Module::parse(&env, &include_bytes!("wasm/wasm_add/wasm_add.wasm")[..])
27-
.expect("Unable to parse module");
28-
29-
let module = rt.load_module(module).expect("Unable to load module");
30-
let func = module
31-
.find_function::<(i64, i64), i64>("add")
32-
.expect("Unable to find function");
33-
println!("Wasm says that 3 + 6 is {}", func.call(3, 6).unwrap())
34-
}
35-
```
36-
37-
## Building
38-
39-
This crate currently does not make use of the cmake project of wasm3, meaning cmake is not required to built this for the time being.
40-
It does however require [Clang 9](https://releases.llvm.org/download.html#9.0.0) to be installed as well as [Bindgen](https://github.com/rust-lang/rust-bindgen), should the `build-bindgen` feature not be set.
41-
42-
## License
43-
44-
Licensed under the MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

examples/call_wasm.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)