Merge remote-tracking branch 'origin/topic/neverlord/version-header'

* origin/topic/neverlord/version-header:
  testing/zeek-version-link: Assume nm is there
  Drop dependency for zeek_dynamic_plugin_base
  Fixup ifdef check in Plugin.h
  Update cmake_minimum_required() in test plugins
  testing: Add zeek-version-link tests
  Clean up ZEEK_CONFIG_SKIP_VERSION_H issues

cmake-format during merge
This commit is contained in:
Arne Welzel 2023-05-10 23:16:24 +02:00
commit 8c0e7cd8bc
14 changed files with 51 additions and 17 deletions

14
CHANGES
View file

@ -1,3 +1,17 @@
6.0.0-dev.541 | 2023-05-10 23:16:24 +0200
* testing/zeek-version-link: Assume nm is there (Arne Welzel, Corelight)
* Drop dependency for zeek_dynamic_plugin_base (Dominik Charousset, Corelight)
* Fixup ifdef check in Plugin.h (Arne Welzel, Corelight)
* Update cmake_minimum_required() in test plugins (Arne Welzel, Corelight)
* testing: Add zeek-version-link tests (Arne Welzel, Corelight)
* Clean up ZEEK_CONFIG_SKIP_VERSION_H issues (Dominik Charousset, Corelight)
6.0.0-dev.533 | 2023-05-09 13:38:37 -0700 6.0.0-dev.533 | 2023-05-09 13:38:37 -0700
* core.network_time.broker: Test reliability improvement (Arne Welzel, Corelight) * core.network_time.broker: Test reliability improvement (Arne Welzel, Corelight)

View file

