Skip to content

Commit

Permalink
Update build environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Oct 2, 2019
1 parent d1fdbee commit 6a91243
Show file tree
Hide file tree
Showing 52 changed files with 543 additions and 431 deletions.
65 changes: 38 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,48 @@ compiler:
- gcc
- clang

services:
- docker

before_install:
- sudo apt-get -qq update
- sudo apt-get -qq upgrade
- sudo apt-get -qq install build-essential llvm cmake
- sudo apt-get -qq install libopencv-dev libgtest-dev
- sudo apt-get -qq install ruby

# Install LCOV
- git clone https://github.com/linux-test-project/lcov.git
- make -C lcov install
- sudo gem install coveralls-lcov
- sudo apt-get -qq install llvm

install:
- mkdir build && cd build
- cmake -D LIME_BUILD_TESTS=ON
-D LIME_BUILD_EXAPMLES=ON
-D LIME_BUILD_PYTHON_MODULE=ON ..
- cmake --build . -- -j4
# Pull Docker image
- docker pull tatsy/ubuntu-cxx:opencv

# Dynamically generate Dockerfile
- sed -i -e "s/@C_COMPILER@/$CC/" Dockerfile
- sed -i -e "s/@CXX_COMPILER@/$CXX/" Dockerfile
- sed -i -e "s/@BRANCH_NAME@/$TRAVIS_BRANCH/" Dockerfile
- sed -i -e "s/@PULL_REQUEST@/$TRAVIS_PULL_REQUEST/" Dockerfile
- sed -i -e "s/@PYTHON_VERSION@/$PYTHON_VERSION/" Dockerfile
- sed -i -e "s/@BUILD_STATIC_LIB@/$BUILD_STATIC_LIB/" Dockerfile

# Build Dockerfile
- docker build --tag=lime-env .

# Run container
- docker run --name lime-env --env="CI=true" --env="TRAVIS_JOB_ID=$TRAVIS_JOB_ID" --env="CTEST_OUTPUT_ON_FAILURE=TRUE" -itd lime-env

script:
# Clear coverage infomation
- lcov --directory . --zerocounters
- docker exec lime-env lcov --directory . --zerocounters

# Run test on Docker container
- make check
- docker exec lime-env make check

# Check Python module installation
- docker exec lime-env python -c "import pylime as lime; lime.print_version()"

after_success:
# Collect coverage
- if [ $CXX = "g++" ]; lcov --directory . --capture --output-file coverage.info; fi
- if [ $CXX = "clang++" ]; lcov --directory . --capture --output-file coverage.info --gcov-tool llvm-cov; fi
- lcov --remove coverage.info 'tests/*' 'examples/*' '/usr/*' 'CMakeFiles/*' --output-file coverage.info
- lcov --list coverage.info
- coveralls-lcov --repo-token c6Fd5h2Ovd2c5PV7agagA89sUhsZCwIPR coverage.info
- if [ $CXX = "g++" ]; then docker exec lime-env lcov --directory . --capture --output-file coverage.info; fi
- if [ $CXX = "clang++" ]; then docker exec lime-env lcov --directory . --capture --output-file coverage.info --gcov-tool llvm-cov; fi
- docker exec lime-env lcov --remove coverage.info 'tests/*' 'examples/*' '/usr/*' '/opt/*' 'CMakeFiles/*' --output-file coverage.info
- docker exec lime-env lcov --list coverage.info
- docker exec lime-env coveralls-lcov --repo-token c6Fd5h2Ovd2c5PV7agagA89sUhsZCwIPR coverage.info

