diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index bdeaa74fcb..6b4e6c48a2 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -27,6 +27,7 @@ endif () option(BUILD_LOGTAIL "Build Logtail executable and tools" ON) option(BUILD_LOGTAIL_SHARED_LIBRARY "Build Logtail shared library") option(ENABLE_ENTERPRISE "enable enterprise feature") +option(WITHSPL "Build Logtail and UT with SPL" ON) 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") @@ -40,6 +41,10 @@ else () include(${CMAKE_CURRENT_SOURCE_DIR}/options.cmake) endif () +if (NOT WITHSPL) + add_definitions(-D__EXCLUDE_SPL__) +endif() + # Default C/CXX flags. if (UNIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fpic -fPIC -D_LARGEFILE64_SOURCE") @@ -88,7 +93,10 @@ set(SUB_DIRECTORIES_LIST profile_sender reader sdk sender sls_control fuse ) if (LINUX) - set(SUB_DIRECTORIES_LIST ${SUB_DIRECTORIES_LIST} observer spl) + if (WITHSPL) + set(SUB_DIRECTORIES_LIST ${SUB_DIRECTORIES_LIST} spl) + endif() + set(SUB_DIRECTORIES_LIST ${SUB_DIRECTORIES_LIST} observer) if (ENABLE_ENTERPRISE) set(SUB_DIRECTORIES_LIST ${SUB_DIRECTORIES_LIST} shennong streamlog) endif() @@ -108,7 +116,9 @@ macro(append_source_files source_files) endmacro() # Module includes & add_subdirectory. include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories("/opt/logtail_spl/include") +if (WITHSPL) + include_directories("/opt/logtail_spl/include") +endif() foreach (DIR_NAME ${SUB_DIRECTORIES_LIST}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${DIR_NAME}) endforeach (DIR_NAME) diff --git a/core/plugin/PluginRegistry.cpp b/core/plugin/PluginRegistry.cpp index a4be79bc55..898cd0d418 100644 --- a/core/plugin/PluginRegistry.cpp +++ b/core/plugin/PluginRegistry.cpp @@ -51,7 +51,7 @@ #include "processor/inner/ProcessorSplitLogStringNative.h" #include "processor/inner/ProcessorSplitMultilineLogStringNative.h" #include "processor/inner/ProcessorTagNative.h" -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(__linux__) && !defined(__ANDROID__) && !defined(__EXCLUDE_SPL__) #include "processor/ProcessorSPL.h" #endif #include "common/Flags.h" @@ -271,7 +271,7 @@ void PluginRegistry::LoadStaticPlugins() { RegisterProcessorCreator(new StaticProcessorCreator()); RegisterProcessorCreator(new StaticProcessorCreator()); RegisterProcessorCreator(new StaticProcessorCreator()); -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(__linux__) && !defined(__ANDROID__) && !defined(__EXCLUDE_SPL__) if (BOOL_FLAG(enable_processor_spl)) { RegisterProcessorCreator(new StaticProcessorCreator()); } diff --git a/core/processor/CMakeLists.txt b/core/processor/CMakeLists.txt index f8d852ce4a..939a3a037a 100644 --- a/core/processor/CMakeLists.txt +++ b/core/processor/CMakeLists.txt @@ -20,7 +20,7 @@ if (MSVC) endif () file(GLOB LIB_SOURCE_FILES *.cpp *.h) -if (NOT LINUX) +if ((NOT LINUX) OR (NOT WITHSPL)) list(REMOVE_ITEM LIB_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/ProcessorSPL.h ${CMAKE_CURRENT_SOURCE_DIR}/ProcessorSPL.cpp) endif () append_source_files(LIB_SOURCE_FILES) @@ -41,5 +41,7 @@ target_link_libraries(${PROJECT_NAME} fuse) target_link_libraries(${PROJECT_NAME} plugin_interface) link_re2(${PROJECT_NAME}) if (LINUX) - target_link_libraries(${PROJECT_NAME} spl) + if (WITHSPL) + target_link_libraries(${PROJECT_NAME} spl) + endif () endif () diff --git a/core/unittest/CMakeLists.txt b/core/unittest/CMakeLists.txt index 765f32c6fb..a5fd8c40a5 100644 --- a/core/unittest/CMakeLists.txt +++ b/core/unittest/CMakeLists.txt @@ -15,6 +15,10 @@ cmake_minimum_required(VERSION 3.22) project(unittest_base) +if (NOT WITHSPL) + add_definitions(-D__EXCLUDE_SPL__) +endif() + add_definitions(-DAPSARA_UNIT_TEST_MAIN) set(NO_TCMALLOC TRUE) add_definitions(-DLOGTAIL_NO_TC_MALLOC) @@ -37,7 +41,9 @@ link_protobuf(${PROJECT_NAME}) link_cityhash(${PROJECT_NAME}) link_leveldb(${PROJECT_NAME}) link_asan(${PROJECT_NAME}) -link_spl(${PROJECT_NAME}) +if (WITHSPL) + link_spl(${PROJECT_NAME}) +endif() link_tcmalloc(${PROJECT_NAME}) if (UNIX) @@ -80,6 +86,8 @@ add_subdirectory(sdk) add_subdirectory(sender) if (LINUX) - add_subdirectory(spl) + if (WITHSPL) + add_subdirectory(spl) + endif() add_subdirectory(observer) endif () \ No newline at end of file diff --git a/core/unittest/processor/ProcessorParseDelimiterNativeUnittest.cpp b/core/unittest/processor/ProcessorParseDelimiterNativeUnittest.cpp index 6163d578a1..4e5feac906 100644 --- a/core/unittest/processor/ProcessorParseDelimiterNativeUnittest.cpp +++ b/core/unittest/processor/ProcessorParseDelimiterNativeUnittest.cpp @@ -1577,7 +1577,7 @@ HTTP/2.0' '200' '154' 'go-sdk'" // run function ProcessorParseDelimiterNative ProcessorParseDelimiterNative& processorParseDelimiterNative = *(new ProcessorParseDelimiterNative); - ProcessorInstance processorInstance(&processorParseDelimiterNative, pluginId); + ProcessorInstance processorInstance(&processorParseDelimiterNative, getPluginMeta()); APSARA_TEST_TRUE_FATAL(processorInstance.Init(config, mContext)); processorParseDelimiterNative.Process(eventGroup);