Skip to content

Commit

Permalink
Merge pull request #104 from second-state/release/wasmedge_0.14.x
Browse files Browse the repository at this point in the history
Release/wasmedge 0.14.x
  • Loading branch information
L-jasmine authored Jun 3, 2024
2 parents 75ef77b + 2f16a58 commit 8e376ce
Show file tree
Hide file tree
Showing 24 changed files with 909 additions and 675 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci-build-release-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ concurrency:

on:
push:
branches:
- '!bump/**'
paths-ignore:
- "**/*.md"
- ".github/workflows/standalone.yml"
Expand All @@ -23,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: wasmedge/wasmedge:ubuntu-build-clang

Expand Down Expand Up @@ -83,7 +85,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: fedora:latest

Expand Down Expand Up @@ -147,7 +149,7 @@ jobs:
strategy:
matrix:
os: [macos-12, macos-13]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]

steps:
- name: Checkout sources
Expand Down Expand Up @@ -187,7 +189,7 @@ jobs:
runs-on: windows-2022
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
env:
WASMEDGE_DIR: ${{ github.workspace }}\WasmEdge
WASMEDGE_BUILD_DIR: ${{ github.workspace }}\WasmEdge\build
Expand Down Expand Up @@ -218,14 +220,14 @@ jobs:
- name: Build WasmEdge with Release mode
working-directory: WasmEdge
run: |
git checkout $(git describe --abbrev=0)
git checkout $(git tag -l --sort=-version:refname | Where-Object { $_ -match '^0.[0-9][0-9].[0-9]$' } | Select-Object -First 1)
$vsPath = (vswhere -latest -property installationPath)
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
$llvm = "LLVM-13.0.1-win64.zip"
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm
$llvm = "LLVM-17.0.6-win64-MultiThreadedDLL.zip"
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-17.0.6/LLVM-17.0.6-win64-MultiThreadedDLL.zip -o $llvm
Expand-Archive -Path $llvm
$llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm"
$llvm_dir = "$pwd\\LLVM-17.0.6-win64-MultiThreadedDLL\\LLVM-17.0.6-win64\\lib\\cmake\\llvm"
$Env:CC = "clang-cl"
$Env:CXX = "clang-cl"
$cmake_sys_version = "10.0.19041.0"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: wasmedge/wasmedge:ubuntu-build-clang

Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: fedora:latest

Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
strategy:
matrix:
os: [macos-12, macos-13]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]

steps:
- name: Checkout sources
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
runs-on: windows-2022
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
env:
WASMEDGE_DIR: ${{ github.workspace }}\WasmEdge
WASMEDGE_BUILD_DIR: ${{ github.workspace }}\WasmEdge\build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-static-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: wasmedge/wasmedge:ubuntu-build-clang

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]

steps:
- name: Checkout WasmEdge Rust SDK
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]

steps:
- name: Checkout WasmEdge Rust SDK
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
strategy:
matrix:
os: [macos-12, macos-13]
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]

steps:
- name: Checkout sources
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.75, 1.74, 1.73]
rust: [1.78, 1.77, 1.76]
container:
image: fedora:latest

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"
name = "wasmedge-sdk"
readme = "README.md"
repository = "https://github.com/WasmEdge/wasmedge-rust-sdk"
version = "0.13.5-newapi"
version = "0.14.0"

[dependencies]
anyhow = "1.0"
Expand All @@ -17,15 +17,15 @@ num-derive = "0.3"
num-traits = "0.2"
thiserror = "1.0.30"
wasmedge-macro.workspace = true
wasmedge-sys = { path = "crates/wasmedge-sys", version = "0.18.0", default-features = false }
wasmedge-sys = { path = "crates/wasmedge-sys", version = "0.19.0", default-features = false }
wasmedge-types.workspace = true

[workspace.dependencies]
async-wasi = { path = "crates/async-wasi", version = "0.2.0" }
cfg-if = "1.0.0"
parking_lot = "0.12.1"
wasmedge-macro = { path = "crates/wasmedge-macro", version = "0.6" }
wasmedge-types = { path = "crates/wasmedge-types", version = "0.5" }
wasmedge-types = { path = "crates/wasmedge-types", version = "0.6" }
wat = "1.0"

