From 119d8a7233aa9fa87639aabec499f22acc7877e8 Mon Sep 17 00:00:00 2001 From: alph00 Date: Fri, 12 Jul 2024 10:52:10 +0000 Subject: [PATCH] fix: change design. Build .a and .so at the same CI UT job --- .github/workflows/build-core-nospl-ut.yaml | 90 ------------------- .github/workflows/build-core-spl-ut.yaml | 8 +- .github/workflows/build-core.yaml | 6 +- .github/workflows/build.yaml | 3 +- .github/workflows/e2e-framework.yaml | 3 +- .github/workflows/e2e.yaml | 3 +- core/CMakeLists.txt | 48 +++++----- core/common/common.cmake | 5 +- core/dependencies.cmake | 8 +- core/flusher/flusher.cmake | 5 +- core/input/input.cmake | 5 +- core/links.cmake | 2 +- core/processor/links.cmake | 19 ++-- core/processor/processor.cmake | 6 +- core/unittest/CMakeLists.txt | 84 +++++++++++------ core/unittest/app_config/CMakeLists.txt | 2 +- core/unittest/batch/CMakeLists.txt | 10 +-- core/unittest/checkpoint/CMakeLists.txt | 6 +- core/unittest/common/CMakeLists.txt | 18 ++-- core/unittest/compression/CMakeLists.txt | 6 +- core/unittest/config/CMakeLists.txt | 12 +-- core/unittest/config_sdk/CMakeLists.txt | 2 +- .../unittest/container_manager/CMakeLists.txt | 2 +- core/unittest/controller/CMakeLists.txt | 2 +- core/unittest/event/CMakeLists.txt | 2 +- core/unittest/event_handler/CMakeLists.txt | 6 +- core/unittest/file_source/CMakeLists.txt | 4 +- core/unittest/flusher/CMakeLists.txt | 2 +- core/unittest/input/CMakeLists.txt | 4 +- core/unittest/log_pb/CMakeLists.txt | 2 +- core/unittest/logger/CMakeLists.txt | 2 +- core/unittest/models/CMakeLists.txt | 16 ++-- core/unittest/monitor/CMakeLists.txt | 4 +- core/unittest/observer/CMakeLists.txt | 24 ++--- core/unittest/pipeline/CMakeLists.txt | 6 +- core/unittest/plugin/CMakeLists.txt | 14 +-- core/unittest/polling/CMakeLists.txt | 2 +- core/unittest/processor/CMakeLists.txt | 28 +++--- core/unittest/queue/CMakeLists.txt | 8 +- core/unittest/reader/CMakeLists.txt | 16 ++-- core/unittest/sdk/CMakeLists.txt | 2 +- core/unittest/sender/CMakeLists.txt | 4 +- core/unittest/serializer/CMakeLists.txt | 2 +- core/unittest/spl/CMakeLists.txt | 4 +- .../development-environment.md | 4 +- scripts/gen_build_scripts.sh | 13 ++- 46 files changed, 242 insertions(+), 282 deletions(-) delete mode 100644 .github/workflows/build-core-nospl-ut.yaml diff --git a/.github/workflows/build-core-nospl-ut.yaml b/.github/workflows/build-core-nospl-ut.yaml deleted file mode 100644 index 96d3478409..0000000000 --- a/.github/workflows/build-core-nospl-ut.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2024 iLogtail Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Build Core NoSPL Unit Test - -on: - pull_request: - paths-ignore: - - "docs/**" - - "example_config/**" - - "docker/**" - - "k8s_template/**" - - "changes/**" - - "licenses/**" - - "CHANGELOG.md" - push: - branches: - - main - - 1.* - -jobs: - CI: - runs-on: ${{ matrix.runner }} - timeout-minutes: 90 - strategy: - matrix: - go-version: [1.19] - # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on - runner: [arc-runner-set-ilogtail] - fail-fast: true - steps: - - name: prepare ubuntu environment - run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y libsystemd-dev build-essential git curl bc - # Clean up space to prevent action from running out of disk space. - - name: Free disk space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo -E apt-get -qq autoremove --purge - sudo -E apt-get -qq clean - - - name: Check disk space - run: | - df -hT $PWD - - - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - - - name: Check out code - uses: actions/checkout@v4 - with: - submodules: true - - - name: Build NoSPL Unit Test - env: - BUILD_LOGTAIL: OFF - BUILD_LOGTAIL_NOSPL_UT: ON - # ENABLE_COMPATIBLE_MODE: ON - ENABLE_STATIC_LINK_CRT: ON - WITHOUTGDB: ON - WITHOUTSPL: ON - MAKE_JOBS: 16 - # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined - run: make core - - - name: NoSPL Unit Test - run: make unittest_core - - result: - runs-on: arc-runner-set-ilogtail - timeout-minutes: 90 - needs: [CI] - steps: - - name: Build Result - run: echo "Just to make the GitHub merge button green" diff --git a/.github/workflows/build-core-spl-ut.yaml b/.github/workflows/build-core-spl-ut.yaml index 156f0adc96..7187c93ca4 100644 --- a/.github/workflows/build-core-spl-ut.yaml +++ b/.github/workflows/build-core-spl-ut.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Build Core SPL Unit Test +name: Build Core Unit Test on: pull_request: @@ -66,10 +66,10 @@ jobs: with: submodules: true - - name: Build SPL Unit Test + - name: Build Unit Test env: BUILD_LOGTAIL: OFF - BUILD_LOGTAIL_SPL_UT: ON + BUILD_LOGTAIL_UT: ON ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON @@ -77,7 +77,7 @@ jobs: # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined run: make core - - name: SPL Unit Test + - name: Unit Test run: make unittest_core result: diff --git a/.github/workflows/build-core.yaml b/.github/workflows/build-core.yaml index f90bedabe9..8bdc756aa4 100644 --- a/.github/workflows/build-core.yaml +++ b/.github/workflows/build-core.yaml @@ -68,8 +68,7 @@ jobs: - name: Build Binary env: - BUILD_LOGTAIL_NOSPL_UT: OFF - BUILD_LOGTAIL_SPL_UT: OFF + BUILD_LOGTAIL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON @@ -78,8 +77,7 @@ jobs: - name: Check compatibility env: - BUILD_LOGTAIL_NOSPL_UT: OFF - BUILD_LOGTAIL_SPL_UT: OFF + BUILD_LOGTAIL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9c5727ffa5..aad824fe0c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,8 +68,7 @@ jobs: - name: Build Binary env: - BUILD_LOGTAIL_NOSPL_UT: OFF - BUILD_LOGTAIL_SPL_UT: OFF + BUILD_LOGTAIL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON diff --git a/.github/workflows/e2e-framework.yaml b/.github/workflows/e2e-framework.yaml index 410145ff94..281d90577d 100644 --- a/.github/workflows/e2e-framework.yaml +++ b/.github/workflows/e2e-framework.yaml @@ -69,8 +69,7 @@ jobs: - name: E2E Plugin Framework Test env: - BUILD_LOGTAIL_NOSPL_UT: OFF - BUILD_LOGTAIL_SPL_UT: OFF + BUILD_LOGTAIL_UT: OFF WITHOUTGDB: ON run: make e2e-core diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a8175a6d9a..2c32832950 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -76,8 +76,7 @@ jobs: - name: E2E Behavior Test env: - BUILD_LOGTAIL_NOSPL_UT: OFF - BUILD_LOGTAIL_SPL_UT: OFF + BUILD_LOGTAIL_UT: OFF WITHOUTGDB: ON run: make e2e diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 12ce17e064..2506b3c240 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -31,8 +31,15 @@ cmake_dependent_option(ENABLE_COMPATIBLE_MODE "Build Logtail in compatible mode 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(BUILD_LOGTAIL_NOSPL_UT "Build noSPL unit test for Logtail") -option(BUILD_LOGTAIL_SPL_UT "Build SPL unit test for Logtail") +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.") +endif() + +set(UT_LINK OFF) +set(UT_LINK_NEED_SPL OFF) if (ENABLE_ENTERPRISE) message(STATUS "Enable Enterprise Feature.") @@ -89,6 +96,7 @@ 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 "") include(${CMAKE_CURRENT_SOURCE_DIR}/common/common.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/common/links.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/input/input.cmake) @@ -150,6 +158,7 @@ if(MSVC) 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) @@ -160,6 +169,7 @@ elseif(UNIX) list(APPEND SOURCE_FILES_LIST ${APPEND_OBSERVER_SOURCES}) endif() set(UNIX_SOURCE_FILES ${SOURCE_FILES_LIST} ${SUBDIR_SOURCE_FILES}) + set(NOSPL_UNIX_SOURCE_FILES ${SOURCE_FILES_LIST} ${NOSPL_SUBDIR_SOURCE_FILES}) endif() # Generate SPL library. @@ -186,28 +196,24 @@ if (BUILD_LOGTAIL) endif() endif() -if (BUILD_LOGTAIL_SHARED_LIBRARY) - if (NOT WITHOUTSPL) - message(ERROR, "generating logtail shared library is not supported with SPL.") - else() - if (ENABLE_ENTERPRISE) - if (UNIX) - add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail.cpp ${UNIX_SOURCE_FILES}) - elseif (MSVC) - add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail_windows.cpp ${WINDOWS_SOURCE_FILES}) - endif () - else () - if (UNIX) - add_library(${LOGTAIL_TARGET} SHARED logtail.cpp ${UNIX_SOURCE_FILES}) - elseif (MSVC) - add_library(${LOGTAIL_TARGET} SHARED logtail_windows.cpp ${WINDOWS_SOURCE_FILES}) - endif () - endif() +if (BUILD_LOGTAIL_SHARED_LIBRARY) + if (ENABLE_ENTERPRISE) + if (UNIX) + add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail.cpp ${UNIX_SOURCE_FILES}) + elseif (MSVC) + add_library(${LOGTAIL_TARGET} SHARED enterprise_logtail_windows.cpp ${WINDOWS_SOURCE_FILES}) + endif () + else () + if (UNIX) + add_library(${LOGTAIL_TARGET} SHARED logtail.cpp ${UNIX_SOURCE_FILES}) + elseif (MSVC) + add_library(${LOGTAIL_TARGET} SHARED logtail_windows.cpp ${WINDOWS_SOURCE_FILES}) + endif () endif() endif () # Logtail UT. -if (BUILD_LOGTAIL_NOSPL_UT OR BUILD_LOGTAIL_SPL_UT) +if (BUILD_LOGTAIL_UT) message(STATUS "Build unittest.") include(CTest) enable_testing() @@ -222,7 +228,7 @@ add_subdirectory(common) # Link libraries. if(BUILD_LOGTAIL OR BUILD_LOGTAIL_SHARED_LIBRARY) input_link(${LOGTAIL_TARGET}) - processor_link(${LOGTAIL_TARGET}) + processor_link(${LOGTAIL_TARGET} ${UT_LINK} ${UT_LINK_NEED_SPL}) flusher_link(${LOGTAIL_TARGET}) all_link(${LOGTAIL_TARGET}) common_link(${LOGTAIL_TARGET}) diff --git a/core/common/common.cmake b/core/common/common.cmake index d687938f77..81bf05c989 100644 --- a/core/common/common.cmake +++ b/core/common/common.cmake @@ -45,4 +45,7 @@ elseif(UNIX) endif() # Set source files to parent -set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST}) \ No newline at end of file +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}) diff --git a/core/dependencies.cmake b/core/dependencies.cmake index f0000a171d..231986560e 100644 --- a/core/dependencies.cmake +++ b/core/dependencies.cmake @@ -242,10 +242,10 @@ macro(link_lz4 target_name) if (lz4_${LINK_OPTION_SUFFIX}) target_link_libraries(${target_name} "${lz4_${LINK_OPTION_SUFFIX}}") elseif (UNIX) - if (WITHOUTSPL OR BUILD_LOGTAIL_SHARED_LIBRARY) + if (WITHOUTSPL) target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.so") else () - target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.a") + target_link_libraries(${target_name} "${lz4_${LIBRARY_DIR_SUFFIX}}/liblz4.so") endif () elseif (MSVC) target_link_libraries(${target_name} @@ -310,10 +310,10 @@ macro(link_unwind target_name) elseif (ANDROID) # target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwindstack.a") elseif (UNIX) - if (WITHOUTSPL OR BUILD_LOGTAIL_SHARED_LIBRARY) + if (WITHOUTSPL) target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.so") else () - target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.a") + target_link_libraries(${target_name} "${unwind_${LIBRARY_DIR_SUFFIX}}/libunwind.so") endif () elseif (MSVC) target_link_libraries(${target_name} diff --git a/core/flusher/flusher.cmake b/core/flusher/flusher.cmake index af3a2f0c20..e967a5705b 100644 --- a/core/flusher/flusher.cmake +++ b/core/flusher/flusher.cmake @@ -20,4 +20,7 @@ include_directories(flusher) 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) # Set source files to parent -set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES}) \ No newline at end of file +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}) diff --git a/core/input/input.cmake b/core/input/input.cmake index 7727584eab..4afddb1afb 100644 --- a/core/input/input.cmake +++ b/core/input/input.cmake @@ -38,4 +38,7 @@ elseif(UNIX) endif() # Set source files to parent -set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST}) \ No newline at end of file +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}) diff --git a/core/links.cmake b/core/links.cmake index fa43fb5741..0dde93ad60 100644 --- a/core/links.cmake +++ b/core/links.cmake @@ -13,7 +13,7 @@ # limitations under the License. macro(all_link target_name) - if (BUILD_LOGTAIL_NOSPL_UT OR BUILD_LOGTAIL_SPL_UT) + if (BUILD_LOGTAIL_UT) link_gtest(${target_name}) endif () link_protobuf(${target_name}) diff --git a/core/processor/links.cmake b/core/processor/links.cmake index 18fb6fe535..3e9e073002 100644 --- a/core/processor/links.cmake +++ b/core/processor/links.cmake @@ -14,14 +14,19 @@ # limitations under the License. # This file is used to link external source files in processor directory -macro(processor_link target_name) +macro(processor_link target_name ut_link ut_link_need_spl) link_re2(${target_name}) - if (LINUX AND NOT WITHOUTSPL) - link_spl(${target_name}) - endif () - if (LINUX AND NOT WITHOUTSPL) - target_link_libraries(${target_name} spl) - endif () + if(${ut_link}) + if(${ut_link_need_spl}) + link_spl(${target_name}) + target_link_libraries(${target_name} spl) + endif() + else () + if (LINUX AND NOT WITHOUTSPL) + link_spl(${target_name}) + target_link_libraries(${target_name} spl) + endif () + endif() link_ssl(${target_name}) # must after link_spl link_crypto(${target_name}) # must after link_spl endmacro() diff --git a/core/processor/processor.cmake b/core/processor/processor.cmake index a97ec0a09c..0fe5ce6ef6 100644 --- a/core/processor/processor.cmake +++ b/core/processor/processor.cmake @@ -32,4 +32,8 @@ if(NOT LINUX OR WITHOUTSPL) endif() # Set source files to parent -set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST}) \ No newline at end of file +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}) diff --git a/core/unittest/CMakeLists.txt b/core/unittest/CMakeLists.txt index ae7880e7d8..df86f0e708 100644 --- a/core/unittest/CMakeLists.txt +++ b/core/unittest/CMakeLists.txt @@ -15,37 +15,21 @@ cmake_minimum_required(VERSION 3.22) project(unittest_base) -include(${CMAKE_SOURCE_DIR}/links.cmake) -include(${CMAKE_SOURCE_DIR}/common/links.cmake) -include(${CMAKE_SOURCE_DIR}/processor/links.cmake) -include(${CMAKE_SOURCE_DIR}/input/links.cmake) -include(${CMAKE_SOURCE_DIR}/flusher/links.cmake) - add_definitions(-DAPSARA_UNIT_TEST_MAIN) set(NO_TCMALLOC TRUE) add_definitions(-DLOGTAIL_NO_TC_MALLOC) if (MSVC) add_definitions(-DNOMINMAX) endif () -if (LINUX AND WITHOUTSPL) - add_library(${PROJECT_NAME} SHARED ${UNIX_SOURCE_FILES}) -else () - add_library(${PROJECT_NAME} STATIC ${UNIX_SOURCE_FILES}) -endif() -if(MSVC) - # For MSVC, use /W4 for a high level of warnings, and treat warnings as errors. - # target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX) -else() - target_compile_options(${PROJECT_NAME} PRIVATE -Werror) -endif() +set(UT_LINK ON) -input_link(${PROJECT_NAME}) -processor_link(${PROJECT_NAME}) -flusher_link(${PROJECT_NAME}) -all_link(${PROJECT_NAME}) -common_link(${PROJECT_NAME}) +include(${CMAKE_SOURCE_DIR}/links.cmake) +include(${CMAKE_SOURCE_DIR}/common/links.cmake) +include(${CMAKE_SOURCE_DIR}/processor/links.cmake) +include(${CMAKE_SOURCE_DIR}/input/links.cmake) +include(${CMAKE_SOURCE_DIR}/flusher/links.cmake) -if(BUILD_LOGTAIL_NOSPL_UT) +macro(add_nospl_subdir) add_subdirectory(app_config) add_subdirectory(batch) add_subdirectory(checkpoint) @@ -75,10 +59,58 @@ if(BUILD_LOGTAIL_NOSPL_UT) if (LINUX) add_subdirectory(observer) endif () -endif() +endmacro() -if(BUILD_LOGTAIL_SPL_UT) +macro(add_spl_subdir) if (LINUX) add_subdirectory(spl) + endif () +endmacro() + +macro(ut_link need_spl) + input_link(${UT_BASE_TARGET}) + processor_link(${UT_BASE_TARGET} ${UT_LINK} ${need_spl}) + flusher_link(${UT_BASE_TARGET}) + all_link(${UT_BASE_TARGET}) + common_link(${UT_BASE_TARGET}) +endmacro() + +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 () + # add spl subdir + set(UT_BASE_TARGET "unittest_base_static") + add_library(${UT_BASE_TARGET} STATIC ${UNIX_SOURCE_FILES}) + 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() + else () + set(UT_BASE_TARGET "unittest_base_static") + add_library(${UT_BASE_TARGET} STATIC ${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 () -endif() \ No newline at end of file +elseif (MSVC) + # For MSVC, use /W4 for a high level of warnings, and treat warnings as errors. + # target_compile_options(${UT_BASE_TARGET} PRIVATE /W4 /WX) +endif() diff --git a/core/unittest/app_config/CMakeLists.txt b/core/unittest/app_config/CMakeLists.txt index 1cfdc4e01f..408719baa2 100644 --- a/core/unittest/app_config/CMakeLists.txt +++ b/core/unittest/app_config/CMakeLists.txt @@ -16,4 +16,4 @@ cmake_minimum_required(VERSION 3.22) project(app_config_unittest) # add_executable(app_config_unittest AppConfigUnittest.cpp) -# target_link_libraries(app_config_unittest unittest_base) +# target_link_libraries(app_config_unittest ${UT_BASE_TARGET}) diff --git a/core/unittest/batch/CMakeLists.txt b/core/unittest/batch/CMakeLists.txt index 42d84cc689..aec7ec610d 100644 --- a/core/unittest/batch/CMakeLists.txt +++ b/core/unittest/batch/CMakeLists.txt @@ -16,19 +16,19 @@ cmake_minimum_required(VERSION 3.22) project(batch_unittest) add_executable(flush_strategy_unittest FlushStrategyUnittest.cpp) -target_link_libraries(flush_strategy_unittest unittest_base) +target_link_libraries(flush_strategy_unittest ${UT_BASE_TARGET}) add_executable(batch_status_unittest BatchStatusUnittest.cpp) -target_link_libraries(batch_status_unittest unittest_base) +target_link_libraries(batch_status_unittest ${UT_BASE_TARGET}) add_executable(batch_item_unittest BatchItemUnittest.cpp) -target_link_libraries(batch_item_unittest unittest_base) +target_link_libraries(batch_item_unittest ${UT_BASE_TARGET}) add_executable(batcher_unittest BatcherUnittest.cpp) -target_link_libraries(batcher_unittest unittest_base) +target_link_libraries(batcher_unittest ${UT_BASE_TARGET}) add_executable(timeout_flush_manager_unittest TimeoutFlushManagerUnittest.cpp) -target_link_libraries(timeout_flush_manager_unittest unittest_base) +target_link_libraries(timeout_flush_manager_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(flush_strategy_unittest) diff --git a/core/unittest/checkpoint/CMakeLists.txt b/core/unittest/checkpoint/CMakeLists.txt index b3c5999950..92ee28a890 100644 --- a/core/unittest/checkpoint/CMakeLists.txt +++ b/core/unittest/checkpoint/CMakeLists.txt @@ -16,13 +16,13 @@ cmake_minimum_required(VERSION 3.22) project(checkpoint_unittest) add_executable(checkpoint_manager_unittest CheckpointManagerUnittest.cpp) -target_link_libraries(checkpoint_manager_unittest unittest_base) +target_link_libraries(checkpoint_manager_unittest ${UT_BASE_TARGET}) # add_executable(checkpoint_manager_v2_unittest CheckpointManagerV2Unittest.cpp) -# target_link_libraries(checkpoint_manager_v2_unittest unittest_base) +# target_link_libraries(checkpoint_manager_v2_unittest ${UT_BASE_TARGET}) add_executable(adhoc_checkpoint_manager_unittest AdhocCheckpointManagerUnittest.cpp) -target_link_libraries(adhoc_checkpoint_manager_unittest unittest_base) +target_link_libraries(adhoc_checkpoint_manager_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(checkpoint_manager_unittest) diff --git a/core/unittest/common/CMakeLists.txt b/core/unittest/common/CMakeLists.txt index b6b15a2cb5..14218255c5 100644 --- a/core/unittest/common/CMakeLists.txt +++ b/core/unittest/common/CMakeLists.txt @@ -19,31 +19,31 @@ add_executable(common_simple_utils_unittest SimpleUtilsUnittest.cpp FileSystemUtilUnittest.h DevInodeUnittest.h TimeUtilUnittest.h) -target_link_libraries(common_simple_utils_unittest unittest_base) +target_link_libraries(common_simple_utils_unittest ${UT_BASE_TARGET}) add_executable(common_logfileoperator_unittest LogFileOperatorUnittest.cpp) -target_link_libraries(common_logfileoperator_unittest unittest_base) +target_link_libraries(common_logfileoperator_unittest ${UT_BASE_TARGET}) add_executable(common_sender_queue_unittest SenderQueueUnittest.cpp) -target_link_libraries(common_sender_queue_unittest unittest_base) +target_link_libraries(common_sender_queue_unittest ${UT_BASE_TARGET}) add_executable(common_sliding_window_counter_unittest SlidingWindowCounterUnittest.cpp) -target_link_libraries(common_sliding_window_counter_unittest unittest_base) +target_link_libraries(common_sliding_window_counter_unittest ${UT_BASE_TARGET}) # add_executable(common_string_piece_unittest StringPieceUnittest.cpp) -# target_link_libraries(common_string_piece_unittest unittest_base) +# target_link_libraries(common_string_piece_unittest ${UT_BASE_TARGET}) add_executable(common_string_tools_unittest StringToolsUnittest.cpp) -target_link_libraries(common_string_tools_unittest unittest_base) +target_link_libraries(common_string_tools_unittest ${UT_BASE_TARGET}) add_executable(common_machine_info_util_unittest MachineInfoUtilUnittest.cpp) -target_link_libraries(common_machine_info_util_unittest unittest_base) +target_link_libraries(common_machine_info_util_unittest ${UT_BASE_TARGET}) add_executable(encoding_converter_unittest EncodingConverterUnittest.cpp) -target_link_libraries(encoding_converter_unittest unittest_base) +target_link_libraries(encoding_converter_unittest ${UT_BASE_TARGET}) add_executable(yaml_util_unittest YamlUtilUnittest.cpp) -target_link_libraries(yaml_util_unittest unittest_base) +target_link_libraries(yaml_util_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(common_simple_utils_unittest) diff --git a/core/unittest/compression/CMakeLists.txt b/core/unittest/compression/CMakeLists.txt index f5f9cf4983..442a8db893 100644 --- a/core/unittest/compression/CMakeLists.txt +++ b/core/unittest/compression/CMakeLists.txt @@ -16,13 +16,13 @@ cmake_minimum_required(VERSION 3.22) project(compression_unittest) add_executable(compressor_factory_unittest CompressorFactoryUnittest.cpp) -target_link_libraries(compressor_factory_unittest unittest_base) +target_link_libraries(compressor_factory_unittest ${UT_BASE_TARGET}) add_executable(lz4_compressor_unittest LZ4CompressorUnittest.cpp) -target_link_libraries(lz4_compressor_unittest unittest_base) +target_link_libraries(lz4_compressor_unittest ${UT_BASE_TARGET}) add_executable(zstd_compressor_unittest ZstdCompressorUnittest.cpp) -target_link_libraries(zstd_compressor_unittest unittest_base) +target_link_libraries(zstd_compressor_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(compressor_factory_unittest) diff --git a/core/unittest/config/CMakeLists.txt b/core/unittest/config/CMakeLists.txt index fe4db7f711..d408e8a1b0 100644 --- a/core/unittest/config/CMakeLists.txt +++ b/core/unittest/config/CMakeLists.txt @@ -16,23 +16,23 @@ cmake_minimum_required(VERSION 3.22) project(config_unittest) # add_executable(config_match_unittest ConfigMatchUnittest.cpp) -# target_link_libraries(config_match_unittest unittest_base) +# target_link_libraries(config_match_unittest ${UT_BASE_TARGET}) # add_executable(config_updator_unittest ConfigUpdatorUnittest.cpp) -# target_link_libraries(config_updator_unittest unittest_base) +# target_link_libraries(config_updator_unittest ${UT_BASE_TARGET}) add_executable(config_unittest ConfigUnittest.cpp) -target_link_libraries(config_unittest unittest_base) +target_link_libraries(config_unittest ${UT_BASE_TARGET}) add_executable(config_watcher_unittest ConfigWatcherUnittest.cpp) -target_link_libraries(config_watcher_unittest unittest_base) +target_link_libraries(config_watcher_unittest ${UT_BASE_TARGET}) add_executable(config_update_unittest ConfigUpdateUnittest.cpp) -target_link_libraries(config_update_unittest unittest_base) +target_link_libraries(config_update_unittest ${UT_BASE_TARGET}) if (ENABLE_ENTERPRISE) add_executable(legacy_config_provider_unittest LegacyConfigProviderUnittest.cpp) - target_link_libraries(legacy_config_provider_unittest unittest_base) + target_link_libraries(legacy_config_provider_unittest ${UT_BASE_TARGET}) endif () include(GoogleTest) diff --git a/core/unittest/config_sdk/CMakeLists.txt b/core/unittest/config_sdk/CMakeLists.txt index c7e3a72797..c84672886d 100644 --- a/core/unittest/config_sdk/CMakeLists.txt +++ b/core/unittest/config_sdk/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(config_sdk_unittest) add_executable(config_sdk_unittest config_sdk_unittest.cpp) -target_link_libraries(config_sdk_unittest unittest_base) +target_link_libraries(config_sdk_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(config_sdk_unittest) diff --git a/core/unittest/container_manager/CMakeLists.txt b/core/unittest/container_manager/CMakeLists.txt index d593574791..00dfa10352 100644 --- a/core/unittest/container_manager/CMakeLists.txt +++ b/core/unittest/container_manager/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(container_manager_unittest) add_executable(container_discovery_options_unittest ContainerDiscoveryOptionsUnittest.cpp) -target_link_libraries(container_discovery_options_unittest unittest_base) +target_link_libraries(container_discovery_options_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(container_discovery_options_unittest) diff --git a/core/unittest/controller/CMakeLists.txt b/core/unittest/controller/CMakeLists.txt index 0583076baf..6946a5b1b1 100644 --- a/core/unittest/controller/CMakeLists.txt +++ b/core/unittest/controller/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(controller_unittest) add_executable(event_dispatcher_dir_unittest EventDispatcherDirUnittest.cpp) -target_link_libraries(event_dispatcher_dir_unittest unittest_base) +target_link_libraries(event_dispatcher_dir_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(event_dispatcher_dir_unittest) diff --git a/core/unittest/event/CMakeLists.txt b/core/unittest/event/CMakeLists.txt index 3a95e1ecd0..f06131ef08 100644 --- a/core/unittest/event/CMakeLists.txt +++ b/core/unittest/event/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(event_unittest) add_executable(event_unittest EventUnittest.cpp) -target_link_libraries(event_unittest unittest_base) +target_link_libraries(event_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(event_unittest) diff --git a/core/unittest/event_handler/CMakeLists.txt b/core/unittest/event_handler/CMakeLists.txt index 9a539b0199..0e5e929ebe 100644 --- a/core/unittest/event_handler/CMakeLists.txt +++ b/core/unittest/event_handler/CMakeLists.txt @@ -16,13 +16,13 @@ cmake_minimum_required(VERSION 3.22) project(event_handler_unittest) # add_executable(create_modify_handler_unittest CreateModifyHandlerUnittest.cpp) -# target_link_libraries(create_modify_handler_unittest unittest_base) +# target_link_libraries(create_modify_handler_unittest ${UT_BASE_TARGET}) # add_executable(modify_handler_unittest ModifyHandlerUnittest.cpp) -# target_link_libraries(modify_handler_unittest unittest_base) +# target_link_libraries(modify_handler_unittest ${UT_BASE_TARGET}) add_executable(log_input_unittest LogInputUnittest.cpp) -target_link_libraries(log_input_unittest unittest_base) +target_link_libraries(log_input_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(log_input_unittest) diff --git a/core/unittest/file_source/CMakeLists.txt b/core/unittest/file_source/CMakeLists.txt index 6b2337cda0..15983d767f 100644 --- a/core/unittest/file_source/CMakeLists.txt +++ b/core/unittest/file_source/CMakeLists.txt @@ -16,10 +16,10 @@ cmake_minimum_required(VERSION 3.22) project(file_source_unittest) add_executable(file_discovery_options_unittest FileDiscoveryOptionsUnittest.cpp) -target_link_libraries(file_discovery_options_unittest unittest_base) +target_link_libraries(file_discovery_options_unittest ${UT_BASE_TARGET}) add_executable(multiline_options_unittest MultilineOptionsUnittest.cpp) -target_link_libraries(multiline_options_unittest unittest_base) +target_link_libraries(multiline_options_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(file_discovery_options_unittest) diff --git a/core/unittest/flusher/CMakeLists.txt b/core/unittest/flusher/CMakeLists.txt index 8d4d5b5a99..23bd6a9400 100644 --- a/core/unittest/flusher/CMakeLists.txt +++ b/core/unittest/flusher/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(flusher_unittest) add_executable(flusher_sls_unittest FlusherSLSUnittest.cpp) -target_link_libraries(flusher_sls_unittest unittest_base) +target_link_libraries(flusher_sls_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(flusher_sls_unittest) diff --git a/core/unittest/input/CMakeLists.txt b/core/unittest/input/CMakeLists.txt index 0419c47a9c..3e38377147 100644 --- a/core/unittest/input/CMakeLists.txt +++ b/core/unittest/input/CMakeLists.txt @@ -16,10 +16,10 @@ cmake_minimum_required(VERSION 3.22) project(input_unittest) add_executable(input_file_unittest InputFileUnittest.cpp) -target_link_libraries(input_file_unittest unittest_base) +target_link_libraries(input_file_unittest ${UT_BASE_TARGET}) add_executable(input_container_stdio_unittest InputContainerStdioUnittest.cpp) -target_link_libraries(input_container_stdio_unittest unittest_base) +target_link_libraries(input_container_stdio_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(input_file_unittest) diff --git a/core/unittest/log_pb/CMakeLists.txt b/core/unittest/log_pb/CMakeLists.txt index 2a7e5fa5ed..1941bc0a39 100644 --- a/core/unittest/log_pb/CMakeLists.txt +++ b/core/unittest/log_pb/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(log_pb_unittest) add_executable(log_pb_unittest PBUnittest.cpp) -target_link_libraries(log_pb_unittest unittest_base) +target_link_libraries(log_pb_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(log_pb_unittest) diff --git a/core/unittest/logger/CMakeLists.txt b/core/unittest/logger/CMakeLists.txt index 02dc1bf5f9..a5d4fef8d0 100644 --- a/core/unittest/logger/CMakeLists.txt +++ b/core/unittest/logger/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(logger_unittest) add_executable(logger_unittest logger_unittest.cpp) -target_link_libraries(logger_unittest unittest_base) +target_link_libraries(logger_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(logger_unittest) diff --git a/core/unittest/models/CMakeLists.txt b/core/unittest/models/CMakeLists.txt index c0831cd8bc..3face62690 100644 --- a/core/unittest/models/CMakeLists.txt +++ b/core/unittest/models/CMakeLists.txt @@ -16,25 +16,25 @@ cmake_minimum_required(VERSION 3.22) project(models_unittest) add_executable(pipeline_event_unittest PipelineEventUnittest.cpp) -target_link_libraries(pipeline_event_unittest unittest_base) +target_link_libraries(pipeline_event_unittest ${UT_BASE_TARGET}) add_executable(log_event_unittest LogEventUnittest.cpp) -target_link_libraries(log_event_unittest unittest_base) +target_link_libraries(log_event_unittest ${UT_BASE_TARGET}) add_executable(metric_value_unittest MetricValueUnittest.cpp) -target_link_libraries(metric_value_unittest unittest_base) +target_link_libraries(metric_value_unittest ${UT_BASE_TARGET}) add_executable(metric_event_unittest MetricEventUnittest.cpp) -target_link_libraries(metric_event_unittest unittest_base) +target_link_libraries(metric_event_unittest ${UT_BASE_TARGET}) add_executable(span_event_unittest SpanEventUnittest.cpp) -target_link_libraries(span_event_unittest unittest_base) +target_link_libraries(span_event_unittest ${UT_BASE_TARGET}) add_executable(pipeline_event_ptr_unittest PipelineEventPtrUnittest.cpp) -target_link_libraries(pipeline_event_ptr_unittest unittest_base) +target_link_libraries(pipeline_event_ptr_unittest ${UT_BASE_TARGET}) add_executable(pipeline_event_group_unittest PipelineEventGroupUnittest.cpp) -target_link_libraries(pipeline_event_group_unittest unittest_base) +target_link_libraries(pipeline_event_group_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(pipeline_event_unittest) @@ -46,4 +46,4 @@ gtest_discover_tests(pipeline_event_ptr_unittest) gtest_discover_tests(pipeline_event_group_unittest) add_executable(event_group_benchmark EventGroupBenchmark.cpp) -target_link_libraries(event_group_benchmark unittest_base) +target_link_libraries(event_group_benchmark ${UT_BASE_TARGET}) diff --git a/core/unittest/monitor/CMakeLists.txt b/core/unittest/monitor/CMakeLists.txt index e2c7995612..ad875c2263 100644 --- a/core/unittest/monitor/CMakeLists.txt +++ b/core/unittest/monitor/CMakeLists.txt @@ -16,10 +16,10 @@ cmake_minimum_required(VERSION 3.22) project(logtail_metric_unittest) add_executable(logtail_metric_unittest LogtailMetricUnittest.cpp) -target_link_libraries(logtail_metric_unittest unittest_base) +target_link_libraries(logtail_metric_unittest ${UT_BASE_TARGET}) add_executable(profiler_data_integrity_unittest DataIntegrityUnittest.cpp) -target_link_libraries(profiler_data_integrity_unittest unittest_base) +target_link_libraries(profiler_data_integrity_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(logtail_metric_unittest) diff --git a/core/unittest/observer/CMakeLists.txt b/core/unittest/observer/CMakeLists.txt index e1796f97cc..6804a3e4a6 100644 --- a/core/unittest/observer/CMakeLists.txt +++ b/core/unittest/observer/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(observer_unittest) add_executable(observer_config_unittest ObserverConfigUnittest.cpp) -target_link_libraries(observer_config_unittest unittest_base) +target_link_libraries(observer_config_unittest ${UT_BASE_TARGET}) # protocol unittest # add_executable(protocol_dns_unittest ProtocolDnsUnittest.cpp) @@ -25,29 +25,29 @@ target_link_libraries(observer_config_unittest unittest_base) # add_executable(protocol_pgsql_unittest ProtocolPgsqlUnittest.cpp) # add_executable(protocol_mysql_unittest ProtocolMySqlUnittest.cpp) -# target_link_libraries(protocol_dns_unittest unittest_base) -# target_link_libraries(protocol_http_unittest unittest_base) -# target_link_libraries(protocol_redis_unittest unittest_base) -# target_link_libraries(protocol_pgsql_unittest unittest_base) -# target_link_libraries(protocol_mysql_unittest unittest_base) +# target_link_libraries(protocol_dns_unittest ${UT_BASE_TARGET}) +# target_link_libraries(protocol_http_unittest ${UT_BASE_TARGET}) +# target_link_libraries(protocol_redis_unittest ${UT_BASE_TARGET}) +# target_link_libraries(protocol_pgsql_unittest ${UT_BASE_TARGET}) +# target_link_libraries(protocol_mysql_unittest ${UT_BASE_TARGET}) # cgoutp meta unittest # add_executable(cgroup_meta_unittest CGoupMetaUnittest.cpp) -# target_link_libraries(cgroup_meta_unittest unittest_base) +# target_link_libraries(cgroup_meta_unittest ${UT_BASE_TARGET}) add_executable(netlink_meta_unittest NetLinkUnittest.cpp) -target_link_libraries(netlink_meta_unittest unittest_base) +target_link_libraries(netlink_meta_unittest ${UT_BASE_TARGET}) add_executable(hostname_meta_unittest HostnameMetaUnittest.cpp) -target_link_libraries(hostname_meta_unittest unittest_base) +target_link_libraries(hostname_meta_unittest ${UT_BASE_TARGET}) # framework unittest add_executable(network_observer_unittest NetworkObserverUnittest.cpp) add_executable(protocol_util_unittest ProtocolUtilUnittest.cpp) add_executable(protocol_infer_unittest ProtocolInferUnittest.cpp) -target_link_libraries(network_observer_unittest unittest_base) -target_link_libraries(protocol_util_unittest unittest_base) -target_link_libraries(protocol_infer_unittest unittest_base) +target_link_libraries(network_observer_unittest ${UT_BASE_TARGET}) +target_link_libraries(protocol_util_unittest ${UT_BASE_TARGET}) +target_link_libraries(protocol_infer_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(observer_config_unittest) diff --git a/core/unittest/pipeline/CMakeLists.txt b/core/unittest/pipeline/CMakeLists.txt index dc1f7deee3..db81d284e5 100644 --- a/core/unittest/pipeline/CMakeLists.txt +++ b/core/unittest/pipeline/CMakeLists.txt @@ -16,13 +16,13 @@ cmake_minimum_required(VERSION 3.22) project(pipeline_unittest) add_executable(global_config_unittest GlobalConfigUnittest.cpp) -target_link_libraries(global_config_unittest unittest_base) +target_link_libraries(global_config_unittest ${UT_BASE_TARGET}) add_executable(pipeline_unittest PipelineUnittest.cpp) -target_link_libraries(pipeline_unittest unittest_base) +target_link_libraries(pipeline_unittest ${UT_BASE_TARGET}) add_executable(pipeline_manager_unittest PipelineManagerUnittest.cpp) -target_link_libraries(pipeline_manager_unittest unittest_base) +target_link_libraries(pipeline_manager_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(global_config_unittest) diff --git a/core/unittest/plugin/CMakeLists.txt b/core/unittest/plugin/CMakeLists.txt index 73a207c23f..b579277496 100644 --- a/core/unittest/plugin/CMakeLists.txt +++ b/core/unittest/plugin/CMakeLists.txt @@ -16,25 +16,25 @@ cmake_minimum_required(VERSION 3.22) project(plugin_unittest) add_executable(static_input_creator_unittest StaticInputCreatorUnittest.cpp) -target_link_libraries(static_input_creator_unittest unittest_base) +target_link_libraries(static_input_creator_unittest ${UT_BASE_TARGET}) add_executable(static_processor_creator_unittest StaticProcessorCreatorUnittest.cpp) -target_link_libraries(static_processor_creator_unittest unittest_base) +target_link_libraries(static_processor_creator_unittest ${UT_BASE_TARGET}) add_executable(static_flusher_creator_unittest StaticFlusherCreatorUnittest.cpp) -target_link_libraries(static_flusher_creator_unittest unittest_base) +target_link_libraries(static_flusher_creator_unittest ${UT_BASE_TARGET}) add_executable(input_instance_unittest InputInstanceUnittest.cpp) -target_link_libraries(input_instance_unittest unittest_base) +target_link_libraries(input_instance_unittest ${UT_BASE_TARGET}) add_executable(processor_instance_unittest ProcessorInstanceUnittest.cpp) -target_link_libraries(processor_instance_unittest unittest_base) +target_link_libraries(processor_instance_unittest ${UT_BASE_TARGET}) add_executable(flusher_instance_unittest FlusherInstanceUnittest.cpp) -target_link_libraries(flusher_instance_unittest unittest_base) +target_link_libraries(flusher_instance_unittest ${UT_BASE_TARGET}) add_executable(plugin_registry_unittest PluginRegistryUnittest.cpp) -target_link_libraries(plugin_registry_unittest unittest_base) +target_link_libraries(plugin_registry_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(static_input_creator_unittest) diff --git a/core/unittest/polling/CMakeLists.txt b/core/unittest/polling/CMakeLists.txt index 20b8197bd9..82b1b54a17 100644 --- a/core/unittest/polling/CMakeLists.txt +++ b/core/unittest/polling/CMakeLists.txt @@ -16,4 +16,4 @@ cmake_minimum_required(VERSION 3.22) project(polling_unittest) # add_executable(polling_unittest PollingUnittest.cpp) -# target_link_libraries(polling_unittest unittest_base) \ No newline at end of file +# target_link_libraries(polling_unittest ${UT_BASE_TARGET}) \ No newline at end of file diff --git a/core/unittest/processor/CMakeLists.txt b/core/unittest/processor/CMakeLists.txt index b970a70d70..dde242abb2 100644 --- a/core/unittest/processor/CMakeLists.txt +++ b/core/unittest/processor/CMakeLists.txt @@ -16,46 +16,46 @@ cmake_minimum_required(VERSION 3.22) project(processor_unittest) add_executable(processor_split_log_string_native_unittest ProcessorSplitLogStringNativeUnittest.cpp) -target_link_libraries(processor_split_log_string_native_unittest unittest_base) +target_link_libraries(processor_split_log_string_native_unittest ${UT_BASE_TARGET}) add_executable(processor_split_multiline_log_string_native_unittest ProcessorSplitMultilineLogStringNativeUnittest.cpp) -target_link_libraries(processor_split_multiline_log_string_native_unittest unittest_base) +target_link_libraries(processor_split_multiline_log_string_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_regex_native_unittest ProcessorParseRegexNativeUnittest.cpp) -target_link_libraries(processor_parse_regex_native_unittest unittest_base) +target_link_libraries(processor_parse_regex_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_json_native_unittest ProcessorParseJsonNativeUnittest.cpp) -target_link_libraries(processor_parse_json_native_unittest unittest_base) +target_link_libraries(processor_parse_json_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_timestamp_native_unittest ProcessorParseTimestampNativeUnittest.cpp) -target_link_libraries(processor_parse_timestamp_native_unittest unittest_base) +target_link_libraries(processor_parse_timestamp_native_unittest ${UT_BASE_TARGET}) add_executable(processor_tag_native_unittest ProcessorTagNativeUnittest.cpp) -target_link_libraries(processor_tag_native_unittest unittest_base) +target_link_libraries(processor_tag_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_apsara_native_unittest ProcessorParseApsaraNativeUnittest.cpp) -target_link_libraries(processor_parse_apsara_native_unittest unittest_base) +target_link_libraries(processor_parse_apsara_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_delimiter_native_unittest ProcessorParseDelimiterNativeUnittest.cpp) -target_link_libraries(processor_parse_delimiter_native_unittest unittest_base) +target_link_libraries(processor_parse_delimiter_native_unittest ${UT_BASE_TARGET}) add_executable(processor_filter_native_unittest ProcessorFilterNativeUnittest.cpp) -target_link_libraries(processor_filter_native_unittest unittest_base) +target_link_libraries(processor_filter_native_unittest ${UT_BASE_TARGET}) add_executable(processor_desensitize_native_unittest ProcessorDesensitizeNativeUnittest.cpp) -target_link_libraries(processor_desensitize_native_unittest unittest_base) +target_link_libraries(processor_desensitize_native_unittest ${UT_BASE_TARGET}) add_executable(processor_merge_multiline_log_native_unittest ProcessorMergeMultilineLogNativeUnittest.cpp) -target_link_libraries(processor_merge_multiline_log_native_unittest unittest_base) +target_link_libraries(processor_merge_multiline_log_native_unittest ${UT_BASE_TARGET}) add_executable(processor_parse_container_log_native_unittest ProcessorParseContainerLogNativeUnittest.cpp) -target_link_libraries(processor_parse_container_log_native_unittest unittest_base) +target_link_libraries(processor_parse_container_log_native_unittest ${UT_BASE_TARGET}) add_executable(parse_container_log_benchmark ParseContainerLogBenchmark.cpp) -target_link_libraries(parse_container_log_benchmark unittest_base) +target_link_libraries(parse_container_log_benchmark ${UT_BASE_TARGET}) add_executable(boost_regex_benchmark BoostRegexBenchmark.cpp) -target_link_libraries(boost_regex_benchmark unittest_base) +target_link_libraries(boost_regex_benchmark ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(processor_split_log_string_native_unittest) diff --git a/core/unittest/queue/CMakeLists.txt b/core/unittest/queue/CMakeLists.txt index 6b26e6fbc6..b9544727b0 100644 --- a/core/unittest/queue/CMakeLists.txt +++ b/core/unittest/queue/CMakeLists.txt @@ -16,16 +16,16 @@ cmake_minimum_required(VERSION 3.22) project(queue_unittest) add_executable(queue_key_manager_unittest QueueKeyManagerUnittest.cpp) -target_link_libraries(queue_key_manager_unittest unittest_base) +target_link_libraries(queue_key_manager_unittest ${UT_BASE_TARGET}) add_executable(process_queue_unittest ProcessQueueUnittest.cpp) -target_link_libraries(process_queue_unittest unittest_base) +target_link_libraries(process_queue_unittest ${UT_BASE_TARGET}) add_executable(process_queue_manager_unittest ProcessQueueManagerUnittest.cpp) -target_link_libraries(process_queue_manager_unittest unittest_base) +target_link_libraries(process_queue_manager_unittest ${UT_BASE_TARGET}) add_executable(exactly_once_queue_manager_unittest ExactlyOnceQueueManagerUnittest.cpp) -target_link_libraries(exactly_once_queue_manager_unittest unittest_base) +target_link_libraries(exactly_once_queue_manager_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(queue_key_manager_unittest) diff --git a/core/unittest/reader/CMakeLists.txt b/core/unittest/reader/CMakeLists.txt index f1a8d9f46d..f870f9adfd 100644 --- a/core/unittest/reader/CMakeLists.txt +++ b/core/unittest/reader/CMakeLists.txt @@ -16,28 +16,28 @@ cmake_minimum_required(VERSION 3.22) project(log_file_reader_unittest) add_executable(log_file_reader_deleted_file_unittest DeletedFileUnittest.cpp) -target_link_libraries(log_file_reader_deleted_file_unittest unittest_base) +target_link_libraries(log_file_reader_deleted_file_unittest ${UT_BASE_TARGET}) add_executable(file_reader_options_unittest FileReaderOptionsUnittest.cpp) -target_link_libraries(file_reader_options_unittest unittest_base) +target_link_libraries(file_reader_options_unittest ${UT_BASE_TARGET}) add_executable(json_log_file_reader_unittest JsonLogFileReaderUnittest.cpp) -target_link_libraries(json_log_file_reader_unittest unittest_base) +target_link_libraries(json_log_file_reader_unittest ${UT_BASE_TARGET}) add_executable(remove_last_incomplete_log_unittest RemoveLastIncompleteLogUnittest.cpp) -target_link_libraries(remove_last_incomplete_log_unittest unittest_base) +target_link_libraries(remove_last_incomplete_log_unittest ${UT_BASE_TARGET}) add_executable(log_file_reader_unittest LogFileReaderUnittest.cpp) -target_link_libraries(log_file_reader_unittest unittest_base) +target_link_libraries(log_file_reader_unittest ${UT_BASE_TARGET}) add_executable(source_buffer_unittest SourceBufferUnittest.cpp) -target_link_libraries(source_buffer_unittest unittest_base) +target_link_libraries(source_buffer_unittest ${UT_BASE_TARGET}) add_executable(get_last_line_data_unittest GetLastLineDataUnittest.cpp) -target_link_libraries(get_last_line_data_unittest unittest_base) +target_link_libraries(get_last_line_data_unittest ${UT_BASE_TARGET}) add_executable(force_read_unittest ForceReadUnittest.cpp) -target_link_libraries(force_read_unittest unittest_base) +target_link_libraries(force_read_unittest ${UT_BASE_TARGET}) if (UNIX) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testDataSet) diff --git a/core/unittest/sdk/CMakeLists.txt b/core/unittest/sdk/CMakeLists.txt index 7c50e40f0e..f052c1a847 100644 --- a/core/unittest/sdk/CMakeLists.txt +++ b/core/unittest/sdk/CMakeLists.txt @@ -16,4 +16,4 @@ cmake_minimum_required(VERSION 3.22) project(sdk_unittest) # add_executable(sdk_common_unittest SDKCommonUnittest.cpp) -# target_link_libraries(sdk_common_unittest unittest_base) +# target_link_libraries(sdk_common_unittest ${UT_BASE_TARGET}) diff --git a/core/unittest/sender/CMakeLists.txt b/core/unittest/sender/CMakeLists.txt index 344c2f5e04..49f3eb0482 100644 --- a/core/unittest/sender/CMakeLists.txt +++ b/core/unittest/sender/CMakeLists.txt @@ -16,10 +16,10 @@ cmake_minimum_required(VERSION 3.22) project(sender_unittest) add_executable(pack_id_manager_unittest PackIdManagerUnittest.cpp) -target_link_libraries(pack_id_manager_unittest unittest_base) +target_link_libraries(pack_id_manager_unittest ${UT_BASE_TARGET}) # add_executable(sender_unittest SenderUnittest.cpp) -# target_link_libraries(sender_unittest unittest_base) +# target_link_libraries(sender_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(pack_id_manager_unittest) diff --git a/core/unittest/serializer/CMakeLists.txt b/core/unittest/serializer/CMakeLists.txt index 27cb3ad8ac..11c1436ee5 100644 --- a/core/unittest/serializer/CMakeLists.txt +++ b/core/unittest/serializer/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.22) project(serializer_unittest) add_executable(sls_serializer_unittest SLSSerializerUnittest.cpp) -target_link_libraries(sls_serializer_unittest unittest_base) +target_link_libraries(sls_serializer_unittest ${UT_BASE_TARGET}) include(GoogleTest) gtest_discover_tests(sls_serializer_unittest) diff --git a/core/unittest/spl/CMakeLists.txt b/core/unittest/spl/CMakeLists.txt index 886b8e62e7..c8c06addc9 100644 --- a/core/unittest/spl/CMakeLists.txt +++ b/core/unittest/spl/CMakeLists.txt @@ -18,6 +18,6 @@ project(spl_unittest) add_executable(spl_unittest SplUnittest.cpp) add_executable(spl_benchmark_test SplBenchmark.cpp) -target_link_libraries(spl_unittest unittest_base) +target_link_libraries(spl_unittest ${UT_BASE_TARGET}) -target_link_libraries(spl_benchmark_test unittest_base) +target_link_libraries(spl_benchmark_test ${UT_BASE_TARGET}) diff --git a/docs/cn/developer-guide/development-environment.md b/docs/cn/developer-guide/development-environment.md index 81ec78cffa..f414bf4d84 100644 --- a/docs/cn/developer-guide/development-environment.md +++ b/docs/cn/developer-guide/development-environment.md @@ -144,10 +144,10 @@ cmake -D CMAKE_BUILD_TYPE=Debug .. 同理,若需要明确需要代码优化,则将上面的Debug改为Release。 -默认的编译开关没有打开UT,如果需要编译UT,需要增加BUILD_LOGTAIL_NOSPL_UT或BUILD_LOGTAIL_SPL_UT开关。替换上述第2行为 +默认的编译开关没有打开UT,如果需要编译UT,需要增加BUILD_LOGTAIL_UT开关。替换上述第2行为 ```bash -cmake -DBUILD_LOGTAIL_NOSPL_UT=ON .. +cmake -DBUILD_LOGTAIL_UT=ON .. ``` - 制作镜像 diff --git a/scripts/gen_build_scripts.sh b/scripts/gen_build_scripts.sh index bd7a345958..bc702a44c5 100755 --- a/scripts/gen_build_scripts.sh +++ b/scripts/gen_build_scripts.sh @@ -34,8 +34,7 @@ GO_MOD_FILE=${9:-${GO_MOD_FILE:-go.mod}} BUILD_TYPE=${BUILD_TYPE:-Release} BUILD_LOGTAIL=${BUILD_LOGTAIL:-ON} -BUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT:-OFF} -BUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT:-OFF} +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} @@ -84,11 +83,11 @@ 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_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_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} -DWITHOUTSPL=${WITHOUTSPL} .. && 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_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_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 + 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 - echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/plugin_gocbuild.sh ${OUT_DIR} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE + 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/plugin_gocbuild.sh ${OUT_DIR} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE fi } @@ -105,14 +104,14 @@ function generateCopyScript() { echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/go_pipeline/libPluginAdapter.so $BINDIR' >>$COPY_SCRIPT_FILE fi - if [ $BUILD_LOGTAIL_NOSPL_UT = "ON" -o $BUILD_LOGTAIL_SPL_UT = "ON" ]; then + if [ $BUILD_LOGTAIL_UT = "ON" ]; then echo 'docker cp "$id":/src/core/build core/build' >>$COPY_SCRIPT_FILE fi else echo 'docker cp "$id":/src/'${OUT_DIR}'/libPluginBase.so $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/go_pipeline/libPluginAdapter.so $BINDIR' >>$COPY_SCRIPT_FILE - if [ $BUILD_LOGTAIL_NOSPL_UT = "ON" -o $BUILD_LOGTAIL_SPL_UT = "ON" ]; then + if [ $BUILD_LOGTAIL_UT = "ON" ]; then echo 'docker cp "$id":/src/core/build core/build' >>$COPY_SCRIPT_FILE fi fi