mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-20 12:38:50 +00:00
Add Xargo and config and stuff
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oxipng-wasm"
|
name = "test"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Surma <surma@surma.link>"]
|
authors = ["Surma <surma@surma.link>"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
path = "lib.rs"
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
5
codecs/oxipng/Xargo.toml
Normal file
5
codecs/oxipng/Xargo.toml
Normal 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
1
codecs/oxipng/tmp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target
|
||||||
27
codecs/oxipng/tmp/Cargo.toml
Normal file
27
codecs/oxipng/tmp/Cargo.toml
Normal 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"
|
||||||
2
codecs/oxipng/tmp/Xargo.toml
Normal file
2
codecs/oxipng/tmp/Xargo.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[dependencies.std]
|
||||||
|
features = ["wasm_syscall"]
|
||||||
20
codecs/oxipng/tmp/_README.md
Normal file
20
codecs/oxipng/tmp/_README.md
Normal file
@@ -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
|
||||||
10
codecs/oxipng/tmp/lib.rs
Normal file
10
codecs/oxipng/tmp/lib.rs
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user