Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,12 @@ if(FLB_OUT_PGSQL AND (NOT PostgreSQL_FOUND))
FLB_OPTION(FLB_OUT_PGSQL OFF)
endif()

# ZeroBus FFI
# ===========
if(FLB_OUT_ZEROBUS)
include(cmake/zerobus-ffi.cmake)
endif()

# Arrow GLib
# ==========
find_package(PkgConfig)
Expand Down
1 change: 1 addition & 0 deletions cmake/plugins_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ DEFINE_OPTION(FLB_OUT_TCP "Enable TCP output plugin"
DEFINE_OPTION(FLB_OUT_UDP "Enable UDP output plugin" ON)
DEFINE_OPTION(FLB_OUT_VIVO_EXPORTER "Enable Vivo exporter output plugin" ON)
DEFINE_OPTION(FLB_OUT_WEBSOCKET "Enable Websocket output plugin" ON)
DEFINE_OPTION(FLB_OUT_ZEROBUS "Enable Databricks ZeroBus output plugin" ON)
95 changes: 95 additions & 0 deletions cmake/zerobus-ffi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Set up the ZeroBus FFI prebuilt static library.
#
# If ZEROBUS_LIB_DIR is already set by the user, that path is used as-is.
# Otherwise the official release tarball is downloaded and the correct
# platform subdirectory is selected automatically.
#
# On unsupported platforms or when the download fails, the plugin is
# disabled automatically (FLB_OUT_ZEROBUS is set to OFF).
#
# After this module runs, ZEROBUS_LIB_DIR points to the directory
# containing libzerobus_ffi.a for the current platform.

if(ZEROBUS_LIB_DIR)
return()
endif()

set(_ZEROBUS_URL
"https://github.com/databricks/zerobus-sdk/releases/download/ffi-v1.0.0/zerobus-ffi-1.0.0.tar.gz")
set(_ZEROBUS_SHA256
"c38609f5bddc160b43b35f9047919b35f66375308be69a0d0d6cd20bc01cee5a")

# Determine the platform subdirectory inside the tarball
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64")
set(_ZEROBUS_PLATFORM "linux-aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set(_ZEROBUS_PLATFORM "linux-x86-64")
else()
message(STATUS
"ZeroBus FFI: unsupported Linux architecture '${CMAKE_SYSTEM_PROCESSOR}', "
"disabling out_zerobus. "
"To build manually, set -DZEROBUS_LIB_DIR=/path/to/lib.")
FLB_OPTION(FLB_OUT_ZEROBUS OFF)
return()
endif()
else()
message(STATUS
"ZeroBus FFI: no prebuilt library available for ${CMAKE_SYSTEM_NAME}, "
"disabling out_zerobus. "
"To build manually, set -DZEROBUS_LIB_DIR=/path/to/lib.")
FLB_OPTION(FLB_OUT_ZEROBUS OFF)
return()
endif()

# Download the tarball if not already cached
set(_ZEROBUS_TARBALL "${CMAKE_BINARY_DIR}/zerobus-ffi-1.0.0.tar.gz")
if(NOT EXISTS "${_ZEROBUS_TARBALL}")
message(STATUS "ZeroBus FFI: downloading ${_ZEROBUS_URL}")
file(DOWNLOAD
"${_ZEROBUS_URL}"
"${_ZEROBUS_TARBALL}"
EXPECTED_HASH "SHA256=${_ZEROBUS_SHA256}"
SHOW_PROGRESS
STATUS _DOWNLOAD_STATUS
)
list(GET _DOWNLOAD_STATUS 0 _DOWNLOAD_ERROR)
if(_DOWNLOAD_ERROR)
message(STATUS
"ZeroBus FFI: download failed (${_DOWNLOAD_STATUS}), "
"disabling out_zerobus. "
"To build manually, set -DZEROBUS_LIB_DIR=/path/to/lib.")
file(REMOVE "${_ZEROBUS_TARBALL}")
FLB_OPTION(FLB_OUT_ZEROBUS OFF)
return()
endif()
endif()

# Extract the tarball
set(_ZEROBUS_EXTRACT_DIR "${CMAKE_BINARY_DIR}")
if(NOT EXISTS "${_ZEROBUS_EXTRACT_DIR}/native")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf "${_ZEROBUS_TARBALL}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
RESULT_VARIABLE _EXTRACT_RESULT
)
if(_EXTRACT_RESULT)
message(STATUS
"ZeroBus FFI: extraction failed, disabling out_zerobus.")
FLB_OPTION(FLB_OUT_ZEROBUS OFF)
return()
endif()
endif()

set(ZEROBUS_LIB_DIR "${_ZEROBUS_EXTRACT_DIR}/native/${_ZEROBUS_PLATFORM}"
CACHE PATH "Path to ZeroBus FFI library directory" FORCE)

if(NOT EXISTS "${ZEROBUS_LIB_DIR}/libzerobus_ffi.a")
message(STATUS
"ZeroBus FFI: libzerobus_ffi.a not found at ${ZEROBUS_LIB_DIR}, "
"disabling out_zerobus.")
FLB_OPTION(FLB_OUT_ZEROBUS OFF)
return()
endif()

message(STATUS "ZeroBus FFI library: ${ZEROBUS_LIB_DIR}/libzerobus_ffi.a")
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ REGISTER_OUT_PLUGIN("out_prometheus_remote_write")
REGISTER_OUT_PLUGIN("out_s3")
REGISTER_OUT_PLUGIN("out_vivo_exporter")
REGISTER_OUT_PLUGIN("out_chronicle")
REGISTER_OUT_PLUGIN("out_zerobus")

if(FLB_ZIG)
REGISTER_OUT_PLUGIN("out_zig_demo" "zig")
Expand Down
29 changes: 29 additions & 0 deletions plugins/out_zerobus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set(src
zerobus.c)

FLB_PLUGIN(out_zerobus "${src}" "")

# ZEROBUS_LIB_DIR is set automatically by cmake/zerobus-ffi.cmake or
# can be overridden by the user via -DZEROBUS_LIB_DIR=/path/to/lib.
if(NOT ZEROBUS_LIB_DIR)
message(FATAL_ERROR
"ZEROBUS_LIB_DIR is not set. This should not happen when "
"FLB_OUT_ZEROBUS is ON — check that cmake/zerobus-ffi.cmake is included.")
endif()

target_link_libraries(flb-plugin-out_zerobus ${ZEROBUS_LIB_DIR}/libzerobus_ffi.a)

# Platform-specific linker flags required by the Rust FFI static library
if(WIN32)
message(FATAL_ERROR
"out_zerobus does not support Windows builds. "
"Disable it with -DFLB_OUT_ZEROBUS=OFF")
elseif(APPLE)
target_link_libraries(flb-plugin-out_zerobus
"-framework CoreFoundation"
"-framework Security"
-liconv)
elseif(UNIX)
target_link_libraries(flb-plugin-out_zerobus
-ldl -lpthread -lm -lresolv -lgcc_s)
endif()
Loading