Skip to content

Commit

Permalink
Enable the asmjs build using the new module system
Browse files Browse the repository at this point in the history
  • Loading branch information
rajsite committed Sep 27, 2018
1 parent aca2198 commit 75af816
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ before_script:
- (source make-it/travis-support/setup-env.sh && make vjs)
- (source make-it/travis-support/setup-env.sh && make vjs BUILD=debug)
- (source make-it/travis-support/setup-env.sh && make vjs BUILD=profile)
- (source make-it/travis-support/setup-env.sh && make vjs BUILD=release TARGET=asmjs-unknown-emscripten)
- tar -tf $(npm pack)
script:
- make testjs
- make testnative
- make testhttpbin
- npm run test-min
- npm run test-asmjs
after_failure:
- cat emsdk-tools/emsdk_install_log.txt
before_deploy:
Expand Down
21 changes: 21 additions & 0 deletions karma.asmjs.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Karma configuration

(function () {
'use strict';

module.exports = function (config) {
var getSharedConfig = require('./karma.shared.js');
var sharedConfig = getSharedConfig(config);

sharedConfig.files = [
...sharedConfig.filesPolyfills,
...sharedConfig.filesInfrastructure,
'dist/asmjs-unknown-emscripten/release/vireo.min.js',
...sharedConfig.filesSource,
...sharedConfig.filesFixtures,
...sharedConfig.filesSpecs
];

config.set(sharedConfig);
};
}());
4 changes: 4 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
...sharedConfig.filesPolyfills,
...sharedConfig.filesInfrastructure,
'dist/wasm32-unknown-emscripten/release/vireo.js',
{
pattern: 'dist/wasm32-unknown-emscripten/release/vireo.core.wasm',
included: false
},
...sharedConfig.filesSource,
...sharedConfig.filesFixtures,
...sharedConfig.filesSpecs
Expand Down
4 changes: 4 additions & 0 deletions karma.coverage.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
...sharedConfig.filesPolyfills,
...sharedConfig.filesInfrastructure,
'dist/wasm32-unknown-emscripten/release/vireo.js',
{
pattern: 'dist/wasm32-unknown-emscripten/release/vireo.core.wasm',
included: false
},
...sharedConfig.filesSource,
...sharedConfig.filesFixtures,
...sharedConfig.filesSpecs
Expand Down
4 changes: 4 additions & 0 deletions karma.debug.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
...sharedConfig.filesPolyfills,
...sharedConfig.filesInfrastructure,
'dist/wasm32-unknown-emscripten/debug/vireo.js',
{
pattern: 'dist/wasm32-unknown-emscripten/debug/vireo.core.wasm',
included: false
},
...sharedConfig.filesSource,
...sharedConfig.filesFixtures,
...sharedConfig.filesSpecs
Expand Down
4 changes: 4 additions & 0 deletions karma.min.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
...sharedConfig.filesPolyfills,
...sharedConfig.filesInfrastructure,
'dist/wasm32-unknown-emscripten/release/vireo.min.js',
{
pattern: 'dist/wasm32-unknown-emscripten/release/vireo.core.wasm',
included: false
},
...sharedConfig.filesSource,
...sharedConfig.filesFixtures,
...sharedConfig.filesSpecs
Expand Down
4 changes: 0 additions & 4 deletions karma.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
],

filesSource: [
{
pattern: 'dist/wasm32-unknown-emscripten/*/vireo.core.wasm',
included: false
}
],

