Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
KEP-1017 Integrate boost build
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruck committed Jan 22, 2019
1 parent 742f80c commit 6346fd0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 100 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ compiler:

before_script:
- cd ${TRAVIS_BUILD_DIR}
- travis_wait source $TRAVIS_BUILD_DIR/toolchain/install-boost.sh
- mkdir build
- cd build
- >
source ${TRAVIS_BUILD_DIR}/toolchain/install-boost.sh && ${CMAKE_COMMAND} -DBOOST_ROOT:PATHNAME=$BOOST_ROOT
${CMAKE_COMMAND}
-DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
-DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}
-DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH} ..
script:
- ${CXX} --version
- echo CXXFLAGS=${CXXFLAGS}
- make boost
- make openssl
- make rocksdb
- make
Expand All @@ -102,7 +102,7 @@ script:
after_success:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
coveralls -r ${TRAVIS_BUILD_DIR} -e 'build/openssl' -e 'build/rocksdb' -e 'build/jsoncpp' -e 'build/googletest' -e 'build/proto' -e 'build/CMakeFiles' -e 'build/swarm_version.hpp' -e 'audit/test' -e 'bootstrap/test' -e 'chaos/test' -e 'crud/test' -e 'crypto/test' -e 'ethereum/test' -e 'http/test' -e 'mocks' -e 'node/test' -e 'options/test' -e 'pbft/test' -e 'raft/test' -e 'status/test' -e 'storage/test' -e 'swarm' -e 'include' -e 'utils/test' --gcov-options '\-lp'
coveralls -r ${TRAVIS_BUILD_DIR} -e 'build/boost' -e 'build/openssl' -e 'build/rocksdb' -e 'build/jsoncpp' -e 'build/googletest' -e 'build/proto' -e 'build/CMakeFiles' -e 'build/swarm_version.hpp' -e 'audit/test' -e 'bootstrap/test' -e 'chaos/test' -e 'crud/test' -e 'crypto/test' -e 'ethereum/test' -e 'http/test' -e 'mocks' -e 'node/test' -e 'options/test' -e 'pbft/test' -e 'raft/test' -e 'status/test' -e 'storage/test' -e 'swarm' -e 'include' -e 'utils/test' --gcov-options '\-lp'
fi
- echo ${TRAVIS_BRANCH}
- if [ "$TRAVIS_BRANCH" = "master" ] ; then PACKAGE_COMPONENT="stable" ; else PACKAGE_COMPONENT="unstable" ; fi
Expand Down
22 changes: 3 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,17 @@ include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(SYSTEM ${PROTOBUF_INCLUDE_DIR})

set(REQUIRED_BOOST "1.68.0")
set(Boost_USE_STATIC_LIBS on)

find_package(
Boost ${REQUIRED_BOOST}
REQUIRED COMPONENTS
log
program_options
system
thread
serialization
)

if(Boost_FOUND)
message(STATUS "Boost: ${Boost_INCLUDE_DIRS}")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
endif()

find_package(CURL REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(REQUIRED_BOOST "1.68.0")

include(cmake/boost.cmake)
include(cmake/jsoncpp.cmake)
include(cmake/rocksdb.cmake)
include(cmake/googletest.cmake)
include(cmake/openssl.cmake)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})

enable_testing()
Expand Down
42 changes: 3 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,7 @@ If you want to deploy your swarm immediately you can use our docker-compose quic

### Installation - macOSX

**Boost**

```text
$ export BOOST_VERSION="1.68.0"
$ export BOOST_INSTALL_DIR="$HOME/myboost"
$ mkdir -p ~/myboost
$ toolchain/install-boost.sh
```

This will result in a custom Boost install at `~/myboost/1_68_0/`that will not collide with your system's Boost.

**Other dependencies \(Protobuf, CMake\)**
**Dependencies \(Protobuf, CMake\)**

