Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand os for c++ testing #402

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
max_jobs: 8

image:
- Visual Studio 2015
- Visual Studio 2017

configuration:
- Release
- Debug

platform:
- x64

environment:
matrix:
- arch: Win64

matrix:
allow_failures:
- platform: x64
configuration: Debug

init:
- set arch=
- if "%arch%"=="Win64" ( set arch= Win64)
- echo %arch%
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017%arch%" )
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015%arch%" )

before_build:
- cmd: |-
mkdir build
cd build
cmake --version
cmake .. -G %generator% -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1 -DPSP_CPP_BUILD_STRICT=1 -DBOOST_ROOT=C:\Libraries\boost_1_67_0 -DBoost_INCLUDE_DIRS=C:\Libraries\boost_1_67_0

build_script:
- msbuild psp.sln /p:Platform=x64 /m /p:Configuration=%CONFIGURATION%
- cp %CONFIGURATION%\psp.dll test\%CONFIGURATION%
- cp tbb-build\%CONFIGURATION%\tbb.dll test\%CONFIGURATION%
- .\test\%CONFIGURATION%\psp_test.exe

# to disable automatic tests
test: off

# to disable deployment
deploy: off
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ language: node_js
node_js: "8"
sudo: required

services:
- docker

matrix:
include:
- node_js: "8"
language: node_js
env: TEST=WASM
services: docker

- language: c++
env: TEST=CPP
services: docker

- python: "3.6"
language: python
env: TEST=PYTHON
cache: pip
services: docker

- language: c++
env: TEST=CPP_OSX
os: osx

cache:
yarn: true
Expand All @@ -37,6 +41,7 @@ env:


install:
- if [ "$TEST" = "CPP_OSX" ]; then brew install yarn; fi
- yarn

script:
Expand All @@ -48,3 +53,5 @@ script:
- if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn build_python; fi
- if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn lint_python; fi
- if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn test_python; fi
- if [ "$TEST" = "CPP_OSX" ]; then yarn build_cpp; fi
- if [ "$TEST" = "CPP_OSX" ]; then yarn test_cpp; fi
117 changes: 70 additions & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH} )

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WIN32 ON)
endif()

##############################
# helper to grab gtest et al #
##############################
function (psp_build_dep name cmake_file)
if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build)
message(WARNING "${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}")
else()
configure_file(${cmake_file} ${name}-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download )
if(result)
message(FATAL_ERROR "CMake step for ${name} failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download )
if(result)
message(FATAL_ERROR "Build step for ${name} failed: ${result}")
endif()
endif()
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
${CMAKE_BINARY_DIR}/${name}-build
EXCLUDE_FROM_ALL)

include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/gtest/include)
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include)
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
endfunction()
##############################


#######################
# BUILD CONFIGURATION #
Expand Down Expand Up @@ -101,7 +136,6 @@ if (PSP_WASM_BUILD)
####################
# EMSCRIPTEN BUILD #
####################
add_definitions(-DPSP_ENABLE_WASM)
set(CMAKE_C_COMPILER emcc)
set(CMAKE_CXX_COMPILER em++)
set(CMAKE_TOOLCHAIN_FILE "$ENV{EMSCRIPTEN_ROOT}/cmake/Modules/Platform/Emscripten.cmake")
Expand Down Expand Up @@ -170,23 +204,29 @@ else()
else()
message("${Cyan}Found boost in ${Boost_INCLUDE_DIRS} ${Boost_LIBRARY_DIRS} ${ColorReset}")
endif()
include_directories(Boost_INCLUDE_DIRS)
include_directories( ${Boost_INCLUDE_DIRS} )

find_package(TBB)
if(NOT TBB_FOUND)
message("${Red}TBB could not be located${ColorReset}")
psp_build_dep("tbb" "cmake/TBB.txt.in")
else()
message("${Cyan}Found tbb in ${TBB_INCLUDE_DIRS} ${TBB_LIBRARY_DIRS} ${ColorReset}")
include_directories( ${TBB_INCLUDE_DIRS} )
endif()

include_directories(TBB_INCLUDE_DIRS)
include_directories("/usr/local/include")
if(WIN32)
foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}")
endforeach(warning)
else()
include_directories("/usr/local/include")
endif()