filesFixtures: [
Expand Down
12 changes: 8 additions & 4 deletions make-it/EmMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MKDIR="mkdir"

VIREO_SDK=..

TARGETS_SUPPORTED=wasm32-unknown-emscripten
TARGETS_SUPPORTED=asmjs-unknown-emscripten wasm32-unknown-emscripten
TARGET=wasm32-unknown-emscripten

ifeq ($(filter $(TARGET), $(TARGETS_SUPPORTED)),)
Expand Down Expand Up @@ -84,12 +84,16 @@ endif
EM_OPTFLAGS ?= $(EM_OPTFLAG)
EM_ANALYSIS_OPT_FLAG = $(EM_OPTFLAG)

ifeq ($(TARGET), asmjs-unknown-emscripten)
TARGET_FLAG = -s WASM=0
endif

ifeq ($(TARGET), wasm32-unknown-emscripten)
WASM_FLAG = -s WASM=1
TARGET_FLAG = -s WASM=1 -s BINARYEN_TRAP_MODE=js -s ALLOW_MEMORY_GROWTH=1
endif

# NO_DYNAMIC_EXECUTION=1 Allows Vireo to be used in CSP environments where eval() is forbidden: https://github.com/kripken/emscripten/blob/master/src/settings.js#L563
EM_OPT = $(EM_OPTFLAGS) $(WASM_FLAG) -s NO_EXIT_RUNTIME=1 -std=c++14 -fno-exceptions --memory-init-file 0 -s NO_DYNAMIC_EXECUTION=1 -s MODULARIZE=1 -s EXPORT_NAME=VireoCreateCoreModule -s EXPORT_ES6=1 --minify 0 -s BINARYEN_TRAP_MODE=js -s ALLOW_MEMORY_GROWTH=1
EM_OPT = $(EM_OPTFLAGS) $(TARGET_FLAG) -s NO_EXIT_RUNTIME=1 -std=c++14 -fno-exceptions --memory-init-file 0 -s NO_DYNAMIC_EXECUTION=1 -s MODULARIZE=1 -s EXPORT_NAME=VireoCreateCoreModule -s EXPORT_ES6=1 --minify 0
EMFLAGS = -I$(INCDIR) -DkVireoOS_emscripten $(EM_OPT)
EMLIBRARY = --js-library $(CORESOURCEDIR)/library_coreHelpers.js \
--js-library $(CORESOURCEDIR)/library_eventHelpers.js \
Expand Down Expand Up @@ -252,7 +256,7 @@ $(DIST)/vireo.core.js: $(EM_BC_FILES) $(ANALYSIS_LIBRARY) $(PREJS) $(POSTJS) | $
$(EMCC) $(EM_OPT) $(EM_WRAP) $(EMLIBRARY) $(EM_BC_FILES) $(ANALYSIS_LIBRARY) $(EM_EXPORTS) $(EM_RUNTIME_EXPORTS) -o $@

$(DIST)/vireo.js: $(DIST)/vireo.core.js $(JS_SOURCE_FILES)
npm run rollup -- $(CORESOURCEDIR)/vireo.loader.$(BUILD).js --format umd --name vireoHelpers --amd.id vireoHelpers --file $@
npm run rollup -- $(CORESOURCEDIR)/vireo.loader.$(TARGET).$(BUILD).js --format umd --name vireoHelpers --amd.id vireoHelpers --file $@

$(DIST)/vireo.min.js: $(DIST)/vireo.js
npm run terser -- $(DIST)/vireo.js -o $@
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"test-dev": "karma start --browsers ChromeHeadlessNoSandbox --skip-tags Slow",
"test-manual": "karma start --no-single-run",
"test-coverage": "karma start karma.coverage.conf.js",
"test-asmjs": "karma start karma.asmjs.conf.js --browsers ChromeHeadlessNoSandbox,FirefoxHeadless",
"lint": "eslint .",
"prehttpbin": "python -V && pip -V && virtualenv --version && tox --version",
"httpbin": "tox",
Expand Down
10 changes: 10 additions & 0 deletions source/core/vireo.loader.asmjs-unknown-emscripten.debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import createVireoCore from '../../dist/asmjs-unknown-emscripten/debug/vireo.core.js';
import createInstanceUnbound from './vireo.loader.shared.js';
import staticHelpers from './vireo.loader.staticHelpers.js';

const createInstance = createInstanceUnbound.bind(undefined, createVireoCore);
export default {
createInstance,
staticHelpers
};
10 changes: 10 additions & 0 deletions source/core/vireo.loader.asmjs-unknown-emscripten.profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import createVireoCore from '../../dist/asmjs-unknown-emscripten/profile/vireo.core.js';
import createInstanceUnbound from './vireo.loader.shared.js';
import staticHelpers from './vireo.loader.staticHelpers.js';

const createInstance = createInstanceUnbound.bind(undefined, createVireoCore);
export default {
createInstance,
staticHelpers
};
10 changes: 10 additions & 0 deletions source/core/vireo.loader.asmjs-unknown-emscripten.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import createVireoCore from '../../dist/asmjs-unknown-emscripten/release/vireo.core.js';
import createInstanceUnbound from './vireo.loader.shared.js';
import staticHelpers from './vireo.loader.staticHelpers.js';

const createInstance = createInstanceUnbound.bind(undefined, createVireoCore);
export default {
createInstance,
staticHelpers
};
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 75af816

Please sign in to comment.