-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from senior7515/build-oss
build: first pass builds all deps.
- Loading branch information
Showing
10 changed files
with
430 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
-std=gnu++17 | ||
-std=c++17 | ||
-Isrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
cmake_minimum_required(VERSION 3.9.0) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
project(REDPANDA VERSION "0.1.0" LANGUAGES CXX) | ||
# https://cmake.org/cmake/help/v3.4/policy/CMP0065.html | ||
cmake_policy(SET CMP0065 OLD) | ||
|
||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
|
||
# CCACHE_DIR is initially provided by vtools | ||
set(CCACHE_DIR $ENV{CCACHE_DIR} CACHE PATH "ccache directory") | ||
set(ENV{CCACHE_DIR} ${CCACHE_DIR}) | ||
set(REDPANDA_DEPS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps_install | ||
CACHE STRING "Managed dependencies install directory") | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
list(APPEND BASE_LD_FLAGS_LIST | ||
-L${REDPANDA_DEPS_INSTALL_DIR}/lib | ||
-L${REDPANDA_DEPS_INSTALL_DIR}/lib64 | ||
) | ||
set(PKG_CONFIG_PATH_LIST | ||
${REDPANDA_DEPS_INSTALL_DIR}/lib64/pkgconfig | ||
${REDPANDA_DEPS_INSTALL_DIR}/share/pkgconfig | ||
${REDPANDA_DEPS_INSTALL_DIR}/lib/pkgconfig | ||
) | ||
|
||
list(APPEND BASE_CXX_FLAGS_LIST -fPIC) | ||
list(APPEND BASE_C_FLAGS_LIST -fPIC) | ||
if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug") | ||
list(APPEND BASE_CXX_FLAGS_LIST | ||
-fsanitize=undefined | ||
-fsanitize=address | ||
) | ||
list(APPEND BASE_C_FLAGS_LIST | ||
-fsanitize=undefined | ||
-fsanitize=address | ||
) | ||
list(APPEND BASE_LD_FLAGS_LIST | ||
-fsanitize=undefined | ||
-fsanitize=address | ||
) | ||
endif() | ||
|
||
# join flag lists | ||
string(JOIN " " BASE_C_FLAGS ${BASE_C_FLAGS_LIST}) | ||
string(JOIN " " BASE_CXX_FLAGS ${BASE_CXX_FLAGS_LIST}) | ||
string(JOIN " " BASE_LD_FLAGS ${BASE_LD_FLAGS_LIST}) | ||
string(JOIN ":" PKG_CONFIG_PATH ${PKG_CONFIG_PATH_LIST}) | ||
find_package(PkgConfig REQUIRED) | ||
set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_CXX_FLAGS}") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_C_FLAGS}") | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING | ||
"Choose: Debug, Release, RelWithDebInfo, MinSizeRel." FORCE) | ||
endif() | ||
|
||
if(REDPANDA_DEPS_ONLY AND NOT V_MANAGE_DEPS) | ||
message(FATAL_ERROR | ||
"To build managed dependencies V_MANAGE_DEPS must be enabled") | ||
endif() | ||
|
||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${BASE_LD_FLAGS} -pie") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${BASE_LD_FLAGS}") | ||
set(CMAKE_MODULE_LINKER_FLAGS "${BASE_LD_FLAGS}") | ||
|
||
# don't export() the contents to registry | ||
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON CACHE INTERNAL "" FORCE) | ||
# disable system level registry /usr/local/share/cmake/* | ||
set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON CACHE INTERNAL "" FORCE) | ||
# disable user package registry ~/.cmake/* | ||
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON CACHE INTERNAL "" FORCE) | ||
set(REDPANDA_DEPS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps_build) | ||
# build type specific flags | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) | ||
set(CMAKE_C_FLAGS_BUILD_TYPE ${CMAKE_C_FLAGS_${BUILD_TYPE}}) | ||
set(CMAKE_CXX_FLAGS_BUILD_TYPE ${CMAKE_CXX_FLAGS_${BUILD_TYPE}}) | ||
configure_file(oss.cmake.in ${REDPANDA_DEPS_BUILD_DIR}/CMakeLists.txt @ONLY) | ||
# wire up dependency search paths. | ||
list(APPEND CMAKE_PREFIX_PATH "${REDPANDA_DEPS_INSTALL_DIR}") | ||
set(BASE_LD_FLAGS "${BASE_LD_FLAGS} -L${REDPANDA_DEPS_INSTALL_DIR}/lib") | ||
if(NOT REDPANDA_DEPS_SKIP_BUILD) | ||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${REDPANDA_DEPS_BUILD_DIR}) | ||
if(result) | ||
message(FATAL_ERROR "CMake step for v::deps failed: ${result}") | ||
endif() | ||
execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${REDPANDA_DEPS_BUILD_DIR}) | ||
if(result) | ||
message(FATAL_ERROR "Build step for v::build failed: ${result}") | ||
endif() | ||
endif() | ||
|
||
# from seastar/CMakeLists.txt. unfortunately this snippet doesn't appear to be | ||
# installed along with the rest of seastar. | ||
function (seastar_generate_swagger) | ||
set (one_value_args TARGET VAR IN_FILE OUT_FILE) | ||
cmake_parse_arguments (args "" "${one_value_args}" "" ${ARGN}) | ||
get_filename_component (out_dir ${args_OUT_FILE} DIRECTORY) | ||
if(REDPANDA_DEPS_ONLY) | ||
set (generator "${REDPANDA_DEPS_INSTALL_DIR}/bin/seastar-json2code.py") | ||
else() | ||
find_program(GENERATOR "seastar-json2code.py") | ||
set (generator "${GENERATOR}") | ||
endif() | ||
|
||
add_custom_command ( | ||
DEPENDS | ||
${args_IN_FILE} | ||
${generator} | ||
OUTPUT ${args_OUT_FILE} | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${out_dir} | ||
COMMAND ${generator} -f ${args_IN_FILE} -o ${args_OUT_FILE}) | ||
|
||
add_custom_target (${args_TARGET} | ||
DEPENDS ${args_OUT_FILE}) | ||
|
||
set (${args_VAR} ${args_OUT_FILE} PARENT_SCOPE) | ||
endfunction () | ||
|
||
if(REDPANDA_DEPS_ONLY) | ||
message("Finished building/installing external project dependencies.") | ||
return() | ||
endif() | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
||
# add code | ||
include(ccache) | ||
include(testing) | ||
include(set_option) | ||
include(v_library) | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -x | ||
root=$(git rev-parse --show-toplevel) | ||
if [[ -z ${CC} ]]; then export CC=/usr/bin/gcc; fi | ||
if [[ -z ${CXX} ]]; then export CXX=/usr/bin/g++; fi | ||
if [[ ! -z ${CCACHE_DIR} && -e /dev/shm ]]; then export CCACHE_DIR=/dev/shm/redpanda; fi | ||
|
||
# Change Debug via -DCMAKE_BUILD_TYPE=Debug | ||
cmake -DCMAKE_BUILD_TYPE=Release \ | ||
-B$root/build \ | ||
-H$root \ | ||
-GNinja \ | ||
-DCMAKE_C_COMPILER=$CC \ | ||
-DCMAKE_CXX_COMPILER=$CXX | ||
|
||
(cd $root/build && ninja && ctest -R _rpunit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
echo "installing seastar dependencies" | ||
if [ -f "/etc/os-release" ]; then | ||
. /etc/os-release | ||
elif [ -f "/etc/arch-release" ]; then | ||
export ID=arch | ||
else | ||
echo "/etc/os-release missing." | ||
exit 1 | ||
fi | ||
|
||
deb_deps=( | ||
curl | ||
libzstd-dev | ||
libsnappy-dev | ||
libsystemd-dev | ||
rapidjson-dev | ||
libxxhash-dev | ||
python3-venv | ||
python3-jinja2 | ||
) | ||
fedora_deps=( | ||
curl | ||
libzstd-static | ||
libzstd-devel | ||
snappy-devel | ||
systemd-devel | ||
rapidjson-devel | ||
xxhash-devel | ||
python3-virtualenv | ||
python3-jinja2 | ||
) | ||
|
||
|
||
case "$ID" in | ||
ubuntu|debian) | ||
apt-get install -y "${deb_deps[@]}" | ||
;; | ||
fedora) | ||
dnf install -y "${fedora_deps[@]}" | ||
;; | ||
*) | ||
echo "Please help us make the script better by sending patches with your OS $ID" | ||
exit 1 | ||
;; | ||
esac | ||
# needed for unit tests | ||
sudo sysctl -w fs.aio-max-nr=10485760 | ||
curl -1sLf "https://raw.githubusercontent.com/vectorizedio/seastar/master/install-dependencies.sh" | sudo -E bash |
Oops, something went wrong.