if(PSP_PYTHON_BUILD)
#########################
# PYTHON BINDINGS BUILD #
#########################
add_definitions(-DPSP_ENABLE_PYTHON)
include_directories("/usr/local/include/python3.7m") # FIXME
include_directories("${CMAKE_SOURCE_DIR}/python/perspective/include")
find_package( PythonInterp 3.7 REQUIRED )
Expand Down Expand Up @@ -238,6 +278,7 @@ set (SOURCE_FILES
src/cpp/context_two.cpp
src/cpp/context_zero.cpp
src/cpp/custom_column.cpp
src/cpp/data.cpp
src/cpp/date.cpp
src/cpp/dense_nodes.cpp
src/cpp/dense_tree_context.cpp
Expand Down Expand Up @@ -287,45 +328,59 @@ set (SOURCE_FILES
src/cpp/vocab.cpp
)

set(CMAKE_CXX_FLAGS " -std=c++0x ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
if (WIN32)
set(CMAKE_CXX_FLAGS " /EHsc")
else()
set(CMAKE_CXX_FLAGS " -std=c++0x ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
endif()

if (PSP_WASM_BUILD)
add_library(psp ${SOURCE_FILES})
target_compile_definitions(psp PRIVATE PSP_ENABLE_WASM=1)
set_target_properties(psp PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}")

add_executable(perspective.async src/cpp/emscripten.cpp)
target_link_libraries(perspective.async psp "${ASYNC_MODE_FLAGS}")
target_compile_definitions(perspective.async PRIVATE PSP_ENABLE_WASM=1)
set_target_properties(perspective.async PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}")
set_target_properties(perspective.async PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/")
set_target_properties(perspective.async PROPERTIES OUTPUT_NAME "psp.async")

add_executable(perspective.sync src/cpp/emscripten.cpp)
target_link_libraries(perspective.sync psp "${SYNC_MODE_FLAGS}")
target_compile_definitions(perspective.sync PRIVATE PSP_ENABLE_WASM=1)
set_target_properties(perspective.sync PROPERTIES COMPILE_FLAGS "${SYNC_MODE_FLAGS}")
set_target_properties(perspective.sync PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/")
set_target_properties(perspective.sync PROPERTIES OUTPUT_NAME "psp.sync")
add_dependencies(perspective.sync perspective.async)

if (NOT CMAKE_BUILD_TYPE_LOWER STREQUAL debug)
add_executable(perspective.asm src/cpp/emscripten.cpp)
target_compile_definitions(perspective.asm PRIVATE PSP_ENABLE_WASM=1)
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/")
set_target_properties(perspective.asm PROPERTIES OUTPUT_NAME "psp.asmjs")
add_dependencies(perspective.asm perspective.sync)
endif()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_SHARED_LIBRARY_SUFFIX .dylib)
endif()

if(PSP_PYTHON_BUILD)
########################
# Python extra targets #
########################
add_library(psp SHARED ${SOURCE_FILES} ${CMAKE_SOURCE_DIR}/python/perspective/src/numpy.cpp ${HEADER_FILES})
target_compile_definitions(psp PRIVATE PSP_ENABLE_PYTHON=1)
target_link_libraries(psp ${BOOST_PYTHON})
target_link_libraries(psp ${BOOST_NUMPY})
target_link_libraries(psp ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
set(CMAKE_SHARED_LIBRARY_SUFFIX .so)

add_library(binding SHARED ${CMAKE_SOURCE_DIR}/python/perspective/src/python.cpp)
target_compile_definitions(binding PRIVATE PSP_ENABLE_PYTHON=1)
target_link_libraries(binding psp)
target_link_libraries(binding tbb)
target_link_libraries(binding ${BOOST_PYTHON})
Expand All @@ -334,64 +389,32 @@ else()
########################
else()
add_library(psp SHARED ${SOURCE_FILES} ${HEADER_FILES})
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_SHARED_LIBRARY_SUFFIX .dylib)
endif()
endif()

if(PSP_CPP_BUILD_STRICT)
if(PSP_CPP_BUILD_STRICT AND NOT WIN32)
target_compile_options(psp PRIVATE -Wall -Werror)
target_compile_options(psp PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
if(PSP_PYTHON_BUILD)
target_compile_options(binding PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
endif()
elseif(WIN32)
target_compile_definitions(psp PRIVATE PERSPECTIVE_EXPORTS=1)
target_compile_definitions(psp PRIVATE WIN32=1)
endif()

# target_link_libraries(psp ${TBB_LIBRARIES}) // doesnt work on mac
target_link_libraries(psp tbb)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${TBB_LIBRARY})

target_compile_options(psp PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
endif()


##############################
# helper to grab gtest et al #
##############################
function (psp_build_dep name cmake_file)
if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build)
message(WARNING "${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}")

else()
configure_file(${cmake_file} ${name}-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download )
if(result)
message(FATAL_ERROR "CMake step for ${name} failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download )
if(result)
message(FATAL_ERROR "Build step for ${name} failed: ${result}")
endif()
endif()
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
${CMAKE_BINARY_DIR}/${name}-build
EXCLUDE_FROM_ALL)
include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/gtest/include)
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include)
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
endfunction()
##############################


#############
# CPP TESTS #
#############
if (PSP_CPP_BUILD_TESTS)
if (WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
psp_build_dep("googletest" "cmake/GTest.txt.in")
# psp_build_dep("tbb" "cmake/TBB.txt.in")

add_subdirectory(test)
add_custom_target(gcov
Expand Down
2 changes: 1 addition & 1 deletion cmake/TBB.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ ExternalProject_Add(tbb
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
)
)
4 changes: 2 additions & 2 deletions scripts/test_python.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function docker(image = "emsdk") {

// Copy .so in place to perspective package
try {
let cmd1 = "cp `find build -name 'libbinding.so'` python/perspective/table/";
let cmd2 = "cp `find build -name 'libpsp.so'` python/perspective/table/";
let cmd1 = "cp `find build -name 'libbinding.*'` python/perspective/table/";
let cmd2 = "cp `find build -name 'libpsp.*'` python/perspective/table/";
if (process.env.PSP_DOCKER) {
execute(docker("python") + ' bash -c "' + cmd1 + '"');
execute(docker("python") + ' bash -c "' + cmd2 + '"');
Expand Down
11 changes: 9 additions & 2 deletions src/cpp/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

namespace perspective {

void
psp_abort() {
void psp_abort() {
std::raise(SIGINT);
}

Expand Down Expand Up @@ -316,6 +315,14 @@ is_internal_colname(const std::string& c) {
return c.compare(std::string("psp_")) == 0;
}


template <typename T>
t_dtype
type_to_dtype() {
return DTYPE_NONE;
}


template <>
t_dtype
type_to_dtype<std::int64_t>() {
Expand Down
Loading