Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into trunk/hex-api
Browse files Browse the repository at this point in the history
# Conflicts:
#	example/genesis.block
#	irohad/torii/impl/command_service_transport_grpc.cpp
#	test/module/iroha-cli/client_test.cpp
#	test/module/irohad/torii/torii_service_test.cpp
  • Loading branch information
kamilsa committed Dec 27, 2018
2 parents 6e53bd3 + 5805ec5 commit 4813dbf
Show file tree
Hide file tree
Showing 555 changed files with 2,789 additions and 8,246 deletions.
2 changes: 1 addition & 1 deletion .jenkinsci/artifacts.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def uploadArtifacts(filePaths, uploadPath, artifactServers=['nexus.iroha.tech'])

withCredentials([usernamePassword(credentialsId: 'ci_nexus', passwordVariable: 'NEXUS_PASS', usernameVariable: 'NEXUS_USER')]) {
artifactServers.each {
sh(script: "while read line; do curl -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file \$line https://${it}/repository/artifacts/${uploadPath}/ ; done < \$(pwd)/batch.txt")
sh(script: "while read line; do curl --http1.1 -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file \$line https://${it}/repository/artifacts/${uploadPath}/ ; done < \$(pwd)/batch.txt")
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion .jenkinsci/docker-pull-or-build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ def dockerPullOrUpdate(imageName, currentDockerfileURL, previousDockerfileURL, r
// Worst case scenario. We cannot count on the local cache
// because Dockerfile may contain apt-get entries that would try to update
// from invalid (stale) addresses
iC = docker.build("${DOCKER_REGISTRY_BASENAME}:${commit}-${BUILD_NUMBER}", "${buildOptions} --no-cache -f /tmp/${env.GIT_COMMIT}/f1 /tmp/${env.GIT_COMMIT}")
if(remoteFilesDiffer(currentDockerfileURL, referenceDockerfileURL)){
// Dockerfile has been changed compared to the develop
iC = docker.build("${DOCKER_REGISTRY_BASENAME}:${commit}-${BUILD_NUMBER}", "${buildOptions} --no-cache -f /tmp/${env.GIT_COMMIT}/f1 /tmp/${env.GIT_COMMIT}")
} else {
// Dockerfile is same as develop, we can just pull it
iC = docker.image("${DOCKER_REGISTRY_BASENAME}:${imageName}")
}
}
else {
// first commit in this branch or Dockerfile modified
Expand Down
25 changes: 22 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,31 @@ endif()
PROJECT(iroha C CXX)

SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
SET(CMAKE_CXX_FLAGS "-std=c++14 -Wall -fdiagnostics-color=always")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-error=deprecated-declarations")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0")
if (NOT MSVC)
SET(CMAKE_CXX_FLAGS "-std=c++14 -Wall -fdiagnostics-color=always")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-error=deprecated-declarations")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0")
endif()
SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
SET(CMAKE_INSTALL_RPATH "../lib")

if(WIN32)
# We have to set _WIN32_WINNT for gRPC
if(${CMAKE_SYSTEM_VERSION} EQUAL 10) # Windows 10
add_definitions(-D _WIN32_WINNT=0x0A00)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1
add_definitions(-D _WIN32_WINNT=0x0603)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8
add_definitions(-D _WIN32_WINNT=0x0602)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
add_definitions(-D _WIN32_WINNT=0x0601)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista
add_definitions(-D _WIN32_WINNT=0x0600)
else() # Windows XP (5.1)
add_definitions(-D _WIN32_WINNT=0x0501)
endif()
endif()

if(COVERAGE)
find_program(LCOV_PROGRAM lcov)
if(NOT LCOV_PROGRAM)
Expand Down
7 changes: 6 additions & 1 deletion cmake/Modules/Findgflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ endif ()
set_target_properties(gflags PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${gflags_INCLUDE_DIR}
IMPORTED_LOCATION ${gflags_LIBRARY}
INTERFACE_LINK_LIBRARIES "pthread"
)

if (NOT MSVC)
set_target_properties(gflags PROPERTIES
INTERFACE_LINK_LIBRARIES "pthread"
)
endif ()
7 changes: 6 additions & 1 deletion cmake/Modules/Findgrpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ endif ()

set_target_properties(grpc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${grpc_INCLUDE_DIR}
INTERFACE_LINK_LIBRARIES "pthread;dl"
IMPORTED_LOCATION ${grpc_LIBRARY}
)

if (NOT MSVC)
set_target_properties(grpc PROPERTIES
INTERFACE_LINK_LIBRARIES "pthread;dl"
)
endif ()

set_target_properties(grpc++ PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${grpc_INCLUDE_DIR}
INTERFACE_LINK_LIBRARIES grpc
Expand Down
39 changes: 30 additions & 9 deletions cmake/Modules/Findpq.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ mark_as_advanced(pq_INCLUDE_DIR)
find_path(postgres_INCLUDE_DIR postgres_ext.h PATH_SUFFIXES postgresql)
mark_as_advanced(postgres_INCLUDE_DIR)

find_library(pq_LIBRARY pq)
# Windows libraries are usually not prefixed with 'lib', however this library
# has such a prefix, therefore we need to search for libpq instead of pq on
# Windows
find_library(pq_LIBRARY NAMES pq libpq)
mark_as_advanced(pq_LIBRARY)

find_program(pg_config_EXECUTABLE pg_config)
mark_as_advanced(pg_config_EXECUTABLE)
# Debug library has 'd' suffix on Windows
if (MSVC)
find_library(pqd_LIBRARY NAMES pqd libpqd)
mark_as_advanced(pqd_LIBRARY)
endif ()

if (NOT MSVC)
find_program(pg_config_EXECUTABLE pg_config)
mark_as_advanced(pg_config_EXECUTABLE)
set(pg_config_REQUIRED pg_config_EXECUTABLE)
endif ()

find_package_handle_standard_args(pq DEFAULT_MSG
pq_INCLUDE_DIR
postgres_INCLUDE_DIR
pq_LIBRARY
pg_config_EXECUTABLE
${pg_config_REQUIRED}
)

set(URL https://git.postgresql.org/git/postgresql.git)
Expand Down Expand Up @@ -50,17 +62,26 @@ endif ()
get_filename_component(pq_LIBRARY_DIR ${pq_LIBRARY} DIRECTORY)
mark_as_advanced(pq_LIBRARY_DIR)

get_filename_component(pg_config_EXECUTABLE_DIR ${pg_config_EXECUTABLE} DIRECTORY)
mark_as_advanced(pg_config_EXECUTABLE_DIR)
if (MSVC)
set_target_properties(pq PROPERTIES
IMPORTED_LOCATION_DEBUG ${pqd_LIBRARY}
IMPORTED_LOCATION_RELEASE ${pq_LIBRARY}
)
endif ()

set_target_properties(pq PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${pq_INCLUDE_DIR};${postgres_INCLUDE_DIR}"
IMPORTED_LOCATION ${pq_LIBRARY}
)

set_target_properties(pg_config PROPERTIES
IMPORTED_LOCATION ${pg_config_EXECUTABLE}
)
if (NOT MSVC)
get_filename_component(pg_config_EXECUTABLE_DIR ${pg_config_EXECUTABLE} DIRECTORY)
mark_as_advanced(pg_config_EXECUTABLE_DIR)

set_target_properties(pg_config PROPERTIES
IMPORTED_LOCATION ${pg_config_EXECUTABLE}
)
endif ()

if(ENABLE_LIBS_PACKAGING)
add_install_step_for_lib(${pq_LIBRARY})
Expand Down
11 changes: 8 additions & 3 deletions cmake/Modules/Findsoci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ mark_as_advanced(SOCI_INCLUDE_DIRS)

find_library(
SOCI_LIBRARY
NAMES soci_core
NAMES soci_core soci_core_3_2
HINTS ${SOCI_INCLUDE_DIR}/..
PATH_SUFFIXES lib${LIB_SUFFIX})
mark_as_advanced(SOCI_LIBRARY)

find_library(
SOCI_postgresql_PLUGIN
NAMES soci_postgresql
NAMES soci_postgresql soci_postgresql_3_2
HINTS ${SOCI_INCLUDE_DIR}/..
PATH_SUFFIXES lib${LIB_SUFFIX})
mark_as_advanced(SOCI_postgresql_PLUGIN)
Expand Down Expand Up @@ -76,9 +76,14 @@ endif ()
set_target_properties(SOCI::core PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SOCI_LIBRARY}"
INTERFACE_LINK_LIBRARIES dl
)

if (NOT MSVC)
set_target_properties(SOCI::core PROPERTIES
INTERFACE_LINK_LIBRARIES dl
)
endif ()

set_target_properties(SOCI::postgresql PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SOCI_postgresql_PLUGIN}"
Expand Down
103 changes: 92 additions & 11 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ find_package(PackageHandleStandardArgs)

include(ExternalProject)

set(EP_PREFIX "${PROJECT_SOURCE_DIR}/external")
set(EP_PREFIX "${PROJECT_BINARY_DIR}/external")
set_directory_properties(PROPERTIES
EP_PREFIX ${EP_PREFIX}
)
Expand All @@ -27,13 +27,73 @@ find_package(spdlog)
# protobuf #
################################
option(FIND_PROTOBUF "Try to find protobuf in system" ON)
find_package(protobuf)
if (MSVC)
find_package(Protobuf REQUIRED CONFIG)
add_library(protobuf INTERFACE IMPORTED)
target_link_libraries(protobuf INTERFACE
protobuf::libprotobuf
)

get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES)

get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELEASE)
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_DEBUG)
endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_NOCONFIG)
endif()

