Support old plugins that use files within the source/build tree

Plugins that were made using an older skeleton (e.g. from Bro 2.5.x)
may still reference "bro-config.h", "bro-path-dev", or "bro" from the
build tree, so we can simply provide compatibility symlinks/wrappers
for the new files that use "zeek" in their names.
This commit is contained in:
Jon Siwek 2019-07-15 11:19:30 -07:00
parent 50e4da74cf
commit 4bdcde52bd
4 changed files with 23 additions and 1 deletions

View file

@ -40,6 +40,9 @@ get_filename_component(ZEEK_SCRIPT_INSTALL_PATH ${ZEEK_SCRIPT_INSTALL_PATH}
set(BRO_PLUGIN_INSTALL_PATH ${ZEEK_ROOT_DIR}/lib/zeek/plugins CACHE STRING "Installation path for plugins" FORCE)
configure_file(zeek-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev)
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/zeek-wrapper.in"
"${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev.sh
"export ZEEKPATH=`${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev`\n"
@ -290,8 +293,11 @@ endif ()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/zeek-config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bro-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/bro-config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zeek-config.h DESTINATION include/zeek)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bro-config.h DESTINATION include/zeek)
if ( CAF_ROOT_DIR )
set(ZEEK_CONFIG_CAF_ROOT_DIR ${CAF_ROOT_DIR})
@ -323,7 +329,6 @@ include(InstallShellScript)
include(InstallSymlink)
InstallShellScript("bin" "zeek-wrapper.in" "zeek-wrapper")
InstallSymlink("${CMAKE_INSTALL_PREFIX}/bin/zeek-wrapper" "${CMAKE_INSTALL_PREFIX}/bin/bro-config")
InstallSymlink("${CMAKE_INSTALL_PREFIX}/include/zeek/zeek-config.h" "${CMAKE_INSTALL_PREFIX}/include/zeek/bro-config.h")
########################################################################
## Recurse on sub-directories

8
bro-config.h.in Normal file
View file

@ -0,0 +1,8 @@
#ifndef BRO_CONFIG_H
#define BRO_CONFIG_H
#pragma message("Warning: bro-config.h is deprecated, use zeek-config.h instead")
#include "zeek-config.h"
#endif // BRO_CONFIG_H

View file

@ -377,6 +377,11 @@ set(BRO_EXE zeek
set(BRO_EXE_PATH ${CMAKE_CURRENT_BINARY_DIR}/zeek
CACHE STRING "Path to Zeek executable binary" FORCE)
# Older plugins may still use `bro` in unit tests.
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/../zeek-wrapper.in"
"${CMAKE_CURRENT_BINARY_DIR}/bro")
# Target to create all the autogenerated files.
add_custom_target(generate_outputs_stage1)
add_dependencies(generate_outputs_stage1 ${bro_ALL_GENERATED_OUTPUTS})

View file

@ -1,3 +1,6 @@
#ifndef ZEEK_CONFIG_H
#define ZEEK_CONFIG_H
/* Old libpcap versions (< 0.6.1) need defining pcap_freecode and
pcap_compile_nopcap */
#cmakedefine DONT_HAVE_LIBPCAP_PCAP_FREECODE
@ -237,3 +240,4 @@ extern const char* BRO_VERSION_FUNCTION();
}
#endif
#endif // ZEEK_CONFIG_H