Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ if (NOT WIN32)
endif ()
endif ()

option(BUILD_TEST "Build tests" OFF)
message("cmake using: BUILD_TEST=${BUILD_TEST}")

option(ENABLE_ANTLR4 "Enable ANTLR4 runtime" ON)
message("cmake using: ENABLE_ANTLR4=${ENABLE_ANTLR4}")

option(ENABLE_SNAPPY "Enable Google Snappy compression" ON)
message("cmake using: ENABLE_SNAPPY=${ENABLE_SNAPPY}")

option(ENABLE_LZ4 "Enable LZ4 compression" ON)
message("cmake using: ENABLE_LZ4=${ENABLE_LZ4}")

option(ENABLE_LZOKAY "Enable LZOKAY compression" ON)
message("cmake using: ENABLE_LZOKAY=${ENABLE_LZOKAY}")

option(ENABLE_ZLIB "Enable Zlib compression" ON)
message("cmake using: ENABLE_ZLIB=${ENABLE_ZLIB}")

# All libs will be stored here, including libtsfile, compress-encoding lib.
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
Expand All @@ -106,9 +123,14 @@ add_subdirectory(third_party)
set(CMAKE_CXX_FLAGS "${SAVED_CXX_FLAGS}")

add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(examples)
if (TESTS_ENABLED)
add_dependencies(TsFile_Test tsfile)
if (BUILD_TEST)
add_subdirectory(test)
if (TESTS_ENABLED)
add_dependencies(TsFile_Test tsfile)
endif ()
else()
message("BUILD_TEST is OFF, skipping test directory")
endif ()

add_subdirectory(examples)

66 changes: 50 additions & 16 deletions cpp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,38 @@ use_cpp11=1
enable_cov=0
debug_se=0
run_cov_only=0
enable_antlr4=ON

enable_snappy=ON
enable_lz4=ON
enable_lzokay=ON
enable_zlib=ON

shell_dir=$(cd "$(dirname "$0")";pwd)

# 添加get_key_value函数
get_key_value() {
echo "${1#*=}"
}

function print_config()
{
echo "build_type=$build_type"
echo "build_test=$build_test"
echo "use_cpp11=$use_cpp11"
echo "enable_cov=$enable_cov"
echo "enable_asan=$enable_asan"
echo "enable_antlr4=$enable_antlr4"
echo "enable_snappy=$enable_snappy"
echo "enable_lz4=$enable_lz4"
echo "enable_lzokay=$enable_lzokay"
echo "enable_zlib=$enable_zlib"
}

function run_test_for_cov()
{
# sh ${shell_dir}/scripts/regression_unittest.sh
sh ${shell_dir}/test/libtsfile_test/run_sdk_tests.sh
sh ${shell_dir}/test/libtsfile_test/run_sdk_tests.sh
}

parse_options()
Expand All @@ -53,20 +69,40 @@ parse_options()
run_cov)
run_cov_only=1;;
-t=*)
build_type=`get_key_value "$1"`;;
build_type=$(get_key_value "$1");;
-t)
shift
build_type=`get_key_value "$1"`;;
build_type=$(get_key_value "$1");;
-a=*)
enable_asan=`get_key_value "$1"`;;
enable_asan=$(get_key_value "$1");;
-a)
shift
enable_asan=`get_key_value "$1"`;;
enable_asan=$(get_key_value "$1");;
-c=*)
enable_cov=`get_key_value "$1"`;;
enable_cov=$(get_key_value "$1");;
-c)
shift
enable_cov=`get_key_value "$1"`;;
enable_cov=$(get_key_value "$1");;
--enable-antlr4=*)
enable_antlr4=$(get_key_value "$1");;
--enable-snappy=*)
enable_snappy=$(get_key_value "$1");;
--enable-lz4=*)
enable_lz4=$(get_key_value "$1");;
--enable-lzokay=*)
enable_lzokay=$(get_key_value "$1");;
--enable-zlib=*)
enable_zlib=$(get_key_value "$1");;
--disable-antlr4)
enable_antlr4=OFF;;
--disable-snappy)
enable_snappy=OFF;;
--disable-lz4)
enable_lz4=OFF;;
--disable-lzokay)
enable_lzokay=OFF;;
--disable-zlib)
enable_zlib=OFF;;
#-h | --help)
# usage
# exit 0;;
Expand Down Expand Up @@ -127,14 +163,12 @@ cmake ../../ \
-DUSE_CPP11=$use_cpp11 \
-DENABLE_COV=$enable_cov \
-DDEBUG_SE=$debug_se \
-DBUILD_TSFILE_ONLY=$build_tsfile_only
-DENABLE_ANTLR4=$enable_antlr4 \
-DBUILD_TSFILE_ONLY=$build_tsfile_only \
-DENABLE_SNAPPY=$enable_snappy \
-DENABLE_LZ4=$enable_lz4 \
-DENABLE_LZOKAY=$enable_lzokay \
-DENABLE_ZLIB=$enable_zlib

VERBOSE=1 make
VERBOSE=1 make install