add_executable(protoc IMPORTED)
set_target_properties(protoc PROPERTIES
IMPORTED_LOCATION ${Protobuf_PROTOC_EXECUTABLE}
)
else ()
find_package(protobuf)
endif()

#########################
# gRPC #
#########################
option(FIND_GRPC "Try to find gRPC in system" ON)
find_package(grpc)
if (MSVC)
find_package(gRPC REQUIRED CONFIG)

add_library(grpc INTERFACE IMPORTED)
target_link_libraries(grpc INTERFACE
gRPC::grpc
)
add_library(grpc++ INTERFACE IMPORTED)
target_link_libraries(grpc++ INTERFACE
gRPC::grpc++
)
add_library(gpr INTERFACE IMPORTED)
target_link_libraries(gpr INTERFACE
gRPC::gpr
)

get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin
IMPORTED_LOCATION_RELEASE)
if(NOT EXISTS "${gRPC_CPP_PLUGIN_EXECUTABLE}")
get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin
IMPORTED_LOCATION_DEBUG)
endif()
if(NOT EXISTS "${gRPC_CPP_PLUGIN_EXECUTABLE}")
get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin
IMPORTED_LOCATION_NOCONFIG)
endif()

add_executable(grpc_cpp_plugin IMPORTED)
set_target_properties(grpc_cpp_plugin PROPERTIES
IMPORTED_LOCATION ${gRPC_CPP_PLUGIN_EXECUTABLE}
)
else ()
find_package(grpc)
endif()

