emscripten-sdk-npm

0.3.2 • Public • Published

emscripten-sdk

test-branch emscripten-sdk mit-license

An NPM wrapper for the Emscripten SDK.

This package installs the Emscripten compiler and provides a command line and a JS interface to use in your build scripts.

You may install one of these two packages:

  • emscripten-sdk -- Control the SDK version via the NPM package version. Recommended.
  • emscripten-sdk-npm -- Control the SDK version via CLI/API parameters. For advanced use.

Command line usage

npx emsdk-checkout
# To update SDK tags, run both `npx emsdk-pull` and `npx emsdk update-tags`
npx emsdk install <version>
npx emsdk activate <version>
npx emsdk-run emcc test/test.c -o test/test.html

The version parameter is not required when using the emscripten-sdk package.

JavaScript usage

const emsdk = require('emsdk-npm');

emsdk.checkout()
.then(() => emsdk.update())
.then(() => emsdk.install(version))
.then(() => emsdk.activate(version))
.then(() => emsdk.run(
    'emcc',
    [
        // Arguments
        'test/test.c', '-o', 'test/test.html'
    ], 
    { 
        // child_process.spawn options, e.g., cwd
    }
))
.catch((err) => {
    // handle err...
});

The JS interface will skip installing the SDK and version if they already exist.

The version parameter is not required when using the emscripten-sdk package.

Install

npm install --save-dev emscripten-sdk

Before you install this package, you must install Python 3.6+ on your system. You may download it at python.org or your OS's package manager.

By default, the SDK is installed into your node_modules tree. You may specify a custom path by modifying your NPM config via one of the commands below. Do this before you install the package:

Action Command
Save the path to your project .npmrc npm config --userconfig "/your/project/root/.npmrc" set emsdk "/your/absolute/custom/path"
Save the path to your user .npmrc npm config set emsdk "/your/absolute/custom/path"
Set an environment variable set NPM_CONFIG_EMSDK=/your/absolute/custom/path
Use a config argument to NPM temporarily npm [command] --emsdk="/your/absolute/custom/path"

Version selection

If you install the emscripten-sdk package, then the Emscripten version is selected via the NPM package version. Change the version you need by editing your package.json.

For example, to force version 1.40.1, you specify the NPM tag as sdk-1.40.1. On the command line:

npm install --save-dev emscripten-sdk@sdk-1.40.1

You may only specify single versions this way. You may not specify version ranges. If you do not specify a version, then the latest version will be selected.

If you install the emscripten-sdk-npm package, then you will specify the version parameter in the command line and JS API. To force version 1.40.1, you specify 1.40.1. To select the most recent version, you specify latest.

License

MIT License.

Package Sidebar

Install

npm i emscripten-sdk-npm

Weekly Downloads

5

Version

0.3.2

License

MIT

Unpacked Size

42.9 kB

Total Files

19

Last publish

Collaborators

  • devappd