Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alph00 committed Jul 16, 2024
1 parent e323899 commit 1868ae3
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 79 deletions.
42 changes: 21 additions & 21 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ option(ENABLE_ENTERPRISE "enable enterprise feature")
cmake_dependent_option(ENABLE_COMPATIBLE_MODE "Build Logtail in compatible mode (for low version Linux)" OFF "LINUX" OFF)
cmake_dependent_option(ENABLE_STATIC_LINK_CRT "Build Logtail by linking CRT statically" OFF "LINUX" OFF)
option(WITHOUTGDB "Build Logtail without gdb")
option(WITHOUTSPL "Link Logtail without SPL")
option(WITHSPL "Link Logtail with SPL" ON)
option(BUILD_LOGTAIL_UT "Build unit test for Logtail")

if (BUILD_LOGTAIL_SHARED_LIBRARY AND NOT WITHOUTSPL)
set(WITHOUTSPL ON)
message(WARNING, "generating logtail shared library is not supported with SPL. WITHOUTSPL has been set to ON.")
if (BUILD_LOGTAIL_SHARED_LIBRARY AND WITHSPL)
message(FATEL_ERROR, "Generating logtail shared library is not supported to be linked with SPL. WITHSPL should be set OFF.")
return()
endif()

set(UT_LINK OFF)
Expand All @@ -49,7 +49,7 @@ else ()
include(${CMAKE_CURRENT_SOURCE_DIR}/options.cmake)
endif ()

if (WITHOUTSPL)
if (NOT WITHSPL)
add_definitions(-D__EXCLUDE_SPL__)
endif()