################################
# rapidjson #
Expand All @@ -53,7 +113,11 @@ find_package(soci)
################################
# gflags #
################################
find_package(gflags)
if (MSVC)
find_package(gflags REQUIRED CONFIG)
else ()
find_package(gflags)
endif()

##########################
# rx c++ #
Expand All @@ -63,7 +127,15 @@ find_package(rxcpp)
##########################
# TBB #
##########################
find_package(tbb)
if (MSVC)
find_package(TBB REQUIRED CONFIG)
add_library(tbb INTERFACE IMPORTED)
target_link_libraries(tbb INTERFACE
TBB::tbb
)
else ()
find_package(tbb)
endif()

##########################
# boost #
Expand All @@ -74,12 +146,21 @@ find_package(Boost 1.65.0 REQUIRED
system
thread
)

add_library(boost INTERFACE IMPORTED)
set_target_properties(boost PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}"
)
if (MSVC)
add_library(boost INTERFACE IMPORTED)
target_link_libraries(boost INTERFACE
Boost::boost
Boost::filesystem
Boost::system
Boost::thread
)
else ()
add_library(boost INTERFACE IMPORTED)
set_target_properties(boost PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}"
)
endif()

if(ENABLE_LIBS_PACKAGING)
foreach (library ${Boost_LIBRARIES})
Expand Down
13 changes: 11 additions & 2 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,19 @@ function(compile_proto_only_grpc_to_cpp PROTO)
string(REGEX REPLACE "\\.proto$" "_mock.grpc.pb.h" GEN_GRPC_PB_MOCK_HEADER ${PROTO})
set(TEST_OUTPUT ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB_MOCK_HEADER})
endif(TESTING)
if (MSVC)
set(GEN_COMMAND "${Protobuf_PROTOC_EXECUTABLE}")
set(GEN_ARGS ${Protobuf_INCLUDE_DIR})
set(GEN_PLUGIN "${gRPC_CPP_PLUGIN_EXECUTABLE}")
else()
set(GEN_COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${protobuf_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH} "${protoc_EXECUTABLE}")
set(GEN_ARGS ${protobuf_INCLUDE_DIR})
set(GEN_PLUGIN "${grpc_CPP_PLUGIN}")
endif()
add_custom_command(
OUTPUT ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB_HEADER} ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB} ${TEST_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${protobuf_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH} "${protoc_EXECUTABLE}"
ARGS -I${protobuf_INCLUDE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} ${ARGN} --grpc_out=${GENERATE_MOCKS}${SCHEMA_OUT_DIR} --plugin=protoc-gen-grpc="${grpc_CPP_PLUGIN}" ${PROTO}
COMMAND ${GEN_COMMAND}
ARGS -I${GEN_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR} ${ARGN} --grpc_out=${GENERATE_MOCKS}${SCHEMA_OUT_DIR} --plugin=protoc-gen-grpc=${GEN_PLUGIN} ${PROTO}
DEPENDS grpc_cpp_plugin ${SCHEMA_PATH}/${PROTO}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
Expand Down
9 changes: 9 additions & 0 deletions docker/develop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN set -e; \
add-apt-repository -y ppa:ubuntu-toolchain-r/test; \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -; \
echo 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main' >> /etc/apt/sources.list; \
echo 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main' >> /etc/apt/sources.list; \
apt-get update

RUN set -e; \
Expand All @@ -38,6 +39,14 @@ RUN set -e; \
gcovr cppcheck doxygen rsync graphviz graphviz-dev unzip vim zip; \
apt-get -y clean

# compiler clang-7 and libc++ only on x86_64, for debug purpose
RUN set -e; \
if [ `uname -m` = "x86_64" ]; then \
apt-get -y --no-install-recommends install \
clang-7 lldb-7 lld-7 libc++-7-dev libc++abi-7-dev; \
apt-get -y clean; \
fi

# install cmake 3.11.4
RUN set -e; \
git clone https://gitlab.kitware.com/cmake/cmake.git /tmp/cmake; \
Expand Down
Loading

0 comments on commit 4813dbf

Please sign in to comment.