```text
$ brew update && brew install protobuf && brew install snappy && brew install lz4 && brew upgrade cmake
Expand All @@ -53,20 +41,6 @@ $ brew install ccache

### Installation - Ubuntu

**Boost**

Open up a console and install the compatible version of Boost:

```text
$ ENV BOOST_VERSION="1.68.0"
$ ENV BOOST_INSTALL_DIR="$HOME/myboost"
$ mkdir -p ~/myboost
$ toolchain/install-boost.sh
```

This will result in a custom Boost install at `~/myboost/1_68_0/`that will not overwrite your system's Boost.

**CMake**

```text
Expand All @@ -90,16 +64,6 @@ If available, cmake will attempt to use ccache \([https://ccache.samba.org](http
$ sudo apt-get install ccache
```

### Building the Daemon with CLion IDE

Ensure that you set your cmake args to pass in:

```text
-DBOOST_ROOT:PATHNAME=$HOME/myboost/1_68_0/
```

The project root can be directly imported into CLion.

### Building the Daemon from Command Line Interface \(CLI\)

Here are the steps to build the Daemon and unit test application from the command line:
Expand All @@ -109,7 +73,7 @@ Here are the steps to build the Daemon and unit test application from the comman
```text
$ mkdir build
$ cd build
$ cmake -DBOOST_ROOT:PATHNAME=$HOME/myboost/1_68_0/ ..
$ cmake ..
$ sudo make install
```

Expand All @@ -118,7 +82,7 @@ $ sudo make install
```text
$ mkdir build
$ cd build
$ ~/mycmake/bin/cmake -DBOOST_ROOT:PATHNAME=$HOME/myboost/1_68_0/ ..
$ ~/mycmake/bin/cmake ..
$ sudo make install
```

Expand Down
2 changes: 1 addition & 1 deletion cmake/add_gmock_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include(GoogleTest)
function(add_gmock_test target)
set(target ${target}_tests)
add_executable(${target} ${test_srcs})
add_dependencies(${target} googletest jsoncpp ${test_deps})
add_dependencies(${target} boost googletest jsoncpp ${test_deps})
target_link_libraries(${target} ${test_libs} ${GMOCK_BOTH_LIBRARIES} ${Boost_LIBRARIES} ${JSONCPP_LIBRARIES} ${test_link} pthread)
target_include_directories(${target} PRIVATE ${JSONCPP_INCLUDE_DIRS} ${ROCKSDB_INCLUDE_DIRS})
gtest_discover_tests(${target})
Expand Down
66 changes: 66 additions & 0 deletions cmake/boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (C) 2018 Bluzelle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

include(ExternalProject)
include(ProcessorCount)

message(STATUS "Boost: ${REQUIRED_BOOST}")

set(BOOST_TARBALL "boost_${REQUIRED_BOOST}")
string(REPLACE "." "_" BOOST_TARBALL ${BOOST_TARBALL})
string(APPEND BOOST_TARBALL ".tar.gz")

set(BOOST_LIBS "chrono,program_options,random,regex,system,thread,log,serialization")

# Prevent travis gcc crashes...
if (DEFINED ENV{TRAVIS})
set(BUILD_FLAGS -j8)
else()
ProcessorCount(N)
if(NOT N EQUAL 0)
set(BUILD_FLAGS -j${N})
endif()
endif()

ExternalProject_Add(boost
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/boost"
URL "http://sourceforge.net/projects/boost/files/boost/${REQUIRED_BOOST}/${BOOST_TARBALL}"
TIMEOUT 30
INSTALL_COMMAND ""
CONFIGURE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost/bootstrap.sh" "--with-libraries=${BOOST_LIBS}"
BUILD_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost/b2" link=static "${BUILD_FLAGS} "
BUILD_IN_SOURCE true
DOWNLOAD_NO_PROGRESS true
)

set_property(DIRECTORY PROPERTY CLEAN_NO_CUSTOM ${CMAKE_CURRENT_BINARY_DIR}/boost)

ExternalProject_Get_Property(boost source_dir)
set(Boost_INCLUDE_DIRS ${source_dir})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

set(Boost_LIBRARIES
${source_dir}/stage/lib/libboost_log.a
${source_dir}/stage/lib/libboost_program_options.a
${source_dir}/stage/lib/libboost_system.a
${source_dir}/stage/lib/libboost_thread.a
pthread
${source_dir}/stage/lib/libboost_serialization.a
${source_dir}/stage/lib/libboost_date_time.a
${source_dir}/stage/lib/libboost_log_setup.a
${source_dir}/stage/lib/libboost_filesystem.a
${source_dir}/stage/lib/libboost_regex.a
${source_dir}/stage/lib/libboost_chrono.a
${source_dir}/stage/lib/libboost_atomic.a
)
2 changes: 1 addition & 1 deletion swarm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(swarm main.cpp)
add_dependencies(swarm jsoncpp rocksdb)
add_dependencies(swarm boost jsoncpp rocksdb)
target_include_directories(swarm PRIVATE ${JSONCPP_INCLUDE_DIRS} ${ROCKSDB_INCLUDE_DIRS})
target_link_libraries(swarm node http raft pbft audit crud chaos options ethereum bootstrap storage crypto proto ${Protobuf_LIBRARIES} status ${ROCKSDB_LIBRARIES} ${Boost_LIBRARIES} ${JSONCPP_LIBRARIES} pthread)
37 changes: 0 additions & 37 deletions toolchain/install-boost.sh

This file was deleted.

0 comments on commit 6346fd0

Please sign in to comment.