Skip to content

Commit

Permalink
Merge pull request #234 from jpmorganchase/remove-nested-build-dirs
Browse files Browse the repository at this point in the history
Remove nested build dirs
  • Loading branch information
texodus authored Sep 11, 2018
2 parents bd6956d + 174c8bb commit 219fc9d
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 58 deletions.
2 changes: 1 addition & 1 deletion packages/perspective-jupyterlab/src/js/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import worker from "worker-loader?inline=true&fallback=false!@jpmorganchase/perspective/src/js/perspective.wasm.js";
import buffer from "arraybuffer-loader!@jpmorganchase/perspective/build/wasm_async/psp.wasm"
import buffer from "arraybuffer-loader!@jpmorganchase/perspective/build/psp.async.wasm"

window.__PSP_WORKER__ = worker;
window.__PSP_WASM__ = buffer;
12 changes: 6 additions & 6 deletions packages/perspective/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@ if (PSP_WASM_BUILD)
add_executable(perspective.async src/cpp/main.cpp)
target_link_libraries(perspective.async psp "${ASYNC_MODE_FLAGS}")
set_target_properties(perspective.async PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}")
set_target_properties(perspective.async PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../build/wasm_async/")
set_target_properties(perspective.async PROPERTIES OUTPUT_NAME "psp")
set_target_properties(perspective.async PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../obj/")
set_target_properties(perspective.async PROPERTIES OUTPUT_NAME "psp.async")

add_executable(perspective.sync src/cpp/main.cpp)
target_link_libraries(perspective.sync psp "${SYNC_MODE_FLAGS}")
set_target_properties(perspective.sync PROPERTIES COMPILE_FLAGS "${SYNC_MODE_FLAGS}")
set_target_properties(perspective.sync PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../build/wasm_sync/")
set_target_properties(perspective.sync PROPERTIES OUTPUT_NAME "psp")
set_target_properties(perspective.sync PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../obj/")
set_target_properties(perspective.sync PROPERTIES OUTPUT_NAME "psp.sync")
add_dependencies(perspective.sync perspective.async)

add_executable(perspective.asm src/cpp/main.cpp)
target_link_libraries(perspective.asm psp "${ASMJS_MODE_FLAGS}")
set_target_properties(perspective.asm PROPERTIES COMPILE_FLAGS "${ASMJS_MODE_FLAGS}")
set_target_properties(perspective.asm PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../build/asmjs/")
set_target_properties(perspective.asm PROPERTIES OUTPUT_NAME "psp")
set_target_properties(perspective.asm PROPERTIES RUNTIME_OUTPUT_DIRECTORY "../obj/")
set_target_properties(perspective.asm PROPERTIES OUTPUT_NAME "psp.asmjs")
add_dependencies(perspective.asm perspective.sync)
endif()

Expand Down
6 changes: 4 additions & 2 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
"bench:build:copy": "cp bench/csv/* build",
"bench:run": "node build/benchmark.js",
"bench": "npm-run-all bench:build bench:run",
"build": "npm-run-all build:compile:* build:webpack",
"build:compile:copy": "mkdir -p obj build build/wasm_async build/wasm_sync build/asmjs",
"build": "npm-run-all build:compile:* build:copy:* build:webpack",
"build:compile:copy": "mkdir -p obj build",
"build:compile:emmake": "cd obj/ && emcmake cmake ../ && emmake make -j${PSP_CPU_COUNT-8}",
"build:copy:async": "cp obj/psp.async.wasm build/psp.async.wasm",
"build:copy:sync": "cp obj/psp.sync.wasm build/psp.sync.wasm",
"build:webpack": "npm-run-all -p build:webpack:*",
"build:webpack:asmjs": "webpack --color --config src/config/perspective.asmjs.config.js",
"build:webpack:wasm": "webpack --color --config src/config/perspective.wasm.config.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective/src/config/common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function () {
options: {}
}
}, {
test: /psp\.js$/,
test: /psp\.(asmjs|async|sync).js$/,
loader: "wrap-loader",
options: {
before: ';var window = window || {};exports.load_perspective = function(Module) {',
Expand All @@ -58,7 +58,7 @@ module.exports = function () {
}
}, {
test: /\.js$/,
exclude: /node_modules\/(?!(\@apache-arrow|\@jupyterlab))|psp\.js/,
exclude: /node_modules\/(?!(\@apache-arrow|\@jupyterlab))|psp\.(asmjs|async|sync).js/,
loader: "babel-loader",
options: {
presets: ['env'],
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective/src/config/perspective.asmjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = Object.assign({}, common(), {
entry: ["babel-polyfill", './src/js/perspective.asmjs.js'],
plugins: [],
output: {
filename: 'perspective.js',
path: path.resolve(__dirname, '../../build/asmjs')
filename: 'perspective.worker.asmjs.js',
path: path.resolve(__dirname, '../../build')
}
});
4 changes: 2 additions & 2 deletions packages/perspective/src/config/perspective.wasm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('./common.config.js');
module.exports = Object.assign({}, common(), {
entry: './src/js/perspective.wasm.js',
output: {
filename: 'perspective.js',
path: path.resolve(__dirname, '../../build/wasm_async')
filename: 'perspective.worker.async.js',
path: path.resolve(__dirname, '../../build')
}
});
12 changes: 6 additions & 6 deletions packages/perspective/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,15 +1009,15 @@ get_data(T ctx, t_uint32 start_row, t_uint32 end_row, t_uint32 start_col, t_uint
int
main(int argc, char** argv)
{
std::cout << "Perspective initialized successfully." << std::endl;
std::cout << "Perspective initialized successfully" << std::endl;
EM_ASM({

if (global.dispatchEvent && !global._perspective_initialized && global.document) {
global._perspective_initialized = true;
var event = global.document.createEvent("Event");
if (self.dispatchEvent && !self._perspective_initialized && self.document) {
self._perspective_initialized = true;
var event = self.document.createEvent("Event");
event.initEvent("perspective-ready", false, true);
global.dispatchEvent(event);
} else if (!global.document && typeof self !== "undefined") {
self.dispatchEvent(event);
} else if (!self.document && typeof self !== "undefined") {
self.postMessage({});
}

Expand Down
20 changes: 8 additions & 12 deletions packages/perspective/src/js/perspective.asmjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
*
*/

const load_perspective = require("../../build/asmjs/psp.js").load_perspective;
const load_perspective = require("../../obj/psp.asmjs.js").load_perspective;
const perspective = require('./perspective.js');

if (global.document !== undefined) {
const Module = load_perspective({
wasmJSMethod: "asmjs",
filePackagePrefixURL: "",
printErr: (x) => console.error(x),
print: (x) => console.warn(x)
});
module.exports = perspective(Module);
} else {
module.exports = perspective(load_perspective);
}
const Module = load_perspective({
wasmJSMethod: "asmjs",
filePackagePrefixURL: "",
printErr: (x) => console.error(x),
print: (x) => console.log(x)
});
module.exports = perspective(Module);

10 changes: 1 addition & 9 deletions packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -1679,14 +1679,6 @@ class WorkerHost extends Host {
init(msg) {
if (typeof WebAssembly === 'undefined') {
console.log("Loading asm.js");
__MODULE__ = __MODULE__({
wasmJSMethod: "asmjs",
locateFile: path => `${path}`,
filePackagePrefixURL: msg.path,
printErr: (x) => console.warn(x),
print: (x) => console.log(x)
// asmjsCodeFile: msg.data || msg.path + 'asmjs/psp.asm.js'
});
} else {
console.log('Loading wasm');
if (msg.data) {
Expand All @@ -1696,7 +1688,7 @@ class WorkerHost extends Host {
__MODULE__ = __MODULE__(module);
} else {
let wasmXHR = new XMLHttpRequest();
wasmXHR.open('GET', msg.path + 'wasm_async/psp.wasm', true);
wasmXHR.open('GET', msg.path + '/psp.async.wasm', true);
wasmXHR.responseType = 'arraybuffer';
wasmXHR.onload = function() {
module = {};
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*
*/

import buffer from "../../build/wasm_sync/psp.wasm";
import buffer from "../../obj/psp.sync.wasm";

const perspective = require('./perspective.js');

const fs = require('fs');

const WebSocket = require('ws');

const load_perspective = require("../../build/wasm_sync/psp.js").load_perspective;
const load_perspective = require("../../obj/psp.sync.js").load_perspective;

let Module = load_perspective({
wasmBinary: buffer,
Expand Down
10 changes: 5 additions & 5 deletions packages/perspective/src/js/perspective.parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class WebWorker extends worker {
}

_start_cross_origin() {
var dir = (typeof WebAssembly === "undefined" ? 'asmjs' : 'wasm_async');
XHRWorker(__SCRIPT_PATH__.path() + dir + '/perspective.js', function(worker) {
var dir = (typeof WebAssembly === "undefined" ? 'asmjs' : 'wasm');
XHRWorker(__SCRIPT_PATH__.path() + '/perspective.worker.' + dir + '.js', function(worker) {
for (var key in this._worker) {
worker[key] = this._worker[key];
}
Expand All @@ -130,7 +130,7 @@ class WebWorker extends worker {

_start_cross_origin_wasm() {
var wasmXHR = new XMLHttpRequest();
wasmXHR.open('GET', __SCRIPT_PATH__.path() + 'wasm_async/psp.wasm', true);
wasmXHR.open('GET', __SCRIPT_PATH__.path() + '/psp.async.wasm', true);
wasmXHR.responseType = 'arraybuffer';
wasmXHR.onload = () => {
let msg = {
Expand All @@ -148,8 +148,8 @@ class WebWorker extends worker {
}

_start_same_origin() {
var dir = (typeof WebAssembly === "undefined" || detect_iphone() ? 'asmjs' : 'wasm_async');
var w = new Worker(__SCRIPT_PATH__.path() + dir + '/perspective.js');
var dir = (typeof WebAssembly === "undefined" || detect_iphone() ? 'asmjs' : 'async');
var w = new Worker(__SCRIPT_PATH__.path() + '/perspective.worker.' + dir + '.js');
for (var key in this._worker) {
w[key] = this._worker[key];
}
Expand Down
5 changes: 2 additions & 3 deletions packages/perspective/src/js/perspective.wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*
*/

const load_perspective = require("../../build/wasm_async/psp.js").load_perspective;
const load_perspective = require("../../obj/psp.async.js").load_perspective;
const perspective = require('./perspective.js');

if (global.document !== undefined && typeof WebAssembly !== 'undefined') {
module.exports = perspective(load_perspective({
wasmJSMethod: "native-wasm",
filePackagePrefixURL: "",
printErr: (x) => console.error(x),
print: (x) => console.warn(x)
print: (x) => console.log(x)
}));
} else {
module.exports = perspective(load_perspective);
Expand Down
6 changes: 1 addition & 5 deletions packages/perspective/test/js/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ function ConsoleReporter() {
jasmine.getEnv().addReporter(new ConsoleReporter());

const start = window._onload;
let ran = 0;

window.addEventListener('perspective-ready', function() {
ran++;
if (ran === (typeof WebAssembly === 'undefined' ? 1 : 2)) {
setTimeout(start, 500);
}
setTimeout(start, 500);
})
2 changes: 1 addition & 1 deletion packages/perspective/test/js/perspective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const RUNTIMES = {
}

if (typeof WebAssembly !== "undefined") {
RUNTIMES["WASM"] = perspective(require("../../build/wasm_sync/psp.js"));
RUNTIMES["WASM"] = perspective(require("../../obj/psp.sync.js"));
}

const constructor_tests = require("./constructors.js");
Expand Down

0 comments on commit 219fc9d

Please sign in to comment.