Skip to content

Commit

Permalink
Removed docker build from C++ build
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Jan 6, 2019
1 parent d47556f commit 70a02a6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ install:
script:
- if [ "$TEST" = "WASM" ]; then yarn lint; fi
- if [ "$TEST" = "WASM" ]; then PSP_DOCKER=1 yarn build; fi
- if [ "$TEST" = "WASM" ]; then yarn test --docker --quiet; fi
- if [ "$TEST" = "CPP" ]; then docker build -f docker/cpp/Dockerfile .; fi
- if [ "$TEST" = "PYTHON" ]; then docker build -f docker/python/Dockerfile .; fi
- if [ "$TEST" = "WASM" ]; then PSP_DOCKER=1 yarn test --quiet; fi
- if [ "$TEST" = "CPP" ]; then PSP_DOCKER=1 yarn build_cpp; fi
- if [ "$TEST" = "CPP" ]; then PSP_DOCKER=1 yarn test_cpp; fi
- if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn build_python; fi
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"build,test,bench": "npm run --silent build && npm run --silent test && npm run --silent bench",
"build,bench": "npm run --silent build && npm run --silent bench",
"build": "node scripts/build.js",
"build_cpp": "lerna run build:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
"build_cpp": "node scripts/build_cpp.js",
"build_python": "node scripts/build_python.js",
"install_python": "cd python && python3 setup.py install",
"bench": "node scripts/bench.js",
"docs": "lerna run docs --silent --stream",
"test": "node scripts/test.js",
"test_cpp": "lerna run test:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
"test_cpp": "node scripts/test_cpp.js",
"clean": "find obj -mindepth 1 -delete && lerna run clean ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream",
"preclean:screenshots": "lerna exec -- mkdir -p screenshots",
"clean:screenshots": "lerna run clean:screenshots ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}}",
Expand Down
3 changes: 0 additions & 3 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
"scripts": {
"bench": "node ../../scripts/bench.js",
"prebuild": "mkdir -p build && mkdir -p obj",
"compile:cpp": "mkdir -p ../../cppbuild && cd ../../cppbuild && cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1 && make -j${PSP_CPU_COUNT-8}",
"cpp": "npm-run-all build:cpp test:cpp",
"build": "npm-run-all build:webpack",
"build:cpp": "npm-run-all compile:cpp",
"build:webpack": "npm-run-all -p build:webpack:*",
"build:webpack:umd": "webpack --color --config src/config/perspective.config.js",
"build:webpack:node": "webpack --color --config src/config/perspective.node.config.js",
"docs": "documentation build src/js/perspective.js -f md --shallow > README.md && cp README.md ../../docs/perspective.md",
"test:cpp": "npm-run-all build:cpp && ../../cppbuild/test/psp_test",
"test:build": "cp test/html/* build",
"test:run": "jest --color --ci",
"test": "npm-run-all test:build test:run",
Expand Down
35 changes: 35 additions & 0 deletions scripts/build_cpp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const execSync = require("child_process").execSync;

const execute = cmd => execSync(cmd, {stdio: "inherit"});

function docker(image = "emsdk") {
console.log(`-- Creating ${image} docker image`);
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += ` -v $(pwd):/usr/src/app/cpp -w /usr/src/app/cpp/cppbuild perspective/${image}`;
return cmd;
}

try {
execute("mkdir -p cppbuild");
if (process.env.PSP_DOCKER) {
execute(docker("cpp") + " cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1");
execute(docker("cpp") + " make -j${PSP_CPU_COUNT-8}");
} else {
execute("cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1");
execute("make -j${PSP_CPU_COUNT-8}");
}
} catch (e) {
process.exit(1);
}
33 changes: 33 additions & 0 deletions scripts/test_cpp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const execSync = require("child_process").execSync;

const execute = cmd => execSync(cmd, {stdio: "inherit"});

function docker(image = "emsdk") {
console.log(`-- Creating ${image} docker image`);
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += ` -v $(pwd):/usr/src/app/cpp -w /usr/src/app/cpp/cppbuild perspective/${image}`;
return cmd;
}

try {
execute("mkdir -p cppbuild");
if (process.env.PSP_DOCKER) {
execute(docker("cpp") + " ./test/psp_test");
} else {
execute("./test/psp_test");
}
} catch (e) {
process.exit(1);
}

0 comments on commit 70a02a6

Please sign in to comment.