Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from wasmi to wasmer #5

Merged
merged 24 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e6885a0
feat(extension) Plug wasmer.
Hywan Mar 6, 2019
4dd4e9d
feat(extension) Rename the library.
Hywan Mar 8, 2019
dcd3cbb
chore(extension) Clean up everything. Fresh restart.
Hywan Mar 8, 2019
55bd78b
feat(extension) Restore the `WASM_SIGNATURE_TYPE_*` constant.
Hywan Mar 8, 2019
8c2c7ff
feat(extension) Restore the `wasm_read_bytes` function.
Hywan Mar 8, 2019
75399e3
feat(extension) Remove the `wasm_new_runtime` function.
Hywan Mar 8, 2019
6330cf3
feat(extension) Restore the `wasm_new_instance` function.
Hywan Mar 8, 2019
4192b9a
feat(extension) Restore the `wasm_invoke_arguments_builder`.
Hywan Mar 8, 2019
a0d0edb
feat(extension) Restore the `wasm_function_arguments_builder_add_i64`.
Hywan Mar 8, 2019
cecbe2e
feat(extension) Restore the `wasm_function_arguments_builder_add_f32`…
Hywan Mar 8, 2019
efdb0b8
feat(extension) Restore the `wasm_function_arguments_builder_add_f64`…
Hywan Mar 8, 2019
4a9e889
feat(extension) Add the `wasm_value` function.
Hywan Mar 8, 2019
5203780
feat(extension) Remove all the `wasm_function_arguments*` functions.
Hywan Mar 8, 2019
4f1db79
feat(extension) Restore the `wasm_invoke_function`.
Hywan Mar 8, 2019
d9af936
fix(extension) Fix the `wasm_invoke_function` signature declaration.
Hywan Mar 8, 2019
c734b80
feat(extension) Rename `WASM_SIGNATURE_TYPE_*` to `WASM_TYPE_*`.
Hywan Mar 8, 2019
5417e39
doc(examples) Add the `raw.php` example.
Hywan Mar 8, 2019
db7b290
feat(extension) Restore the `wasm_get_function_signature` function.
Hywan Mar 11, 2019
bdab8f2
feat(extension) Better reflections, partially restore the imported fu…
Hywan Mar 11, 2019
3557fcb
feat(extension) Rename `struct foo` to `struct wasm_instance_context_…
Hywan Mar 12, 2019
eeaa504
feat(extension) Rewrite from C to C++.
Hywan Mar 12, 2019
56f028a
fix(extension) Remove the import functions API for now.
Hywan Mar 12, 2019
22abbbb
chore(extension) Remove the `wasmer.hh` file.
Hywan Mar 12, 2019
2ba7a86
chore(examples) Remove a debugging file.
Hywan Mar 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Cargo.lock
composer.lock
target/
vendor/
/target/
/vendor/
/extension/wasmer.hh
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "php-ext-wasm"
version = "0.1.0"
version = "0.2.0"
authors = ["Ivan Enderlin <ivan.enderlin@hoa-project.net>"]
edition = "2018"

[lib]
crate-type = ["dylib", "staticlib"]

[dependencies]
wasmi = "^0.4.2"
wasmer-runtime-c-api = { version = "^0.2.1" }

[build-dependencies]
cbindgen = "^0.6.0"
walkdir = "2.2"

[patch.crates-io]
wasmer-runtime-c-api = { path = "/Users/hywan/Development/Wasmer/wasmer/lib/runtime-c-api/" }
55 changes: 49 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
extern crate cbindgen;
extern crate walkdir;

use std::env;
use core::cmp::Ordering;
use std::{env::var, fs::copy, path::PathBuf};
use walkdir::{DirEntry, WalkDir};

fn is_hidden(entry: &DirEntry) -> bool {
entry
.file_name()
.to_str()
.map(|string| string.starts_with("."))
.unwrap_or(false)
}

fn last_modified_first(a: &DirEntry, b: &DirEntry) -> Ordering {
if let Ok(a_system_time) = a.metadata().unwrap().modified() {
if let Ok(b_system_time) = b.metadata().unwrap().modified() {
a_system_time.cmp(&b_system_time)
} else {
Ordering::Greater
}
} else {
Ordering::Less
}
}

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let out_directory = var("OUT_DIR").expect("The `OUT_DIR` environment variable is not found.");
let mut build_directory = PathBuf::from(&out_directory);
assert!(build_directory.pop(), "`OUT_DIR` is invalid.");
assert!(build_directory.pop(), "`OUT_DIR` is invalid.");

let mut walker = WalkDir::new(&build_directory)
.sort_by(last_modified_first)
.into_iter()
.filter_entry(|entry| !is_hidden(entry))
.filter_map(|entry| entry.ok())
.filter(|entry| entry.metadata().is_ok())
.filter(|entry| entry.file_name().to_string_lossy() == "wasmer.hh");

if let Some(entry) = walker.next() {
let cargo_directory = var("CARGO_MANIFEST_DIR")
.expect("The `CARGO_MANIFEST_DIR` environment variable is not found.");
let mut header_destination = PathBuf::from(&cargo_directory);
header_destination.push("extension");
header_destination.push("wasmer");
header_destination.set_extension("hh");

cbindgen::generate(crate_dir)
.expect("Unable to generate C bindings.")
.write_to_file("headers/php-ext-wasm.h");
copy(entry.path(), header_destination)
.expect("Cannot copy the `wasmer.hh` C header file from `wasmer-runtime-c-api`.");
} else {
panic!("The `wasmer.hh` file is not found.");
}
}
9 changes: 0 additions & 9 deletions cbindgen.toml

This file was deleted.

4 changes: 2 additions & 2 deletions extension/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if test "$PHP_WASM" != "no"; then
AC_DEFINE(HAVE_WASM, 1, [ Have wasm support ])

PHP_SUBST(WASM_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(php_ext_wasm, ., WASM_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(wasmer_runtime_c_api, ., WASM_SHARED_LIBADD)

PHP_NEW_EXTENSION(wasm, wasm.c, $ext_shared)
PHP_NEW_EXTENSION(wasm, wasm.cc, $ext_shared)
fi
1 change: 0 additions & 1 deletion extension/libphp_ext_wasm.a

This file was deleted.

1 change: 1 addition & 0 deletions extension/libwasmer_runtime_c_api.a
1 change: 0 additions & 1 deletion extension/php-ext-wasm.h

This file was deleted.

2 changes: 1 addition & 1 deletion extension/php_wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
extern zend_module_entry wasm_module_entry;
# define phpext_wasm_ptr &wasm_module_entry

# define PHP_WASM_VERSION "0.1.0"
# define PHP_WASM_VERSION "0.2.0"

# if defined(ZTS) && defined(COMPILE_DL_WASM)
ZEND_TSRMLS_CACHE_EXTERN()
Expand Down
Loading