Expand Down Expand Up @@ -95,8 +95,8 @@ endif ()
include(${CMAKE_CURRENT_SOURCE_DIR}/utils.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/dependencies.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/links.cmake)
set(SUBDIR_SOURCE_FILES "")
set(NOSPL_SUBDIR_SOURCE_FILES "")
set(SUBDIR_SOURCE_FILES_CORE "")
set(SUBDIR_SOURCE_FILES_SPL "")
include(${CMAKE_CURRENT_SOURCE_DIR}/common/common.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/common/links.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/input/input.cmake)
Expand Down Expand Up @@ -131,7 +131,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories("/opt/logtail_spl/include")
if (LINUX)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/observer)
if (NOT WITHOUTSPL)
if (WITHSPL)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/spl)
endif()
endif()
Expand All @@ -157,8 +157,6 @@ if(MSVC)
# remove linux event listener
file(GLOB REMOVE_EVENT_LISTENER_SOURCES event_listener/*_Linux.cpp event_listener/*_Linux.h)
list(REMOVE_ITEM SOURCE_FILES_LIST ${REMOVE_EVENT_LISTENER_SOURCES})
set(WINDOWS_SOURCE_FILES ${SOURCE_FILES_LIST} ${SUBDIR_SOURCE_FILES})
set(NOSPL_WINDOWS_SOURCE_FILES ${SOURCE_FILES_LIST} ${NOSPL_SUBDIR_SOURCE_FILES})
elseif(UNIX)
# remove windows event listener
file(GLOB REMOVE_EVENT_LISTENER_SOURCES event_listener/*_Windows.cpp event_listener/*_Windows.h)
Expand All @@ -167,14 +165,16 @@ elseif(UNIX)
# observer
file(GLOB_RECURSE APPEND_OBSERVER_SOURCES observer/*)
list(APPEND SOURCE_FILES_LIST ${APPEND_OBSERVER_SOURCES})
if (WITHSPL)
set(SRC_FILES ${SUBDIR_SOURCE_FILES_SPL})
endif()
endif()
set(UNIX_SOURCE_FILES ${SOURCE_FILES_LIST} ${SUBDIR_SOURCE_FILES})
set(NOSPL_UNIX_SOURCE_FILES ${SOURCE_FILES_LIST} ${NOSPL_SUBDIR_SOURCE_FILES})
endif()
set(SRC_FILES ${SRC_FILES} ${SOURCE_FILES_LIST} ${SUBDIR_SOURCE_FILES_CORE})

# Generate SPL library.
if (LINUX)
if (NOT WITHOUTSPL)
if (WITHSPL)
add_subdirectory(spl)
endif()
endif()
Expand All @@ -183,31 +183,31 @@ endif()
if (BUILD_LOGTAIL)
if (ENABLE_ENTERPRISE)
if (UNIX)
add_executable(${LOGTAIL_TARGET} enterprise_logtail.cpp ${UNIX_SOURCE_FILES})
add_executable(${LOGTAIL_TARGET} enterprise_logtail.cpp ${SRC_FILES})
elseif (MSVC)
add_executable(${LOGTAIL_TARGET} enterprise_logtail_windows.cpp ${WINDOWS_SOURCE_FILES})
add_executable(${LOGTAIL_TARGET} enterprise_logtail_windows.cpp ${SRC_FILES})
endif ()
else ()
if (UNIX)
add_executable(${LOGTAIL_TARGET} logtail.cpp ${UNIX_SOURCE_FILES})
add_executable(${LOGTAIL_TARGET} logtail.cpp ${SRC_FILES})
elseif (MSVC)
add_executable(${LOGTAIL_TARGET} logtail_windows.cpp ${WINDOWS_SOURCE_FILES})
add_executable(${LOGTAIL_TARGET} logtail_windows.cpp ${SRC_FILES})
endif ()
endif()
endif()

if (BUILD_LOGTAIL_SHARED_LIBRARY)
if (ENABLE_ENTERPRISE)
if (UNIX)
add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail.cpp ${UNIX_SOURCE_FILES})
add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail.cpp ${SRC_FILES})
elseif (MSVC)
add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail_windows.cpp ${WINDOWS_SOURCE_FILES})
add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail_windows.cpp ${SRC_FILES})
endif ()
else ()
if (UNIX)
add_library(${LOGTAIL_TARGET} SHARED logtail.cpp ${UNIX_SOURCE_FILES})
add_library(${LOGTAIL_TARGET} SHARED logtail.cpp ${SRC_FILES})
elseif (MSVC)
add_library(${LOGTAIL_TARGET} SHARED logtail_windows.cpp ${WINDOWS_SOURCE_FILES})
add_library(${LOGTAIL_TARGET} SHARED logtail_windows.cpp ${SRC_FILES})
endif ()
endif()
endif ()
Expand Down
5 changes: 1 addition & 4 deletions core/common/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,4 @@ elseif(UNIX)
endif()

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})

# for NOSPL UT
set(NOSPL_SUBDIR_SOURCE_FILES ${NOSPL_SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})
set(SUBDIR_SOURCE_FILES_CORE ${SUBDIR_SOURCE_FILES_CORE} ${THIS_SOURCE_FILES_LIST})
12 changes: 2 additions & 10 deletions core/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,7 @@ macro(link_lz4 target_name)
if (lz4_${LINK_OPTION_SUFFIX})
target_link_libraries(${target_name} "${lz4_${LINK_OPTION_SUFFIX}}")
elseif (UNIX)
if (WITHOUTSPL)
target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.so")
else ()
target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.so")
endif ()
target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.so")
elseif (MSVC)
target_link_libraries(${target_name}
debug "liblz4_staticd"
Expand Down Expand Up @@ -310,11 +306,7 @@ macro(link_unwind target_name)
elseif (ANDROID)
# target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwindstack.a")
elseif (UNIX)
if (WITHOUTSPL)
target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.so")
else ()
target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.so")
endif ()
target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.so")
elseif (MSVC)
target_link_libraries(${target_name}
debug "breakpad_commond.lib"
Expand Down
7 changes: 2 additions & 5 deletions core/flusher/flusher.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
include_directories(flusher)

# Add source files
file(GLOB THIS_SOURCE_FILES ${CMAKE_SOURCE_DIR}/flusher/*.c ${CMAKE_SOURCE_DIR}/flusher/*.cc ${CMAKE_SOURCE_DIR}/flusher/*.cpp ${CMAKE_SOURCE_DIR}/flusher/*.h)
file(GLOB THIS_SOURCE_FILES_LIST ${CMAKE_SOURCE_DIR}/flusher/*.c ${CMAKE_SOURCE_DIR}/flusher/*.cc ${CMAKE_SOURCE_DIR}/flusher/*.cpp ${CMAKE_SOURCE_DIR}/flusher/*.h)

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES})

# for NOSPL UT
set(NOSPL_SUBDIR_SOURCE_FILES ${NOSPL_SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES})
set(SUBDIR_SOURCE_FILES_CORE ${SUBDIR_SOURCE_FILES_CORE} ${THIS_SOURCE_FILES_LIST})
5 changes: 1 addition & 4 deletions core/input/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,4 @@ elseif(UNIX)
endif()

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})

# for NOSPL UT
set(NOSPL_SUBDIR_SOURCE_FILES ${NOSPL_SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})
set(SUBDIR_SOURCE_FILES_CORE ${SUBDIR_SOURCE_FILES_CORE} ${THIS_SOURCE_FILES_LIST})
2 changes: 1 addition & 1 deletion core/processor/links.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ macro(processor_link target_name ut_link ut_link_need_spl)
target_link_libraries(${target_name} spl)
endif()
else ()
if (LINUX AND NOT WITHOUTSPL)
if (LINUX AND WITHSPL)
link_spl(${target_name})
target_link_libraries(${target_name} spl)
endif ()
Expand Down
11 changes: 2 additions & 9 deletions core/processor/processor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ list(APPEND THIS_SOURCE_FILES_LIST ${THIS_SOURCE_FILES})
file(GLOB THIS_SOURCE_FILES ${CMAKE_SOURCE_DIR}/processor/inner/*.c ${CMAKE_SOURCE_DIR}/processor/inner/*.cc ${CMAKE_SOURCE_DIR}/processor/inner/*.cpp ${CMAKE_SOURCE_DIR}/processor/inner/*.h)
list(APPEND THIS_SOURCE_FILES_LIST ${THIS_SOURCE_FILES})

if(NOT LINUX OR WITHOUTSPL)
# remove spl related files in processor
list(REMOVE_ITEM THIS_SOURCE_FILES_LIST ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.cpp ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.h)
endif()

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})

# for NOSPL UT, remove ProcessorSPL.cpp and ProcessorSPL.h
list(REMOVE_ITEM THIS_SOURCE_FILES_LIST ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.cpp ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.h)
set(NOSPL_SUBDIR_SOURCE_FILES ${NOSPL_SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})
set(SUBDIR_SOURCE_FILES_CORE ${SUBDIR_SOURCE_FILES_CORE} ${THIS_SOURCE_FILES_LIST})
set(SUBDIR_SOURCE_FILES_SPL ${SUBDIR_SOURCE_FILES_SPL} ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.cpp ${CMAKE_SOURCE_DIR}/processor/ProcessorSPL.h)
42 changes: 19 additions & 23 deletions core/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include(${CMAKE_SOURCE_DIR}/processor/links.cmake)
include(${CMAKE_SOURCE_DIR}/input/links.cmake)
include(${CMAKE_SOURCE_DIR}/flusher/links.cmake)

macro(add_nospl_subdir)
macro(add_core_subdir)
add_subdirectory(app_config)
add_subdirectory(batch)
add_subdirectory(checkpoint)
Expand Down Expand Up @@ -75,38 +75,34 @@ macro(ut_link need_spl)
common_link(${UT_BASE_TARGET})
endmacro()

set(SOURCE_FILES_CORE ${SOURCE_FILES_LIST} ${SUBDIR_SOURCE_FILES_CORE})
set(SOURCE_FILES_CORE_WITHSPL ${SOURCE_FILES_CORE} ${SUBDIR_SOURCE_FILES_SPL})

if (UNIX)
if (LINUX)
if (WITHOUTSPL)
# add nospl subdir
set(UT_BASE_TARGET "unittest_base")
add_library(${UT_BASE_TARGET} SHARED ${NOSPL_UNIX_SOURCE_FILES})
target_compile_options(${UT_BASE_TARGET} PRIVATE -Werror)
add_nospl_subdir()
set(UT_LINK_NEED_SPL OFF)
ut_link(${UT_LINK_NEED_SPL})
else ()
if (WITHSPL)
# add spl subdir
set(UT_BASE_TARGET "unittest_base_static")
add_library(${UT_BASE_TARGET} STATIC ${UNIX_SOURCE_FILES})
set(UT_BASE_TARGET "unittest_base_withspl")
add_library(${UT_BASE_TARGET} STATIC ${SOURCE_FILES_CORE_WITHSPL})
target_compile_options(${UT_BASE_TARGET} PRIVATE -Werror)
add_spl_subdir()
set(UT_LINK_NEED_SPL ON)
ut_link(${UT_LINK_NEED_SPL})
# add nospl subdir
set(UT_BASE_TARGET "unittest_base")
add_definitions(-D__EXCLUDE_SPL__)
add_library(${UT_BASE_TARGET} SHARED ${NOSPL_UNIX_SOURCE_FILES})
target_compile_options(${UT_BASE_TARGET} PRIVATE -Werror)
add_nospl_subdir()
set(UT_LINK_NEED_SPL OFF)
ut_link(${UT_LINK_NEED_SPL})
endif()
# add core subdir
set(UT_BASE_TARGET "unittest_base")
add_definitions(-D__EXCLUDE_SPL__)
add_library(${UT_BASE_TARGET} SHARED ${SOURCE_FILES_CORE})
target_compile_options(${UT_BASE_TARGET} PRIVATE -Werror)
add_core_subdir()
set(UT_LINK_NEED_SPL OFF)
ut_link(${UT_LINK_NEED_SPL})
else ()
set(UT_BASE_TARGET "unittest_base_static")
add_library(${UT_BASE_TARGET} STATIC ${NOSPL_UNIX_SOURCE_FILES})
# add core subdir
set(UT_BASE_TARGET "unittest_base")
add_library(${UT_BASE_TARGET} STATIC ${SOURCE_FILES_CORE})
target_compile_options(${UT_BASE_TARGET} PRIVATE -Werror)
add_nospl_subdir()
add_core_subdir()
set(UT_LINK_NEED_SPL OFF)
ut_link(${UT_LINK_NEED_SPL})
endif ()
Expand Down
4 changes: 2 additions & 2 deletions scripts/gen_build_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT:-OFF}
ENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE:-OFF}
ENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT:-OFF}
WITHOUTGDB==${WITHOUTGDB:-OFF}
WITHOUTSPL=${WITHOUTSPL:-OFF}
WITHSPL=${WITHSPL:-ON}
BUILD_SCRIPT_FILE=$GENERATED_HOME/gen_build.sh
COPY_SCRIPT_FILE=$GENERATED_HOME/gen_copy_docker.sh
MAKE_JOBS=${MAKE_JOBS:-$(nproc)}
Expand Down Expand Up @@ -83,7 +83,7 @@ EOF
if [ $CATEGORY = "plugin" ]; then
echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} .. && cd plugin && make -s PluginAdapter && cd ../../.. && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE
elif [ $CATEGORY = "core" ]; then
echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} -DWITHOUTSPL=${WITHOUTSPL} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE
echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} -DWITHSPL=${WITHSPL} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE
elif [ $CATEGORY = "all" ]; then
echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE
elif [ $CATEGORY = "e2e" ]; then
Expand Down

0 comments on commit 1868ae3

Please sign in to comment.