Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speedup CI UT job #1606

Merged
merged 8 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
25 changes: 11 additions & 14 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ 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(WITHSPL "Link Logtail with SPL" ON)
option(WITHSPL "Build Logtail and UT with SPL" ON)
option(BUILD_LOGTAIL_UT "Build unit test for Logtail")

if (BUILD_LOGTAIL_SHARED_LIBRARY AND WITHSPL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUILD_LOGTAIL_SHARED_LIBRARY 注释说明下应用场景

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image BUILD_LOGTAIL_SHARED_LIBRARY 是用于生成动态库的开关,是原来就有的

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码注释,不是评论注释。说明下什么场景会用

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

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)
set(UT_LINK_NEED_SPL OFF)

if (ENABLE_ENTERPRISE)
message(STATUS "Enable Enterprise Feature.")
add_definitions(-D__ENTERPRISE__)
Expand Down Expand Up @@ -217,14 +214,6 @@ if (BUILD_LOGTAIL_SHARED_LIBRARY)
endif()
endif ()

# Logtail UT.
if (BUILD_LOGTAIL_UT)
message(STATUS "Build unittest.")
include(CTest)
enable_testing()
add_subdirectory(unittest)
endif ()

# Generate independent libraries.
# add_subdirectory(helper)
add_subdirectory(go_pipeline)
Expand All @@ -233,8 +222,16 @@ add_subdirectory(common)
# Link libraries.
if(BUILD_LOGTAIL OR BUILD_LOGTAIL_SHARED_LIBRARY)
input_link(${LOGTAIL_TARGET})
processor_link(${LOGTAIL_TARGET} ${UT_LINK} ${UT_LINK_NEED_SPL})
processor_link(${LOGTAIL_TARGET} ${WITHSPL})
flusher_link(${LOGTAIL_TARGET})
all_link(${LOGTAIL_TARGET})
common_link(${LOGTAIL_TARGET})
endif()
endif()

# Logtail UT.
if (BUILD_LOGTAIL_UT)
message(STATUS "Build unittest.")
include(CTest)
enable_testing()
add_subdirectory(unittest)
endif ()
17 changes: 5 additions & 12 deletions core/processor/links.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
# limitations under the License.
# This file is used to link external source files in processor directory

macro(processor_link target_name ut_link ut_link_need_spl)
macro(processor_link target_name link_withspl)
link_re2(${target_name})
if(${ut_link})
if(${ut_link_need_spl})
link_spl(${target_name})
target_link_libraries(${target_name} spl)
endif()
else ()
if (LINUX AND WITHSPL)
link_spl(${target_name})
target_link_libraries(${target_name} spl)
endif ()
endif()
if (LINUX AND ${link_withspl})
link_spl(${target_name})
target_link_libraries(${target_name} spl)
endif ()
link_ssl(${target_name}) # must after link_spl
link_crypto(${target_name}) # must after link_spl
endmacro()
23 changes: 8 additions & 15 deletions core/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ add_definitions(-DLOGTAIL_NO_TC_MALLOC)
if (MSVC)
add_definitions(-DNOMINMAX)
endif ()
set(UT_LINK ON)

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)

macro(add_core_subdir)
yyuuttaaoo marked this conversation as resolved.
Show resolved Hide resolved
add_subdirectory(app_config)
Expand Down Expand Up @@ -67,9 +60,9 @@ macro(add_spl_subdir)
endif ()
endmacro()

macro(ut_link need_spl)
macro(ut_link ut_link_withspl)
input_link(${UT_BASE_TARGET})
processor_link(${UT_BASE_TARGET} ${UT_LINK} ${need_spl})
processor_link(${UT_BASE_TARGET} ${ut_link_withspl})
flusher_link(${UT_BASE_TARGET})
all_link(${UT_BASE_TARGET})
common_link(${UT_BASE_TARGET})
Expand All @@ -86,25 +79,25 @@ if (UNIX)
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})
set(UT_LINK_WITHSPL ON)
ut_link(${UT_LINK_WITHSPL})
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})
set(UT_LINK_WITHSPL OFF)
ut_link(${UT_LINK_WITHSPL})
else ()
# 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_core_subdir()
set(UT_LINK_NEED_SPL OFF)
ut_link(${UT_LINK_NEED_SPL})
set(UT_LINK_WITHSPL OFF)
ut_link(${UT_LINK_WITHSPL})
endif ()
elseif (MSVC)
# For MSVC, use /W4 for a high level of warnings, and treat warnings as errors.
Expand Down
Loading