before_deploy:
- docker cp lime-env:/root/lime/VERSION .
Expand All @@ -45,12 +54,12 @@ before_deploy:
- git config --global user.email "travis@travis-ci.org"
- sudo apt-get -qq install doxygen
- wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/anaconda
- export PATH="$HOME/anaconda/bin:$PATH"
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- conda update --yes conda
- conda install --yes sphinx
- pip install breathe sphinx_rtd_theme
- patch -u $HOME/anaconda/lib/python3.6/site-packages/breathe/renderer/sphinxrenderer.py < docs/sphinxrenderer.py.patch
- patch -u $HOME/miniconda/lib/python3.6/site-packages/breathe/renderer/sphinxrenderer.py < docs/sphinxrenderer.py.patch
- cd docs && sh ./deploy_docs.sh && cd -
- mkdir packages
- tar czvf packages/releases-v${LIME_VERSION}.tar.gz $(ls -I packages)
Expand All @@ -69,7 +78,7 @@ deploy:
on:
tags: false
branch: master
condition: "$CXX = clang++ && $PYTHON_VERSION = 3.5"
condition: "$CXX = clang++ && BUILD_STATIC_LIB=OFF && $PYTHON_VERSION = 3.5"

branches:
only:
Expand All @@ -78,8 +87,10 @@ branches:

env:
matrix:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.5
- BUILD_STATIC_LIB=OFF PYTHON_VERSION=2.7
- BUILD_STATIC_LIB=OFF PYTHON_VERSION=3.5
- BUILD_STATIC_LIB=ON PYTHON_VERSION=2.7
- BUILD_STATIC_LIB=ON PYTHON_VERSION=3.5

notifications:
email:
Expand Down
82 changes: 65 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.0.0)
project(lime)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(Macros)

if (UNIX AND NOT APPLE)
set(LINUX TRUE)
else()
Expand All @@ -10,9 +13,18 @@ endif()
# ------------------------------------------------------------------------------
# Set version string
# ------------------------------------------------------------------------------
set(LIME_VERSION_STRING "0.3.0")
message(STATUS "LIME v${LIME_VERSION_STRING}")
file(WRITE "VERSION" "${LIME_VERSION_STRING}")
set(LIME_MAJOR_VERSION 0)
set(LIME_MINOR_VERSION 3)
set(LIME_PATCH_VERSION 0)
set(LIME_VERSION "${LIME_MAJOR_VERSION}.${LIME_MINOR_VERSION}.${LIME_PATCH_VERSION}")
message(STATUS "LIME v${LIME_VERSION}")
file(WRITE "VERSION" "${LIME_VERSION}")

# ------------------------------------------------------------------------------
# Common paths
# ------------------------------------------------------------------------------
set(LIME_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/sources)
set(LIME_LIBRARY lime)

# ------------------------------------------------------------------------------
# Build options
Expand All @@ -38,17 +50,10 @@ endif()
# ------------------------------------------------------------------------------
# Build settings
# ------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()

if (${LIME_BUILD_TESTS})
find_package(GTest REQUIRED)
if (NOT WIN32)
message(STATUS "[ LIME ] Generating coverage data.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

# ------------------------------------------------------------------------------
Expand All @@ -67,10 +72,53 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_DEBUG_POSTFIX "-debug")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Add example directory
set(LIME_ROOT ${CMAKE_CURRENT_LIST_DIR})
# ------------------------------------------------------------------------------
# Traverse source directory
# ------------------------------------------------------------------------------
add_subdirectory(sources)
add_subdirectory(examples)

# ------------------------------------------------------------------------------
# Add example directory
# ------------------------------------------------------------------------------
if (${LIME_BUILD_EXAMPLES})
add_subdirectory(examples)
endif()

# ------------------------------------------------------------------------------
# Add test directory
add_subdirectory(tests)
# ------------------------------------------------------------------------------
if (${LIME_BUILD_TESTS})
find_package(GTest REQUIRED)
if (NOT WIN32)
message(STATUS "[ LIME ] Generating coverage data.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
endif()

enable_testing()
add_subdirectory(tests)
endif()

# ------------------------------------------------------------------------------
# Installation setup
# ------------------------------------------------------------------------------
if (LIME_BUILD_STATIC_LIB)
export(TARGETS lime FILE "${CMAKE_BINARY_DIR}/LimeTargets.cmake")
export(PACKAGE lime)

set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib")
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/LimeConfig.cmake.in
${CMAKE_BINARY_DIR}/LimeConfig.cmake @ONLY)

configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/LimeConfigVersion.cmake.in
${CMAKE_BINARY_DIR}/LimeConfigVersion.cmake @ONLY)

install(FILES
${CMAKE_BINARY_DIR}/LimeConfig.cmake
${CMAKE_BINARY_DIR}/LimeConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT dev)

install(EXPORT LimeTargets
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT dev)
endif()
58 changes: 27 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,26 @@ ENV PULL_REQUEST @PULL_REQUEST@
ENV CC @C_COMPILER@
ENV CXX @CXX_COMPILER@
ENV PYTHON_VERSION @PYTHON_VERSION@
ENV BUILD_STATIC_LIB @BUILD_STATIC_LIB@
ENV PATH /opt/conda/bin:$PATH

#
## update/upgrade
#
RUN apt-get update -qq
RUN apt-get upgrade -qq

#
## Install Gcovr
#
RUN apt-get -qq install python-pip
RUN pip install gcovr
RUN apt-get update -q
#RUN apt-get upgrade -q

#
## Install cppcheck, cccc, and doxygen
#
RUN apt-get -qq install cppcheck cccc doxygen

#
## Install Python through Anaconda
#
RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
RUN bash miniconda.sh -b -p $HOME/anaconda
ENV PATH "$HOME/anaconda/bin:$PATH"
RUN conda update --yes conda
RUN conda install --yes python=$PYTHON_VERSION setuptools numpy scipy pillow six libgcc

#
## Install Boost
## Install Python through Miniconda
#
RUN wget -q https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
RUN tar -zxf boost_1_64_0.tar.gz
RUN \
cd boost_1_64_0 && \
./bootstrap.sh && \
./b2 address-model=64 \
include=`python -c "from __future__ import print_function; from distutils import sysconfig; print(sysconfig.get_python_inc())"` \
-d0 --with-python -j2 install .
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -q -O miniconda3.sh
RUN sh ./miniconda3.sh -b -p /opt/conda
RUN rm ./miniconda3.sh

#
## Install Google test
Expand All @@ -62,7 +44,7 @@ RUN \
make && make install

#
## Build lime
## Download lime source codes
#
RUN git clone --depth 12 -b $BRANCH_NAME https://github.com/tatsy/lime.git #redo
RUN \
Expand All @@ -76,16 +58,30 @@ RUN \
cd lime && \
git submodule update --init --recursive

#
## Create conda env and change default env
#
RUN \
cd lime && \
sed -i -e "s/python/python=$PYTHON_VERSION/" environment.yml && \
conda env create -f environment.yml
ENV PATH /opt/conda/envs/lime/bin:$PATH
ENV CONDA_DEFAULT_ENV lime

#
## Build lime
#
RUN \
cd lime && \
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D LIME_BUILD_TESTS=ON \
-D GTEST_ROOT=/usr/local \
-D PYTHON_INCLUDE_DIR=`python -c "from __future__ import print_function; from distutils import sysconfig; print(sysconfig.get_python_inc())"` \
-D PYTHON_LIBRARY=`find $HOME/anaconda/lib -name python${PYTHON_VERSION}` \
-D LIME_BUILD_EXAMPLES=ON \
-D LIME_BUILD_STATIC_LIB=$BUILD_STATIC_LIB \
-D PYTHON_EXECUTABLE=/opt/conda/envs/lime/bin/python \
-D PYBIND11_PYTHON_VERSION=$PYTHON_VERSION \
-D LIME_BUILD_PYTHON_MODULE=ON . && \
cmake --build .
cmake --build . -- -j4

#
## Install pylime
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This library is comprised of only header files. Therefore, you do not
need to do anything other than installing OpenCV in your computer.
The library depends on **OpenCV 3.0** or later.

For the installation detail, please refer to [the reference manual](http://tatsy.github.io/lime/).

## Functions

This library supports following methods.
Expand Down Expand Up @@ -47,8 +49,8 @@ This library supports following methods.

## Samples

You can compile all the samples using CMake.
You can compile all the samples using CMake!

## Copyright

MIT License 2015, Tatsuya Yatagawa (tatsy)
MIT License 2015-2019, Tatsuya Yatagawa (tatsy)
Loading

0 comments on commit 6a91243

Please sign in to comment.