[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmedge-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ links = "wasmedge"
name = "wasmedge-sys"
readme = "README.md"
repository = "https://github.com/WasmEdge/wasmedge-rust-sdk"
version = "0.18.1"
version = "0.19.0"

[dependencies]
log = "0.4"
Expand Down
5 changes: 5 additions & 0 deletions crates/wasmedge-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ fn main() {
let success = std::process::Command::new(bindgen_path)
.arg("--no-prepend-enum-name") // The API already prepends the name.
.arg("--dynamic-link-require-all")
.arg("--allowlist-item")
.arg("WasmEdge.*")
.arg("--no-layout-tests")
.arg("--formatter=none")
.arg("-o")
.arg(out_file)
Expand All @@ -136,6 +139,8 @@ fn main() {
.clang_arg(format!("-I{inc_dir}"))
.prepend_enum_name(false)
.dynamic_link_require_all(true)
.allowlist_item("WasmEdge.*")
.layout_tests(false)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("failed to generate bindings")
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmedge-sys/src/ast_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'module> ImportType<'module> {
false => {
// get the element type
let elem_ty = unsafe { ffi::WasmEdge_TableTypeGetRefType(ctx_tab_ty) };
let elem_ty: RefType = elem_ty.into();
let elem_ty = RefType::from(ValType::from(elem_ty));

// get the limit
let limit = unsafe { ffi::WasmEdge_TableTypeGetLimit(ctx_tab_ty) };
Expand Down Expand Up @@ -317,7 +317,7 @@ impl<'module> ExportType<'module> {
false => {
// get the element type
let elem_ty = unsafe { ffi::WasmEdge_TableTypeGetRefType(ctx_tab_ty) };
let elem_ty: RefType = elem_ty.into();
let elem_ty = RefType::from(ValType::from(elem_ty));

// get the limit
let limit = unsafe { ffi::WasmEdge_TableTypeGetLimit(ctx_tab_ty) };
Expand Down
31 changes: 22 additions & 9 deletions crates/wasmedge-sys/src/async/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ impl AsMut<Function> for AsyncFunction {
mod tests {
use super::*;
use crate::{
instance::function::AsFunc, r#async::fiber::AsyncState, types::WasmValue, Executor,
instance::function::AsFunc,
r#async::{fiber::AsyncState, module::AsyncImportObject},
types::WasmValue,
AsInstance, Executor,
};

use wasmedge_types::{error::CoreExecutionError, FuncType, ValType};
Expand All @@ -147,7 +150,7 @@ mod tests {
_s: Vec<S>,
}

let mut data: Data<i32, &str> = Data {
let data: Data<i32, &str> = Data {
_x: 12,
_y: "hello".to_string(),
_v: vec![1, 2, 3],
Expand All @@ -164,19 +167,19 @@ mod tests {
println!("Rust: Entering Rust function real_add");

if input.len() != 2 {
return Err(CoreError::Execution(CoreExecutionError::FuncTypeMismatch));
return Err(CoreError::Execution(CoreExecutionError::FuncSigMismatch));
}

let a = if input[0].ty() == ValType::I32 {
input[0].to_i32()
} else {
return Err(CoreError::Execution(CoreExecutionError::FuncTypeMismatch));
return Err(CoreError::Execution(CoreExecutionError::FuncSigMismatch));
};

let b = if input[1].ty() == ValType::I32 {
input[1].to_i32()
} else {
return Err(CoreError::Execution(CoreExecutionError::FuncTypeMismatch));
return Err(CoreError::Execution(CoreExecutionError::FuncSigMismatch));
};

tokio::time::sleep(std::time::Duration::from_millis(300)).await;
Expand All @@ -189,13 +192,19 @@ mod tests {
})
}

let mut import_module = AsyncImportObject::create("test_module", Box::new(data)).unwrap();

// create a FuncType
let func_ty = FuncType::new(vec![ValType::I32; 2], vec![ValType::I32]);
// create a host function
let result =
AsyncFunction::create_async_func(&func_ty, real_add::<Data<i32, &str>>, &mut data, 0);
let result = AsyncFunction::create_async_func(
&func_ty,
real_add::<Data<i32, &str>>,
import_module.get_host_data_mut(),
0,
);
assert!(result.is_ok());
let mut host_func = result.unwrap();
let host_func = result.unwrap();

// get func type
let result = host_func.ty();
Expand All @@ -210,17 +219,21 @@ mod tests {
assert_eq!(ty.returns_len(), 1);
assert_eq!(ty.returns(), &[ValType::I32]);

import_module.add_async_func("add", host_func);

// run this function
let result = Executor::create(None, None);
assert!(result.is_ok());
let mut executor = result.unwrap();

let mut add_func = import_module.get_func_mut("add").unwrap();

let async_state = AsyncState::new();

let result = executor
.call_func_async(
&async_state,
host_func.as_mut(),
&mut add_func,
vec![WasmValue::from_i32(1), WasmValue::from_i32(2)],
)
.await;
Expand Down
Loading

0 comments on commit 8e376ce

Please sign in to comment.