-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
968 changed files
with
53,914 additions
and
89 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
BasedOnStyle: Google |
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,5 @@ | ||
3rdparty | ||
bin | ||
lib | ||
build | ||
/inc/ |
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,147 @@ | ||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | ||
|
||
file(GLOB 3RDPARTY_LIST cmake/*.cmake) | ||
foreach(3RDPARTY_LIB ${3RDPARTY_LIST}) | ||
include (${3RDPARTY_LIB}) | ||
endforeach() | ||
|
||
project(bqassetsmgr C CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(CXX_FLAGS | ||
-g | ||
-Wextra | ||
-Wno-unused-parameter | ||
-march=native | ||
) | ||
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}") | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fPIC") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -fPIC") | ||
|
||
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") | ||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) | ||
endif() | ||
|
||
set(EXECUTABLE_OUTPUT_PATH ${SOLUTION_ROOT_DIR}/bin) | ||
set(LIBRARY_OUTPUT_PATH ${SOLUTION_ROOT_DIR}/lib) | ||
|
||
check_if_the_cmd_exists(clang-format) | ||
get_proj_ver(${PROJ_VER} ${MAJOR_VER}) | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/config.hpp.in" | ||
"${PROJECT_BINARY_DIR}/config-proj.hpp") | ||
|
||
aux_source_directory(src SRC_LIST) | ||
add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) | ||
|
||
if(${CMAKE_BUILD_TYPE} MATCHES Debug) | ||
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") | ||
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "-d") | ||
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJ_VER} SOVERSION ${MAJOR_VER}) | ||
else() | ||
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") | ||
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJ_VER} SOVERSION ${MAJOR_VER}) | ||
endif() | ||
|
||
add_dependencies(${PROJECT_NAME} ${3RDPARTY_DEPENDENCIES}) | ||
message(STATUS "3RDPARTY_DEPENDENCIES ${3RDPARTY_DEPENDENCIES}") | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC "${SOLUTION_ROOT_DIR}/bqweb/inc" | ||
PUBLIC "${SOLUTION_ROOT_DIR}/bqpub/inc" | ||
PUBLIC "${SOLUTION_ROOT_DIR}/bqipc/inc" | ||
PUBLIC "${SOLUTION_ROOT_DIR}/pub/inc" | ||
PUBLIC "${PROJECT_SOURCE_DIR}/inc" | ||
PUBLIC "${PROJECT_SOURCE_DIR}/src" | ||
PUBLIC "${PROJECT_BINARY_DIR}" | ||
PUBLIC "${YYJSON_INC_DIR}" | ||
PUBLIC "${RAPIDJSON_INC_DIR}" | ||
PUBLIC "${NLOHMANN_JSON_INC_DIR}" | ||
PUBLIC "${CPR_INC_DIR}" | ||
PUBLIC "${YAMLCPP_INC_DIR}" | ||
PUBLIC "${WEBSOCKETPP_INC_DIR}" | ||
PUBLIC "${SPDLOG_INC_DIR}" | ||
PUBLIC "${BOOST_INC_DIR}" | ||
PUBLIC "${READERWRITER_QUEUE_INC_DIR}" | ||
PUBLIC "${CONCURRENT_QUEUE_INC_DIR}" | ||
PUBLIC "${GFLAGS_INC_DIR}" | ||
PUBLIC "${MAGIC_ENUM_INC_DIR}" | ||
PUBLIC "${FMT_INC_DIR}" | ||
PUBLIC "${XXHASH_INC_DIR}" | ||
PUBLIC "${MIMALLOC_INC_DIR}" | ||
) | ||
|
||
target_link_directories(${PROJECT_NAME} | ||
PUBLIC "${SOLUTION_ROOT_DIR}/lib/" | ||
PUBLIC "${YYJSON_LIB_DIR}" | ||
PUBLIC "${NLOHMANN_JSON_LIB_DIR}" | ||
PUBLIC "${CPR_LIB_DIR}" | ||
PUBLIC "${YAMLCPP_LIB_DIR}" | ||
PUBLIC "${WEBSOCKETPP_LIB_DIR}" | ||
PUBLIC "${SPDLOG_LIB_DIR}" | ||
PUBLIC "${BOOST_LIB_DIR}" | ||
PUBLIC "${READERWRITER_QUEUE_LIB_DIR}" | ||
PUBLIC "${GFLAGS_LIB_DIR}" | ||
PUBLIC "${MAGIC_ENUM_LIB_DIR}" | ||
PUBLIC "${FMT_LIB_DIR}" | ||
PUBLIC "${XXHASH_LIB_DIR}" | ||
PUBLIC "${MIMALLOC_LIB_DIR}" | ||
) | ||
|
||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
target_link_libraries(${PROJECT_NAME} | ||
bqweb-d | ||
bqpub-d | ||
bqipc-d | ||
pub-d | ||
) | ||
else() | ||
target_link_libraries(${PROJECT_NAME} | ||
bqweb | ||
bqpub | ||
bqipc | ||
pub | ||
) | ||
endif() | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
cpr | ||
libyyjson.a | ||
libyaml-cpp.a | ||
libfmt.a | ||
libgflags.a | ||
libmimalloc.a | ||
dl | ||
pthread | ||
) | ||
|
||
option(BUILD_TESTS "Build the tests" ON) | ||
if (BUILD_TESTS) | ||
set(TEST_PROJECT_NAME ${PROJECT_NAME}-test) | ||
message(STATUS "Start building test cases.") | ||
enable_testing() | ||
add_test(NAME test COMMAND ${TEST_PROJECT_NAME} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test) | ||
add_subdirectory(test) | ||
if(${CMAKE_BUILD_TYPE} MATCHES Debug) | ||
add_custom_target(tests COMMAND ${EXECUTABLE_OUTPUT_PATH}/${TEST_PROJECT_NAME}-d) | ||
else() | ||
add_custom_target(tests COMMAND ${EXECUTABLE_OUTPUT_PATH}/${TEST_PROJECT_NAME}) | ||
endif() | ||
endif() | ||
|
||
option(BUILD_BENCH "Build the bench" ON) | ||
if (BUILD_BENCH) | ||
set(BENCH_PROJECT_NAME ${PROJECT_NAME}-bench) | ||
message(STATUS "Start building benches.") | ||
add_subdirectory(bench) | ||
if(${CMAKE_BUILD_TYPE} MATCHES Debug) | ||
add_custom_target(bench COMMAND ${EXECUTABLE_OUTPUT_PATH}/${BENCH_PROJECT_NAME}-d) | ||
else() | ||
add_custom_target(bench COMMAND ${EXECUTABLE_OUTPUT_PATH}/${BENCH_PROJECT_NAME}) | ||
endif() | ||
endif() |
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,20 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
class FixtureTest : public benchmark::Fixture { | ||
public: | ||
void SetUp(const ::benchmark::State& state) {} | ||
void TearDown(const ::benchmark::State& state) {} | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(FixtureTest, test)(benchmark::State& st) { | ||
for (auto _ : st) { | ||
int times = st.range(0); | ||
for (int i = 0; i < times; ++i) { | ||
} | ||
} | ||
} | ||
BENCHMARK_REGISTER_F(FixtureTest, test) | ||
->Unit(benchmark::kMicrosecond) | ||
->Arg(1000); | ||
|
||
BENCHMARK_MAIN(); |
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,60 @@ | ||
aux_source_directory(. BENCH_SRC_LIST) | ||
set(BENCH_SRC_LIST ${BENCH_SRC_LIST}) | ||
add_executable(${BENCH_PROJECT_NAME} ${BENCH_SRC_LIST}) | ||
|
||
if(${CMAKE_BUILD_TYPE} MATCHES Debug) | ||
set_target_properties(${BENCH_PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "-d-${PROJ_VER}") | ||
add_custom_target(link_bench_target ALL | ||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${BENCH_PROJECT_NAME}-d-${PROJ_VER}" ${EXECUTABLE_OUTPUT_PATH}/${BENCH_PROJECT_NAME}-d) | ||
else() | ||
set_target_properties(${BENCH_PROJECT_NAME} PROPERTIES RELEASE_POSTFIX "-${PROJ_VER}") | ||
add_custom_target(link_bench_target ALL | ||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${BENCH_PROJECT_NAME}-${PROJ_VER}" ${EXECUTABLE_OUTPUT_PATH}/${BENCH_PROJECT_NAME}) | ||
endif() | ||
|
||
target_include_directories(${BENCH_PROJECT_NAME} | ||
PUBLIC "${PROJECT_SOURCE_DIR}/inc" | ||
PUBLIC "${PROJECT_SOURCE_DIR}/src" | ||
PUBLIC "${MYSQLCPPCONN_INC_DIR}" | ||
PUBLIC "${YYJSON_INC_DIR}" | ||
PUBLIC "${RAPIDJSON_INC_DIR}" | ||
PUBLIC "${NLOHMANN_JSON_INC_DIR}" | ||
PUBLIC "${CPR_INC_DIR}" | ||
PUBLIC "${YAMLCPP_INC_DIR}" | ||
PUBLIC "${WEBSOCKETPP_INC_DIR}" | ||
PUBLIC "${SPDLOG_INC_DIR}" | ||
PUBLIC "${BOOST_INC_DIR}" | ||
PUBLIC "${READERWRITER_QUEUE_INC_DIR}" | ||
PUBLIC "${CONCURRENT_QUEUE_INC_DIR}" | ||
PUBLIC "${MAGIC_ENUM_INC_DIR}" | ||
PUBLIC "${FMT_INC_DIR}" | ||
PUBLIC "${XXHASH_INC_DIR}" | ||
PUBLIC "${MIMALLOC_INC_DIR}" | ||
PUBLIC "${BENCHMARK_INC_DIR}" | ||
) | ||
|
||
target_link_directories(${BENCH_PROJECT_NAME} | ||
PUBLIC "${PROJECT_SOURCE_DIR}/lib" | ||
PUBLIC "${MYSQLCPPCONN_LIB_DIR}" | ||
PUBLIC "${YYJSON_LIB_DIR}" | ||
PUBLIC "${NLOHMANN_JSON_LIB_DIR}" | ||
PUBLIC "${CPR_LIB_DIR}" | ||
PUBLIC "${YAMLCPP_LIB_DIR}" | ||
PUBLIC "${WEBSOCKETPP_LIB_DIR}" | ||
PUBLIC "${SPDLOG_LIB_DIR}" | ||
PUBLIC "${BOOST_LIB_DIR}" | ||
PUBLIC "${READERWRITER_QUEUE_LIB_DIR}" | ||
PUBLIC "${MAGIC_ENUM_LIB_DIR}" | ||
PUBLIC "${FMT_LIB_DIR}" | ||
PUBLIC "${XXHASH_LIB_DIR}" | ||
PUBLIC "${MIMALLOC_LIB_DIR}" | ||
PUBLIC "${BENCHMARK_LIB_DIR}" | ||
) | ||
|
||
target_link_libraries(${BENCH_PROJECT_NAME} | ||
libyyjson.a | ||
libfmt.a | ||
libbenchmark.a | ||
dl | ||
pthread | ||
) |
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,65 @@ | ||
#!/bin/bash | ||
set -u | ||
set -e | ||
|
||
readonly PARALLEL_COMPILE_THREAD_NUM=8 | ||
readonly SOLUTION_ROOT_DIR=/mnt/storage/work/betterquant | ||
|
||
readonly PROJ_NAME=$(pwd | awk -F'/' '{print $NF}') | ||
readonly FILE_OF_CPP="\.cpp$\|\.cc$\|\.hpp$\|\.h$" | ||
|
||
check_command_format() { | ||
readonly CORRECT_COMMAND_FORMAT='bash build.sh or bash build.sh all' | ||
[[ $# != 0 && $# != 1 ]] && echo usage: $CORRECT_COMMAND_FORMAT && exit 1 | ||
[[ $# == 1 && $1 != "all" ]] && echo usage: $CORRECT_COMMAND_FORMAT && exit 1 | ||
echo $0 $* | ||
} | ||
check_command_format $* | ||
|
||
format_src_code() { | ||
if [[ -d $1 ]]; then | ||
find $1 -type f -mmin -60 | grep $FILE_OF_CPP | xargs -t -i clang-format -i {} | ||
fi | ||
} | ||
|
||
build() { | ||
echo build $1 version | ||
build_type=$1 | ||
build_type="${build_type^}" | ||
|
||
mkdir -p build/$1 || exit 1 | ||
cd build/$1 | ||
|
||
cmake ../../ -DCMAKE_BUILD_TYPE=$build_type \ | ||
-DSOLUTION_ROOT_DIR:STRING=${SOLUTION_ROOT_DIR} || (cd - && exit 1) | ||
|
||
if [[ $# -gt 1 ]]; then | ||
make -j $PARALLEL_COMPILE_THREAD_NUM $2 || (cd - && exit 1) | ||
else | ||
make -j $PARALLEL_COMPILE_THREAD_NUM || (cd - && exit 1) | ||
fi | ||
|
||
cd - | ||
} | ||
|
||
main() { | ||
format_src_code inc/ | ||
format_src_code src/ | ||
build debug $PROJ_NAME | ||
|
||
format_src_code bench/ | ||
format_src_code test/ | ||
|
||
cd build/debug | ||
make -j $PARALLEL_COMPILE_THREAD_NUM | ||
make tests | ||
cd - | ||
|
||
[[ $# != 1 || $1 != "all" ]] && exit | ||
build release | ||
cd build/release | ||
make bench | ||
cd - | ||
} | ||
|
||
main $* |
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,36 @@ | ||
include(ExternalProject) | ||
include(cmake/config.cmake) | ||
|
||
set(ABSEIL_MAJOR_VER 20220623) | ||
set(ABSEIL_MINOR_VER 0) | ||
set(ABSEIL_PATCH_VER 0) | ||
set(ABSEIL_URL_HASH SHA256=4208129b49006089ba1d6710845a45e31c59b0ab6bff9e5788a87f55c5abd602) | ||
|
||
set(ABSEIL_VER ${ABSEIL_MAJOR_VER}.${ABSEIL_MINOR_VER}.${ABSEIL_PATCH_VER}) | ||
set(ABSEIL_ROOT ${3RDPARTY_PATH}/abseil) | ||
set(ABSEIL_INC_DIR /usr/local/include) | ||
set(ABSEIL_LIB_DIR /usr/local/lib) | ||
|
||
set(ABSEIL_URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.0.tar.gz) | ||
set(ABSEIL_CONFIGURE cd ${ABSEIL_ROOT}/src/abseil-${ABSEIL_VER} && mkdir -p build && cd build && cmake -DCMAKE_CXX_STANDARD=17 ..) | ||
set(ABSEIL_BUILD cd ${ABSEIL_ROOT}/src/abseil-${ABSEIL_VER} && cd build && cmake --build . --target all) | ||
set(ABSEIL_INSTALL cd ${ABSEIL_ROOT}/src/abseil-${ABSEIL_VER} && cd build && make install) | ||
|
||
ExternalProject_Add(abseil-${ABSEIL_VER} | ||
URL ${ABSEIL_URL} | ||
DOWNLOAD_NAME abseil-${ABSEIL_VER}.tar.gz | ||
URL_HASH ${ABSEIL_URL_HASH} | ||
PREFIX ${ABSEIL_ROOT} | ||
CONFIGURE_COMMAND ${ABSEIL_CONFIGURE} | ||
BUILD_COMMAND ${ABSEIL_BUILD} | ||
INSTALL_COMMAND ${ABSEIL_INSTALL} | ||
) | ||
|
||
set(3RDPARTY_DEPENDENCIES ${3RDPARTY_DEPENDENCIES} abseil-${ABSEIL_VER}) | ||
|
||
if (NOT EXISTS ${ABSEIL_ROOT}/src/abseil-${ABSEIL_VER}) | ||
add_custom_target(rescan-abseil ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} DEPENDS abseil-${ABSEIL_VER}) | ||
else() | ||
add_custom_target(rescan-abseil) | ||
endif() | ||
|
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,35 @@ | ||
include(ExternalProject) | ||
include(cmake/config.cmake) | ||
|
||
set(BENCHMARK_MAJOR_VER 1) | ||
set(BENCHMARK_MINOR_VER 5) | ||
set(BENCHMARK_PATCH_VER 1) | ||
set(BENCHMARK_URL_HASH SHA256=23082937d1663a53b90cb5b61df4bcc312f6dee7018da78ba00dd6bd669dfef2) | ||
|
||
set(BENCHMARK_VER ${BENCHMARK_MAJOR_VER}.${BENCHMARK_MINOR_VER}.${BENCHMARK_PATCH_VER}) | ||
set(BENCHMARK_ROOT ${3RDPARTY_PATH}/benchmark) | ||
set(BENCHMARK_INC_DIR ${BENCHMARK_ROOT}/src/benchmark-${BENCHMARK_VER}/include/) | ||
set(BENCHMARK_LIB_DIR ${BENCHMARK_ROOT}/src/benchmark-${BENCHMARK_VER}/build/src/) | ||
|
||
set(BENCHMARK_URL https://github.com/google/benchmark/archive/v${BENCHMARK_VER}.tar.gz) | ||
set(BENCHMARK_CONFIGURE cd ${BENCHMARK_ROOT}/src/benchmark-${BENCHMARK_VER} && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=release -DBENCHMARK_ENABLE_TESTING=OFF) | ||
set(BENCHMARK_BUILD cd ${BENCHMARK_ROOT}/src/benchmark-${BENCHMARK_VER} && cd build && make) | ||
|
||
ExternalProject_Add(benchmark-${BENCHMARK_VER} | ||
URL ${BENCHMARK_URL} | ||
URL_HASH ${BENCHMARK_URL_HASH} | ||
DOWNLOAD_NAME benchmark-${BENCHMARK_VER}.tar.gz | ||
PREFIX ${BENCHMARK_ROOT} | ||
CONFIGURE_COMMAND ${BENCHMARK_CONFIGURE} | ||
BUILD_COMMAND ${BENCHMARK_BUILD} | ||
INSTALL_COMMAND "" | ||
) | ||
|
||
set(3RDPARTY_DEPENDENCIES ${3RDPARTY_DEPENDENCIES} benchmark-${BENCHMARK_VER}) | ||
|
||
if (NOT EXISTS ${BENCHMARK_ROOT}/src/benchmark-${BENCHMARK_VER}) | ||
add_custom_target(rescan-benchmark ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} DEPENDS benchmark-${BENCHMARK_VER}) | ||
else() | ||
add_custom_target(rescan-benchmark) | ||
endif() | ||
|
Oops, something went wrong.