Skip to content

Commit 23b4110

Browse files
committed
wasm3-sys: Cleanup
1 parent fc60790 commit 23b4110

File tree

2 files changed

+9
-47
lines changed

2 files changed

+9
-47
lines changed

wasm3-sys/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
22
name = "wasm3-sys"
33
version = "0.2.0"
4-
authors = ["Lukas Tobias Wirth <[email protected]>"]
4+
authors = [
5+
"Oasis Protocol Foundation <[email protected]>",
6+
"Lukas Tobias Wirth <[email protected]>"
7+
]
58
edition = "2018"
6-
description = "Raw ffi bindings for wasm3"
7-
homepage = "https://github.com/veykril/wasm3-rs"
8-
repository = "https://github.com/veykril/wasm3-rs"
9+
description = "Raw FFI bindings for wasm3"
910
categories = ["external-ffi-bindings"]
1011
build = "build.rs"
1112
license = "MIT"
1213
links = "wasm3"
1314
include = ["wasm3/source/**/*", "src/**/*", "Cargo.toml", "build.rs"]
1415

1516
[features]
16-
wasi = []
1717
use-32bit-slots = []
1818
floats = []
1919

wasm3-sys/build.rs

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use std::env;
2-
use std::ffi::OsStr;
3-
use std::fmt::Write as _;
4-
use std::fs;
5-
use std::path::{Path, PathBuf};
1+
use std::{env, ffi::OsStr, fs, path::PathBuf};
62

73
static WASM3_SOURCE: &str = "wasm3/source";
84
const WHITELIST_REGEX_FUNCTION: &str = "([A-Z]|m3_).*";
@@ -12,36 +8,12 @@ const PRIMITIVES: &[&str] = &[
128
"f64", "f32", "u64", "i64", "u32", "i32", "u16", "i16", "u8", "i8",
139
];
1410

15-
fn gen_wrapper(out_path: &Path) -> PathBuf {
16-
// TODO: we currently need the field definitions of the structs of wasm3. These aren't exposed
17-
// in the wasm3.h header so we have to generate bindings for more.
18-
let wrapper_file = out_path.join("wrapper.h");
19-
20-
let mut buffer = String::new();
21-
fs::read_dir(WASM3_SOURCE)
22-
.unwrap_or_else(|_| panic!("failed to read {} directory", WASM3_SOURCE))
23-
.filter_map(Result::ok)
24-
.map(|entry| entry.path())
25-
.filter(|path| path.extension().and_then(OsStr::to_str) == Some("h"))
26-
.for_each(|path| {
27-
writeln!(
28-
&mut buffer,
29-
"#include \"{}\"",
30-
path.file_name().unwrap().to_str().unwrap()
31-
)
32-
.unwrap()
33-
});
34-
fs::write(&wrapper_file, buffer).expect("failed to create wasm3 wrapper file");
35-
wrapper_file
36-
}
37-
3811
fn gen_bindings() {
3912
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
4013

41-
let wrapper_file = gen_wrapper(&out_path);
42-
4314
let mut bindgen = bindgen::builder()
44-
.header(wrapper_file.to_str().unwrap())
15+
.header("wasm3/source/wasm3.h")
16+
.header("wasm3/source/m3_env.h")
4517
.use_core()
4618
.ctypes_prefix("cty")
4719
.layout_tests(false)
@@ -69,13 +41,8 @@ fn gen_bindings() {
6941
),
7042
&format!(
7143
"-Dd_m3HasFloat={}",
72-
if cfg!(feature = "floats") {
73-
1
74-
} else {
75-
0
76-
}
44+
if cfg!(feature = "floats") { 1 } else { 0 }
7745
),
78-
"-Dd_m3LogOutput=0",
7946
"-Dd_m3VerboseErrorMessages=0",
8047
"-Iwasm3/source",
8148
]
@@ -101,7 +68,6 @@ fn main() {
10168
);
10269

10370
cfg.cpp(false)
104-
.define("d_m3LogOutput", Some("0"))
10571
.warnings(false)
10672
.extra_warnings(false)
10773
.include(WASM3_SOURCE);
@@ -130,10 +96,6 @@ fn main() {
13096
};
13197
}
13298

133-
if cfg!(feature = "wasi") {
134-
cfg.define("d_m3HasWASI", None);
135-
}
136-
13799
cfg.define(
138100
"d_m3Use32BitSlots",
139101
if cfg!(feature = "use-32bit-slots") {

0 commit comments

Comments
 (0)