Add Xargo and config and stuff

This commit is contained in:
Surma
2019-02-07 00:28:28 +00:00
parent cf45520be3
commit 9e19c36b42
7 changed files with 67 additions and 1 deletions

View File

@@ -1,9 +1,10 @@
[package]
name = "oxipng-wasm"
name = "test"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
[lib]
path = "lib.rs"
crate-type = ["cdylib", "rlib"]
[features]

5
codecs/oxipng/Xargo.toml Normal file
View File

@@ -0,0 +1,5 @@
[target.wasm32-unknown-unknown.dependencies]
time = {}
[target.wasm32-unknown-unknown.dependencies.std]
features = ["wasm_syscall"]

1
codecs/oxipng/tmp/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target

View File

@@ -0,0 +1,27 @@
[package]
name = "loltest"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
[lib]
path = "lib.rs"
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.2"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

View File

@@ -0,0 +1,2 @@
[dependencies.std]
features = ["wasm_syscall"]

View File

@@ -0,0 +1,20 @@
Im trying to activate [the `wasm_syscall` feature][1] in Rusts stdlib for WebAssembly.
Here is my `Cargo.toml` and my `Xargo.toml`. But even with this setup the generated wasm file is still hard-coded to panic.
**HELP?**
My current command to compile is:
```
xargo build --target wasm32-unknown-unknown --release
```
If you have [`wasm2wat`][2] installed, you can verify the generate code via
```
wasm2wat target/wasm32-unknown-unknown/release/loltest.wasm | grep -A5 perform::
```
[1]: https://github.com/rust-lang/rust/blob/b139669f374eb5024a50eb13f116ff763b1c5935/src/libstd/sys/wasm/mod.rs#L309
[2]: https://github.com/WebAssembly/wabt

10
codecs/oxipng/tmp/lib.rs Normal file
View File

@@ -0,0 +1,10 @@
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use std::time::{Instant};
#[wasm_bindgen]
pub fn doit() -> u32 {
let start = Instant::now();
start.elapsed().as_secs() as u32
}