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
- Host: GitHub
- URL: https://github.com/movableink/ember-cli-emscripten
- Owner: movableink
- License: mit
- Created: 2015-03-03T21:34:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-04T00:24:46.000Z (about 10 years ago)
- Last Synced: 2024-11-17T10:57:00.942Z (7 months ago)
- Language: JavaScript
- Size: 101 KB
- Stars: 30
- Watchers: 9
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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:
```
#includeusing 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.