An open API service indexing awesome lists of open source software.

https://github.com/movableink/ember-cli-emscripten

Compile c/c++ inside ember projects using emscripten
https://github.com/movableink/ember-cli-emscripten

Last synced: 6 months ago
JSON representation

Compile c/c++ inside ember projects using emscripten

Awesome Lists containing this project

README

        

# Ember-CLI Emscripten

ember-cli-emscripten allows you to add emscripten-flavored c or c++ code to your ember app, then require the exposed functions and classes.

## Installation

`ember install:addon ember-cli-emscripten`

## Usage

This addon uses emscripten's [embind](http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html) to expose c/c++ functions to javascript. From the emscripten example, saved as `app/compiled/math.cpp` in your ember-cli app:

```
#include

using namespace emscripten;

float lerp(float a, float b, float t) {
return (1 - t) * a + t * b;
}

EMSCRIPTEN_BINDINGS(my_module) {
function("lerp", &lerp);
}
```

ember-cli-emscripten then exports `lerp` via ES6, so you could use it like so:

```
import math from 'ember-app/compiled/math';

math.lerp(1, 2.5, 5)
```

## TODO

* Right now every cpp file that gets compiled to js includes the emscripten runtime. Ideally this should only be included once per project.
* Expose emscripten emcc optimization options.

## License

See LICENSE.