mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Use object libraries for subdir libs and plugins
This commit is contained in:
parent
6775463f13
commit
25aadd82ef
12 changed files with 16 additions and 66 deletions
|
@ -13,10 +13,6 @@ set(bro_REGISTER_BIFS CACHE INTERNAL "BIFs for automatic registering" FORCE)
|
|||
set(bro_BASE_BIF_SCRIPTS CACHE INTERNAL "Zeek script stubs for BIFs in base distribution of Zeek" FORCE)
|
||||
set(bro_PLUGIN_BIF_SCRIPTS CACHE INTERNAL "Zeek script stubs for BIFs in Zeek plugins" FORCE)
|
||||
|
||||
# If TRUE, use CMake's object libraries for sub-directories instead of
|
||||
# static libraries. This requires CMake >= 2.8.8.
|
||||
set(bro_HAVE_OBJECT_LIBRARIES FALSE)
|
||||
|
||||
configure_file(version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c)
|
||||
configure_file(util-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/util-config.h)
|
||||
|
||||
|
@ -139,7 +135,9 @@ list(APPEND BINPAC_OUTPUTS "${BINPAC_OUTPUT_CC}")
|
|||
########################################################################
|
||||
|
||||
set(bro_SUBDIR_LIBS CACHE INTERNAL "subdir libraries" FORCE)
|
||||
set(bro_SUBDIR_DEPS CACHE INTERNAL "subdir dependencies" FORCE)
|
||||
set(bro_PLUGIN_LIBS CACHE INTERNAL "plugin libraries" FORCE)
|
||||
set(bro_PLUGIN_DEPS CACHE INTERNAL "plugin dependencies" FORCE)
|
||||
|
||||
add_subdirectory(analyzer)
|
||||
add_subdirectory(broker)
|
||||
|
@ -150,26 +148,6 @@ add_subdirectory(iosource)
|
|||
add_subdirectory(logging)
|
||||
add_subdirectory(probabilistic)
|
||||
|
||||
set(bro_SUBDIRS
|
||||
# Order is important here.
|
||||
${bro_PLUGIN_LIBS}
|
||||
${bro_SUBDIR_LIBS}
|
||||
)
|
||||
|
||||
if ( NOT bro_HAVE_OBJECT_LIBRARIES )
|
||||
foreach (_plugin ${bro_PLUGIN_LIBS})
|
||||
string(REGEX REPLACE "plugin-" "" _plugin "${_plugin}")
|
||||
string(REGEX REPLACE "-" "_" _plugin "${_plugin}")
|
||||
set(_decl "namespace plugin { namespace ${_plugin} { class Plugin; extern Plugin plugin; } };")
|
||||
set(_use "i += (size_t)(&(plugin::${_plugin}::plugin));")
|
||||
set(__BRO_DECL_PLUGINS "${__BRO_DECL_PLUGINS}${_decl}\n")
|
||||
set(__BRO_USE_PLUGINS "${__BRO_USE_PLUGINS}${_use}\n")
|
||||
endforeach()
|
||||
|
||||
configure_file(plugins.cc.in ${CMAKE_CURRENT_BINARY_DIR}/plugins.cc)
|
||||
set(PLUGIN_INIT ${CMAKE_CURRENT_BINARY_DIR}/plugins.cc)
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
## bro target
|
||||
|
||||
|
@ -344,20 +322,14 @@ set(bro_SRCS
|
|||
${FLEX_Scanner_INPUT}
|
||||
${BISON_Parser_INPUT}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h
|
||||
${PLUGIN_INIT}
|
||||
${THIRD_PARTY_SRCS}
|
||||
${MAIN_SRCS}
|
||||
)
|
||||
|
||||
collect_headers(bro_HEADERS ${bro_SRCS})
|
||||
|
||||
if ( bro_HAVE_OBJECT_LIBRARIES )
|
||||
add_executable(zeek ${bro_SRCS} ${bro_HEADERS} ${bro_SUBDIRS})
|
||||
target_link_libraries(zeek ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||
else ()
|
||||
add_executable(zeek ${bro_SRCS} ${bro_HEADERS})
|
||||
target_link_libraries(zeek ${bro_SUBDIRS} ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||
endif ()
|
||||
add_executable(zeek ${bro_SRCS} ${bro_HEADERS} ${bro_SUBDIR_LIBS} ${bro_PLUGIN_LIBS})
|
||||
target_link_libraries(zeek ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||
|
||||
if ( NOT "${bro_LINKER_FLAGS}" STREQUAL "" )
|
||||
set_target_properties(zeek PROPERTIES LINK_FLAGS "${bro_LINKER_FLAGS}")
|
||||
|
@ -396,12 +368,12 @@ add_dependencies(generate_outputs generate_outputs_stage2a generate_outputs_stag
|
|||
|
||||
# Build __load__.zeek files for standard *.bif.zeek.
|
||||
bro_bif_create_loader(bif_loader "${bro_BASE_BIF_SCRIPTS}")
|
||||
add_dependencies(bif_loader ${bro_SUBDIRS})
|
||||
add_dependencies(bif_loader ${bro_PLUGIN_DEPS} ${bro_SUBDIR_DEPS})
|
||||
add_dependencies(zeek bif_loader)
|
||||
|
||||
# Build __load__.zeek files for plugins/*.bif.zeek.
|
||||
bro_bif_create_loader(bif_loader_plugins "${bro_PLUGIN_BIF_SCRIPTS}")
|
||||
add_dependencies(bif_loader_plugins ${bro_SUBDIRS})
|
||||
add_dependencies(bif_loader_plugins ${bro_PLUGIN_DEPS} ${bro_SUBDIR_DEPS})
|
||||
add_dependencies(zeek bif_loader_plugins)
|
||||
|
||||
# Install *.bif.zeek.
|
||||
|
|
|
@ -17,6 +17,6 @@ set(analyzer_SRCS
|
|||
|
||||
bif_target(analyzer.bif)
|
||||
|
||||
bro_add_subdir_library(analyzer ${analyzer_SRCS} ${BIF_OUTPUT_CC})
|
||||
bro_add_subdir_library(analyzer ${analyzer_SRCS})
|
||||
add_dependencies(bro_analyzer generate_outputs)
|
||||
|
||||
|
|
|
@ -21,5 +21,5 @@ bif_target(data.bif)
|
|||
bif_target(messaging.bif)
|
||||
bif_target(store.bif)
|
||||
|
||||
bro_add_subdir_library(brokercomm ${comm_SRCS} ${BIF_OUTPUT_CC})
|
||||
bro_add_subdir_library(brokercomm ${comm_SRCS})
|
||||
add_dependencies(bro_brokercomm generate_outputs)
|
||||
|
|
|
@ -20,5 +20,5 @@ set(file_analysis_SRCS
|
|||
|
||||
bif_target(file_analysis.bif)
|
||||
|
||||
bro_add_subdir_library(file_analysis ${file_analysis_SRCS} ${BIF_OUTPUT_CC})
|
||||
bro_add_subdir_library(file_analysis ${file_analysis_SRCS})
|
||||
add_dependencies(bro_file_analysis generate_outputs)
|
||||
|
|
|
@ -4,5 +4,5 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
zeek_plugin_begin(Zeek FileDataEvent)
|
||||
zeek_plugin_cc(DataEvent.cc Plugin.cc ../../Analyzer.cc)
|
||||
zeek_plugin_cc(DataEvent.cc Plugin.cc)
|
||||
zeek_plugin_end()
|
||||
|
|
|
@ -4,6 +4,6 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
zeek_plugin_begin(Zeek FileEntropy)
|
||||
zeek_plugin_cc(Entropy.cc Plugin.cc ../../Analyzer.cc)
|
||||
zeek_plugin_cc(Entropy.cc Plugin.cc)
|
||||
zeek_plugin_bif(events.bif)
|
||||
zeek_plugin_end()
|
||||
|
|
|
@ -4,7 +4,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
zeek_plugin_begin(Zeek FileExtract)
|
||||
zeek_plugin_cc(Extract.cc Plugin.cc ../../Analyzer.cc)
|
||||
zeek_plugin_cc(Extract.cc Plugin.cc)
|
||||
zeek_plugin_bif(events.bif)
|
||||
zeek_plugin_bif(functions.bif)
|
||||
zeek_plugin_end()
|
||||
|
|
|
@ -4,6 +4,6 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
zeek_plugin_begin(Zeek FileHash)
|
||||
zeek_plugin_cc(Hash.cc Plugin.cc ../../Analyzer.cc)
|
||||
zeek_plugin_cc(Hash.cc Plugin.cc)
|
||||
zeek_plugin_bif(events.bif)
|
||||
zeek_plugin_end()
|
||||
|
|
|
@ -5,7 +5,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
zeek_plugin_begin(Zeek Unified2)
|
||||
zeek_plugin_cc(Unified2.cc Plugin.cc ../../Analyzer.cc)
|
||||
zeek_plugin_cc(Unified2.cc Plugin.cc)
|
||||
zeek_plugin_bif(events.bif types.bif)
|
||||
zeek_plugin_pac(unified2.pac unified2-file.pac unified2-analyzer.pac)
|
||||
zeek_plugin_end()
|
||||
|
|
|
@ -18,6 +18,6 @@ set(input_SRCS
|
|||
|
||||
bif_target(input.bif)
|
||||
|
||||
bro_add_subdir_library(input ${input_SRCS} ${BIF_OUTPUT_CC})
|
||||
bro_add_subdir_library(input ${input_SRCS})
|
||||
add_dependencies(bro_input generate_outputs)
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ set(logging_SRCS
|
|||
|
||||
bif_target(logging.bif)
|
||||
|
||||
bro_add_subdir_library(logging ${logging_SRCS} ${BIF_OUTPUT_CC})
|
||||
bro_add_subdir_library(logging ${logging_SRCS})
|
||||
add_dependencies(bro_logging generate_outputs)
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
// A work-around the problem that for static libraries unused globals
|
||||
// aren't linked into the final binary. CMake automatically inserts
|
||||
// code here to reference the globals that initializes each of the
|
||||
// statically compiled plugins.
|
||||
//
|
||||
// Note: This won't be necessary anymore once we can assume CMake >2.8.8
|
||||
// as a required depencendy. If so, switch bro_HAVE_OBJECT_LIBRARIES
|
||||
// in src/CMakeLists.txt to TRUE and remove this.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
${__BRO_DECL_PLUGINS}
|
||||
|
||||
size_t __make_sure_to_use_plugin_globals()
|
||||
{
|
||||
// This function is never actually called.
|
||||
|
||||
size_t i = 0;
|
||||
${__BRO_USE_PLUGINS}
|
||||
return i;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue