From 70a02a6974f2e6649ca808ca0ad530eb40f2054e Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Sat, 5 Jan 2019 23:11:04 -0500 Subject: [PATCH] Removed docker build from C++ build --- .travis.yml | 7 ++++--- package.json | 4 ++-- packages/perspective/package.json | 3 --- scripts/build_cpp.js | 35 +++++++++++++++++++++++++++++++ scripts/test_cpp.js | 33 +++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 scripts/build_cpp.js create mode 100644 scripts/test_cpp.js diff --git a/.travis.yml b/.travis.yml index b3279d7178..aa96a44aea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/package.json b/package.json index 7c054732da..f0f6b9db78 100644 --- a/package.json +++ b/package.json @@ -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}}", diff --git a/packages/perspective/package.json b/packages/perspective/package.json index 29b881ec17..2f550314d6 100644 --- a/packages/perspective/package.json +++ b/packages/perspective/package.json @@ -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", diff --git a/scripts/build_cpp.js b/scripts/build_cpp.js new file mode 100644 index 0000000000..d5f702b25b --- /dev/null +++ b/scripts/build_cpp.js @@ -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); +} diff --git a/scripts/test_cpp.js b/scripts/test_cpp.js new file mode 100644 index 0000000000..0fbdb7d52e --- /dev/null +++ b/scripts/test_cpp.js @@ -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); +}