0.2.2 • Published 6 years ago
emcc v0.2.2
node-emcc
A simple Emscripten downloader and runner library for node.
Usage
Make sure you have all dependencies listed at http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html#platform-specific-notes
npm install --save-dev emcc
const path = require('path');
const emcc = require('emcc');
const inputFile = path.join(__dirname, 'src', 'test.c');
const outputFile = path.join(__dirname, 'out', 'test.js');
// Create output directory if it does not exist
require('mkdirp').sync(path.dirname(outputFile));
// Run the emscripten compiler
emcc(`-s WASM=1 ${inputFile} -o ${outputFile}`, (err, stdout, stderr) => {
// If there is an error, throw it
if (err != null || stderr.trim() != '') {
console.error(stderr);
throw err;
}
// Log the compiler output
console.log(stdout);
});
License
MIT License. See LICENSE file.