Skip to content

Commit

Permalink
Add appveyor config
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Aug 8, 2018
1 parent f786854 commit f9194cb
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 15 deletions.
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ project(z5)
# Check and enable C++ 14
##############################

include(CheckCXXCompilerFlag)
# make sure the compiler supports c++14
# FIXME I think this won't work for MSVC
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
if(NOT HAS_CPP14_FLAG)
message(FATAL_ERROR "Unsupported compiler -- z5 requires C++14 support!")
include(CheckCXXCompilerFlag)
# NOTE this does not work for MSVC 14 (which does have c++ 14 support)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
if(NOT HAS_CPP14_FLAG)
message(FATAL_ERROR "Unsupported compiler -- z5 requires C++14 support!")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

Expand Down Expand Up @@ -65,7 +67,9 @@ include_directories(${CMAKE_SOURCE_DIR}/external/json/include)
# Set up conda env
###############################

# This does not work within travis for some reason
# This does not work within travis or appveyor, because
# we set the CMAKE_PREFIX_PATH
# TODO rename this to USE_CONDA_PREFIX or similar
if(NOT WITHIN_TRAVIS)
# Find the current conda env and set it as CMAKE_PREFIX_PATH
execute_process(COMMAND bash -c "conda info | grep 'active env location' | awk '{print $5}'"
Expand All @@ -82,6 +86,8 @@ if(NOT WITHIN_TRAVIS)
string(REGEX REPLACE "\n$" "" CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
endif()

MESSAGE(STATUS "Setting cmake prefix path to ${CMAKE_PREFIX_PATH}")

# Set CMAKE_PREFIX_PATH to the conda env, but allow changing it
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "")

Expand Down
37 changes: 37 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
platform:
- x64

clone_script:
- cmd: git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/%APPVEYOR_REPO_NAME%.git %APPVEYOR_BUILD_FOLDER%
- cmd: cd %APPVEYOR_BUILD_FOLDER%
- cmd: git checkout -qf %APPVEYOR_REPO_COMMIT%
- cmd: git submodule update --init

environment:
matrix:
- PY_VERSION: "3.6"
VC_VERSION: "14"

build_script:
# This is a small script that takes the PATH variable and transforms its entries
# into their short-path (DOS-like) counterparts. The new path is written into the file path.txt,
# from which it is then loaded. This allows to shorten the overall length of the PATH variable,
# thus avoiding an issue with conda. See also:
# https://github.com/conda/conda/issues/1923
# It might be that this will be solved in future conda versions.
- config\\shorten_path.bat > path.txt
- set /p PATH=<path.txt
# we may want to support more python versions in the future
- if "%PY_VERSION%" == "3.6" set PATH=C:\\Miniconda3-x64\\Scripts;%PATH%
- if "%PY_VERSION%" == "3.6" conda create -c conda-forge -q --yes -n python python=%PY_VERSION%
- activate python
- set CONDA_ACTIVE_ENV=C:\\Miniconda3-x64\\envs\\python
- set BOOST_INCLUDE=%CONDA_ACTIVE_ENV%\\Library\\include
- echo "BOOST_ROOT:"
- echo "%BOOST_ROOT%"
- conda install -c conda-forge --yes xtensor-python c-blosc boost bzip2
- cd %APPVEYOR_BUILD_FOLDER%
- mkdir build
- cd build
- cmake .. -G "Visual Studio %VC_VERSION% Win64" -DCMAKE_PREFIX_PATH="%CONDA_ACTIVE_ENV%" -DWITH_BLOSC=ON -DWITH_ZLIB=ON -DWITH_BZIP2=ON -DWITHIN_TRAVIS=ON -DBOOST_INCLUDEDIR=%BOOST_INCLUDE%
- cmake --build .
20 changes: 20 additions & 0 deletions config/shorten_path.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off

SET MyPath=%PATH%
rem echo %MyPath%
rem echo --

setlocal EnableDelayedExpansion

SET TempPath="%MyPath:;=";"%"
SET var=
FOR %%a IN (%TempPath%) DO (
IF exist %%~sa (
SET "var=!var!;%%~sa"
) ELSE (
rem echo %%a does not exist
)
)

rem echo --
echo !var:~1!
6 changes: 3 additions & 3 deletions include/z5/io/io_n5.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace io {

// we need to wrap std::min in a lambda and a std::function to pass it to `iterateChunks`
std::function<std::size_t (std::size_t, std::size_t)> minComp = [](std::size_t a, std::size_t b) {
return std::min(a, b);
return (std::min)(a, b);
};

// starting from our current chunk position, find the downstream chunk with
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace io {

// we need to wrap std::max in a lambda and a std::function to pass it to `iterateChunks`
std::function<std::size_t (std::size_t, std::size_t)> maxComp = [](std::size_t a, std::size_t b) {
return std::max(a, b);
return (std::max)(a, b);
};

// starting from our current chunk position, find the downstream chunk with
Expand Down Expand Up @@ -231,7 +231,7 @@ namespace io {
offset += 2;

// write the number of dimensions
uint16_t nDimsOut = shape.size();
uint16_t nDimsOut = static_cast<uint16_t>(shape.size());
util::reverseEndiannessInplace(nDimsOut);
data.insert(data.begin() + offset, (char*) &nDimsOut, (char*) &nDimsOut + 2);
offset += 2;
Expand Down
10 changes: 5 additions & 5 deletions include/z5/util/threadpool.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ParallelOptions
*/
int getActualNumThreads() const
{
return std::max(1,numThreads_);
return (std::max)(1,numThreads_);
}

/** \brief Set the number of threads or one of the constants <tt>Auto</tt>,
Expand Down Expand Up @@ -350,12 +350,12 @@ inline void parallel_foreach_impl(

// NIFTY_CHECK(workload == nItems || nItems == 0, "parallel_foreach(): Mismatch between num items and begin/end.");
const float workPerThread = float(workload)/pool.nThreads();
const std::ptrdiff_t chunkedWorkPerThread = std::max<std::ptrdiff_t>(int(workPerThread/3.0f + 0.5f), 1);
const std::ptrdiff_t chunkedWorkPerThread = (std::max<std::ptrdiff_t>)(int(workPerThread/3.0f + 0.5f), 1);

std::vector<std::future<void> > futures;
for( ;iter<end; iter+=chunkedWorkPerThread)
{
const std::size_t lc = std::min(workload, chunkedWorkPerThread);
const std::size_t lc = (std::min)(workload, chunkedWorkPerThread);
workload-=lc;
futures.emplace_back(
pool.enqueue(
Expand Down Expand Up @@ -391,12 +391,12 @@ inline void parallel_foreach_impl(

std::ptrdiff_t workload = nItems;
const float workPerThread = float(workload)/pool.nThreads();
const std::ptrdiff_t chunkedWorkPerThread = std::max<std::ptrdiff_t>(int(workPerThread/3.0f+0.5f), 1);
const std::ptrdiff_t chunkedWorkPerThread = (std::max<std::ptrdiff_t>)(int(workPerThread/3.0f+0.5f), 1);

std::vector<std::future<void> > futures;
for(;;)
{
const std::size_t lc = std::min(chunkedWorkPerThread, workload);
const std::size_t lc = (std::min)(chunkedWorkPerThread, workload);
workload -= lc;
futures.emplace_back(
pool.enqueue(
Expand Down
2 changes: 1 addition & 1 deletion include/z5/util/util.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace util {
std::vector<types::ShapeType> & grid) {
// get the number of dims and initialize the positions
// at the min coordinates
const std::size_t nDim = minCoords.size();
const int nDim = minCoords.size();
types::ShapeType positions = minCoords;

// start iteration in highest dimension
Expand Down

0 comments on commit f9194cb

Please sign in to comment.