VERBOSE=1 make install
12 changes: 12 additions & 0 deletions cpp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<coverage.enabled>OFF</coverage.enabled>
<build.type>Release</build.type>
<enable.asan>OFF</enable.asan>
<build.test>ON</build.test>
<enable.snappy>ON</enable.snappy>
<enable.lz4>ON</enable.lz4>
<enable.lzokay>ON</enable.lzokay>
<enable.zlib>ON</enable.zlib>
<enable.antlr4>ON</enable.antlr4>
</properties>
<build>
<sourceDirectory>${project.basedir}</sourceDirectory>
Expand Down Expand Up @@ -74,6 +80,12 @@
<option>-DCOV_ENABLED=${coverage.enabled}</option>
<option>-DCMAKE_BUILD_TYPE=${build.type}</option>
<option>-DENABLE_ASAN=${enable.asan}</option>
<option>-DBUILD_TEST=${build.test}</option>
<option>-DENABLE_ANTLR4=${enable.antlr4}</option>
<option>-DENABLE_SNAPPY=${enable.snappy}</option>
<option>-DENABLE_LZ4=${enable.lz4}</option>
<option>-DENABLE_LZOKAY=${enable.lzokay}</option>
<option>-DENABLE_ZLIB=${enable.zlib}</option>
</options>
<sourcePath/>
<targetPath/>
Expand Down
110 changes: 92 additions & 18 deletions cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,74 @@ if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif()

option(ENABLE_SNAPPY "Enable Google Snappy compression" ON)
message("cmake using: ENABLE_SNAPPY=${ENABLE_SNAPPY}")

option(ENABLE_LZ4 "Enable LZ4 compression" ON)
message("cmake using: ENABLE_LZ4=${ENABLE_LZ4}")

option(ENABLE_LZOKAY "Enable LZOKAY compression" ON)
message("cmake using: ENABLE_LZOKAY=${ENABLE_LZOKAY}")

option(ENABLE_ZLIB "Enable Zlib compression" ON)
message("cmake using: ENABLE_ZLIB=${ENABLE_ZLIB}")

message("Running in src directory")
if (${COV_ENABLED})
add_compile_options(-fprofile-arcs -ftest-coverage)
endif ()
add_definitions(-DANTLR4CPP_STATIC)
set(ANTLR4_WITH_STATIC_CRT OFF)

if (ENABLE_ANTLR4)
add_definitions(-DANTLR4CPP_STATIC)
set(ANTLR4_WITH_STATIC_CRT OFF)
message("ANTLR4 is enabled, adding ANTLR4 definitions")
else()
message("ANTLR4 is disabled")
endif()

set(PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/src
${THIRD_PARTY_INCLUDE}/google_snappy
${CMAKE_SOURCE_DIR}/third_party/lz4
${CMAKE_SOURCE_DIR}/third_party/lzokay
${CMAKE_SOURCE_DIR}/third_party/zlib-1.2.13
${CMAKE_SOURCE_DIR}/third_party/google_snappy
${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src
)

if (ENABLE_SNAPPY)
list(APPEND PROJECT_INCLUDE_DIR
${THIRD_PARTY_INCLUDE}/google_snappy
${CMAKE_SOURCE_DIR}/third_party/google_snappy
)
endif()

if (ENABLE_LZ4)
list(APPEND PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/third_party/lz4
)
endif()

if (ENABLE_LZOKAY)
list(APPEND PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/third_party/lzokay
)
endif()

if (ENABLE_ZLIB)
list(APPEND PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/third_party/zlib-1.2.13
)
endif()

if (ENABLE_ANTLR4)
list(APPEND PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src
)
message("Adding ANTLR4 include directory")
endif()

include_directories(${PROJECT_INCLUDE_DIR})

add_subdirectory(parser)
if (ENABLE_ANTLR4)
add_subdirectory(parser)
message("Adding parser subdirectory")
endif()

add_subdirectory(common)
add_subdirectory(compress)
add_subdirectory(cwrapper)
Expand All @@ -55,32 +102,59 @@ add_subdirectory(reader)
add_subdirectory(utils)
add_subdirectory(writer)

set(COMPRESSION_LIBS "")

if (ENABLE_SNAPPY)
list(APPEND COMPRESSION_LIBS snappy)
endif()

if (ENABLE_LZ4)
list(APPEND COMPRESSION_LIBS LZ4)
endif()

if (ENABLE_LZOKAY)
list(APPEND COMPRESSION_LIBS lzokay)
endif()

if (ENABLE_ZLIB)
list(APPEND COMPRESSION_LIBS zlibstatic)
endif()

message("Compression libraries: ${COMPRESSION_LIBS}")

if (ENABLE_ANTLR4)
target_link_libraries(parser_obj antlr4_static)
message("Linking parser_obj with antlr4_static")
endif()

set(COMPRESSION_LIBS snappy LZ4 lzokay zlibstatic)
target_link_libraries(parser_obj antlr4_static)
target_link_libraries(compress_obj ${COMPRESSION_LIBS})
target_link_libraries(common_obj ${COMPRESSION_LIBS})
target_link_libraries(read_obj ${COMPRESSION_LIBS})
target_link_libraries(write_obj ${COMPRESSION_LIBS})

add_library(tsfile SHARED)

if (${COV_ENABLED})
message("Enable code cov...")
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj -lgcov)
if (ENABLE_ANTLR4)
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj -lgcov)
else()
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj -lgcov)
endif()
else()
message("Disable code cov...")
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj)
if (ENABLE_ANTLR4)
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj)
else()
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj)
endif()
endif()

# to trigger copy headers
add_dependencies(tsfile utils_obj encoding_obj)

set(LIBTSFILE_PROJECT_VERSION ${TsFile_CPP_VERSION})
set(LIBTSFILE_SO_VERSION ${TsFile_CPP_VERSION})
set_target_properties(tsfile PROPERTIES VERSION ${LIBTSFILE_PROJECT_VERSION})
set_target_properties(tsfile PROPERTIES SOVERSION ${LIBTSFILE_SO_VERSION})

install(TARGETS tsfile LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH})



install(TARGETS tsfile LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH})
Loading
Loading