Skip to content

Commit

Permalink
fix: change design. Build .a and .so at the same CI UT job
Browse files Browse the repository at this point in the history
  • Loading branch information
alph00 committed Jul 12, 2024
1 parent def1194 commit 119d8a7
Show file tree
Hide file tree
Showing 46 changed files with 242 additions and 282 deletions.
90 changes: 0 additions & 90 deletions .github/workflows/build-core-nospl-ut.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/build-core-spl-ut.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -66,18 +66,18 @@ 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
MAKE_JOBS: 16
# 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:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/e2e-framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 27 additions & 21 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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()
Expand All @@ -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})
Expand Down
5 changes: 4 additions & 1 deletion core/common/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ elseif(UNIX)
endif()

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})
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})
8 changes: 4 additions & 4 deletions core/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion core/flusher/flusher.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
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})
5 changes: 4 additions & 1 deletion core/input/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ elseif(UNIX)
endif()

# Set source files to parent
set(SUBDIR_SOURCE_FILES ${SUBDIR_SOURCE_FILES} ${THIS_SOURCE_FILES_LIST})
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})
2 changes: 1 addition & 1 deletion core/links.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
19 changes: 12 additions & 7 deletions core/processor/links.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 5 additions & 1 deletion core/processor/processor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
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})
Loading

0 comments on commit 119d8a7

Please sign in to comment.