From 9e19c36b42de0a2230404720d37504f0bf7e6031 Mon Sep 17 00:00:00 2001 From: Surma Date: Thu, 7 Feb 2019 00:28:28 +0000 Subject: [PATCH] Add Xargo and config and stuff --- codecs/oxipng/Cargo.toml | 3 ++- codecs/oxipng/Xargo.toml | 5 +++++ codecs/oxipng/tmp/.gitignore | 1 + codecs/oxipng/tmp/Cargo.toml | 27 +++++++++++++++++++++++++++ codecs/oxipng/tmp/Xargo.toml | 2 ++ codecs/oxipng/tmp/_README.md | 20 ++++++++++++++++++++ codecs/oxipng/tmp/lib.rs | 10 ++++++++++ 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 codecs/oxipng/Xargo.toml create mode 100644 codecs/oxipng/tmp/.gitignore create mode 100644 codecs/oxipng/tmp/Cargo.toml create mode 100644 codecs/oxipng/tmp/Xargo.toml create mode 100644 codecs/oxipng/tmp/_README.md create mode 100644 codecs/oxipng/tmp/lib.rs diff --git a/codecs/oxipng/Cargo.toml b/codecs/oxipng/Cargo.toml index eeb7fece..e7c7d701 100644 --- a/codecs/oxipng/Cargo.toml +++ b/codecs/oxipng/Cargo.toml @@ -1,9 +1,10 @@ [package] -name = "oxipng-wasm" +name = "test" version = "0.1.0" authors = ["Surma "] [lib] +path = "lib.rs" crate-type = ["cdylib", "rlib"] [features] diff --git a/codecs/oxipng/Xargo.toml b/codecs/oxipng/Xargo.toml new file mode 100644 index 00000000..60fbc181 --- /dev/null +++ b/codecs/oxipng/Xargo.toml @@ -0,0 +1,5 @@ +[target.wasm32-unknown-unknown.dependencies] +time = {} + +[target.wasm32-unknown-unknown.dependencies.std] +features = ["wasm_syscall"] diff --git a/codecs/oxipng/tmp/.gitignore b/codecs/oxipng/tmp/.gitignore new file mode 100644 index 00000000..eb5a316c --- /dev/null +++ b/codecs/oxipng/tmp/.gitignore @@ -0,0 +1 @@ +target diff --git a/codecs/oxipng/tmp/Cargo.toml b/codecs/oxipng/tmp/Cargo.toml new file mode 100644 index 00000000..df842ed0 --- /dev/null +++ b/codecs/oxipng/tmp/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "loltest" +version = "0.1.0" +authors = ["Surma "] + +[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" diff --git a/codecs/oxipng/tmp/Xargo.toml b/codecs/oxipng/tmp/Xargo.toml new file mode 100644 index 00000000..5f349062 --- /dev/null +++ b/codecs/oxipng/tmp/Xargo.toml @@ -0,0 +1,2 @@ +[dependencies.std] +features = ["wasm_syscall"] diff --git a/codecs/oxipng/tmp/_README.md b/codecs/oxipng/tmp/_README.md new file mode 100644 index 00000000..32158d69 --- /dev/null +++ b/codecs/oxipng/tmp/_README.md @@ -0,0 +1,20 @@ +I’m trying to activate [the `wasm_syscall` feature][1] in Rust’s 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 diff --git a/codecs/oxipng/tmp/lib.rs b/codecs/oxipng/tmp/lib.rs new file mode 100644 index 00000000..d632314d --- /dev/null +++ b/codecs/oxipng/tmp/lib.rs @@ -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 +}