sys binaryen-sys

Bindings to the binaryen library

6 releases (breaking)

0.6.0 Jan 4, 2019
0.5.0 Oct 19, 2018
0.4.0 Aug 16, 2018
0.3.0 Jan 19, 2018
0.1.0 Sep 3, 2017

#27 in #webassembly

Download history 27/week @ 2018-11-15 46/week @ 2018-11-22 64/week @ 2018-11-29 8/week @ 2018-12-06 13/week @ 2018-12-13 42/week @ 2018-12-20 9/week @ 2018-12-27 30/week @ 2019-01-03 9/week @ 2019-01-10 12/week @ 2019-01-17 10/week @ 2019-01-24 15/week @ 2019-01-31 2/week @ 2019-02-07 4/week @ 2019-02-14 3/week @ 2019-02-21

128 downloads per month
Used in 2 crates (1 directly)

Apache-2.0

4.5MB
33K SLoC

C++ 29K SLoC // 0.2% comments Python 2.5K SLoC // 0.1% comments JavaScript 1.5K SLoC // 0.0% comments Shell 605 SLoC // 0.1% comments Rust 133 SLoC // 0.0% comments

binaryen-rs

Build Status crates.io docs.rs

Binaryen bindings for Rust. These bindings wrap binaryen C API very closly and at times might be not very idiomatic. For example, binaryen can abort your program if used incorrectly.

With Binaryen you can create optimized WebAssembly modules.

For example what you can create with Binaryen you can check out DEMO*. Yes, this is CHIP-8 roms compiled straight to the WebAssembly. See emchipten test bed for this project.

(*) Modern browser required

Example

extern crate binaryen;

use binaryen::*;

fn main() {
    let module = Module::new();

    let params = &[ValueTy::I32, ValueTy::I32];
    let iii = module.add_fn_type(Some("iii"), params, Ty::I32);

    let x = module.get_local(0, ValueTy::I32);
    let y = module.get_local(1, ValueTy::I32);
    let add = module.binary(BinaryOp::AddI32, x, y);

    let _adder = module.add_fn("adder", &iii, &[], add);

    assert!(module.is_valid());

    module.print();
}

This example will print:

(module
 (type $iii (func (param i32 i32) (result i32)))
 (memory $0 0)
 (func $adder (type $iii) (param $0 i32) (param $1 i32) (result i32)
  (i32.add
   (get_local $0)
   (get_local $1)
  )
 )
)

No runtime deps

  • build build.rs
  • build bindgen 0.30
  • build cc 1.0
  • build cmake 0.1.25