@ -188,6 +188,9 @@ set_target_properties(zeek_internal PROPERTIES EXPORT_NAME Internal)
install(TARGETS zeek_internal EXPORT ZeekTargets) install(TARGETS zeek_internal EXPORT ZeekTargets)
target_compile_features(zeek_internal INTERFACE ${ZEEK_CXX_STD}) target_compile_features(zeek_internal INTERFACE ${ZEEK_CXX_STD})
# Skip "link-time version check" in Plugin.h for plugins that we bake in.
target_compile_definitions(zeek_internal INTERFACE ZEEK_PLUGIN_SKIP_VERSION_CHECK)
# Target for bundling the creation of auto-generated files. # Target for bundling the creation of auto-generated files.
add_custom_target(zeek_autogen_files) add_custom_target(zeek_autogen_files)
@ -238,6 +241,13 @@ if (ZEEK_ENABLE_FUZZERS)
set(zeek_fuzzer_shared_access PUBLIC) set(zeek_fuzzer_shared_access PUBLIC)
endif () endif ()
# Set ZEEK_CONFIG_SKIP_VERSION_H for our main in-source targets.
foreach (name zeek_exe zeek_lib zeek_fuzzer_shared)
if (TARGET ${name})
target_compile_definitions(${name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H)
endif ()
endforeach ()
# Convenience function for adding library dependencies to the main target(s). # Convenience function for adding library dependencies to the main target(s).
function (zeek_target_link_libraries lib_target) function (zeek_target_link_libraries lib_target)
foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) foreach (name zeek_exe zeek_lib zeek_fuzzer_shared)
@ -268,7 +278,6 @@ endfunction ()
# loaded plugins. Also propagates include paths and C++17 mode on the install # loaded plugins. Also propagates include paths and C++17 mode on the install
# interface. # interface.
add_library(zeek_dynamic_plugin_base INTERFACE) add_library(zeek_dynamic_plugin_base INTERFACE)
target_link_libraries(zeek_dynamic_plugin_base INTERFACE $<BUILD_INTERFACE:zeek_internal>)
target_include_directories( target_include_directories(
zeek_dynamic_plugin_base zeek_dynamic_plugin_base
INTERFACE $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> INTERFACE $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
@ -318,6 +327,7 @@ function (zeek_add_subdir_library name)
# Create target and add the sources. # Create target and add the sources.
set(target_name "zeek_${name}_obj") set(target_name "zeek_${name}_obj")
add_library(${target_name} OBJECT ${FN_ARGS_SOURCES}) add_library(${target_name} OBJECT ${FN_ARGS_SOURCES})
target_compile_definitions(${target_name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H)
add_dependencies(${target_name} zeek_autogen_files) add_dependencies(${target_name} zeek_autogen_files)
target_link_libraries(${target_name} PRIVATE $<BUILD_INTERFACE:zeek_internal>) target_link_libraries(${target_name} PRIVATE $<BUILD_INTERFACE:zeek_internal>)
add_clang_tidy_files(${FN_ARGS_SOURCES}) add_clang_tidy_files(${FN_ARGS_SOURCES})

View file

@ -1 +1 @@
6.0.0-dev.533 6.0.0-dev.541

View file

@ -13,8 +13,10 @@
// Avoid ccache busting of Plugin.h for internal plugins by // Avoid ccache busting of Plugin.h for internal plugins by
// only including zeek/zeek-version.h if we're building an // only including zeek/zeek-version.h if we're building an
// external plugin. // external plugin. The define gets set in the CMakeLists.txt file
#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD // for the Zeek::Internal target, which only exists when
// building Zeek itself.
#ifndef ZEEK_PLUGIN_SKIP_VERSION_CHECK
#include "zeek/zeek-version.h" #include "zeek/zeek-version.h"
// Remove the BRO define in v6.1. // Remove the BRO define in v6.1.
#define BRO_PLUGIN_BRO_VERSION ZEEK_VERSION_FUNCTION #define BRO_PLUGIN_BRO_VERSION ZEEK_VERSION_FUNCTION
@ -130,10 +132,12 @@ public:
#endif #endif
inline Configuration() __attribute__((always_inline)) inline Configuration() __attribute__((always_inline))
{ {
// Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external // Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external plugins. The
// plugins. The internal ones are in the same binary so the runtime // internal ones are in the same binary so the runtime link check shouldn't be
// link check shouldn't be needed and we can avoid ccache busting. // needed and we can avoid ccache busting. The define gets set in the
#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD // CMakeLists.txt file for the Zeek::Internal target, which only exists when
// building Zeek itself.
#ifndef ZEEK_PLUGIN_SKIP_VERSION_CHECK
bro_version = ZEEK_PLUGIN_ZEEK_VERSION; bro_version = ZEEK_PLUGIN_ZEEK_VERSION;
zeek_version = ZEEK_PLUGIN_ZEEK_VERSION; zeek_version = ZEEK_PLUGIN_ZEEK_VERSION;
#endif #endif

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Foo-FOO) project(Zeek-Plugin-Foo-FOO)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Conflict-Plugin) project(Zeek-Plugin-Conflict-Plugin)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT BRO_DIST) if (NOT BRO_DIST)
message(FATAL_ERROR "BRO_DIST not set") message(FATAL_ERROR "BRO_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Packet-Plugin-Demo) project(Zeek-Packet-Plugin-Demo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -1,6 +1,6 @@
project(Zeek-Plugin-Demo-Foo) project(Zeek-Plugin-Demo-Foo)
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.15)
if (NOT ZEEK_DIST) if (NOT ZEEK_DIST)
message(FATAL_ERROR "ZEEK_DIST not set") message(FATAL_ERROR "ZEEK_DIST not set")

View file

@ -0,0 +1,6 @@
# @TEST-DOC: Poking at internals: Expect an undefined zeek_version_X_Y_Z_plugin symbol in the plugin's .so/.dynlib. If this test turns out to be brittle, remove it, but we lost the mechanism.
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Foo
# @TEST-EXEC: cp -r %DIR/pktsrc-plugin/* .
# @TEST-EXEC: (./configure --zeek-dist=${DIST} && VERBOSE=1 make) >&2
# @TEST-EXEC: nm -u build/lib/Demo-Foo* > undefined.out
# @TEST-EXEC: grep -E 'zeek_version_[0-9]+_[0-9]+_[0-9]+.*_plugin_[0-9]+' undefined.out