zeek-config: Move ZEEK_VERSION* out of zeek-config.h

When bumping the VERSION file, everything that includes the auto-generated
zeek/zeek-config.h needs to rebuild and ccache usage is voided due the file
changing. Split the mutable version information into a new zeek-version.h
file to avoid this.

Further, do not include zeek-version.h within Plugin.h and avoid the reference
to ZEEK_VERSION_FUNCTION unless we're building an external plugin.

Closes #2776.
This commit is contained in:
Arne Welzel 2023-02-21 15:39:52 +01:00
parent ebc9563243
commit d23b1331e5
6 changed files with 63 additions and 22 deletions

View file

@ -759,6 +759,9 @@ if ( NOT BINARY_PACKAGING_MODE )
endif ()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-version.h.in
${CMAKE_CURRENT_BINARY_DIR}/zeek-version.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zeek-version.h DESTINATION include/zeek)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zeek-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/zeek-config.h)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})

19
NEWS
View file

@ -6,6 +6,25 @@ release. For an exhaustive list of changes, see the ``CHANGES`` file
Zeek 6.0.0
==========
Breaking Changes
----------------
- The zeek/zeek-config.h header does not provide the macros ZEEK_VERSION and
ZEEK_VERSION_NUMBER anymore when compiling builtin plugins. This may affect
external plugins included via the configure flag ``--include-plugins``
referencing these macros. A suggested update for these plugins is adding
the following snippet:
#if __has_include("zeek/zeek-version.h")
#include "zeek/zeek-version.h"
#endif
External plugins that are built out-of-tree, e.g. via ``zkg`` are not
affected by this change.
The main motivation is improved ccache effectiveness for speedier CI and
development builds whenever a VERSION bump happens.
New Functionality
-----------------

View file

@ -2,8 +2,6 @@
#pragma once
#include "zeek/zeek-config.h"
#include <functional>
#include <list>
#include <optional>
@ -13,9 +11,15 @@
#include "zeek/ZeekArgs.h"
#include "zeek/logging/WriterBackend.h"
// Avoid ccache busting of Plugin.h for internal plugins by
// only including zeek/zeek-version.h if we're building an
// external plugin.
#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD
#include "zeek/zeek-version.h"
// Remove the BRO define in v6.1.
#define BRO_PLUGIN_BRO_VERSION ZEEK_VERSION_FUNCTION
#define ZEEK_PLUGIN_ZEEK_VERSION ZEEK_VERSION_FUNCTION
#endif
namespace zeek::threading
{
@ -126,8 +130,13 @@ public:
#endif
inline Configuration() __attribute__((always_inline))
{
// Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external
// plugins. The internal ones are in the same binary so the runtime
// link check shouldn't be needed and we can avoid ccache busting.
#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD
bro_version = ZEEK_PLUGIN_ZEEK_VERSION;
zeek_version = ZEEK_PLUGIN_ZEEK_VERSION;
#endif
}
#ifdef __GNUC__
#pragma GCC diagnostic pop

View file

@ -1,5 +1,5 @@
#include "zeek/zeek-config.h"
#include "zeek/zeek-version.h"
char version[] = "@VERSION@";

View file

@ -141,14 +141,6 @@
/* Use the sqlite reader/writer. */
#cmakedefine USE_SQLITE
/* Version number of package */
#define VERSION "@VERSION@"
// Zeek version number.
// This is the result of (major * 10000 + minor * 100 + patch)
// For example, 3.1.2 becomes 30102.
#define ZEEK_VERSION_NUMBER @ZEEK_VERSION_NUMBER@
/* whether words are stored with the most significant byte first */
#cmakedefine WORDS_BIGENDIAN
@ -251,19 +243,18 @@
/* String with extension of dynamic libraries (e.g., ".so") */
#define DYNAMIC_PLUGIN_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@"
/* True if we're building outside of the main Zeek source code tree. */
/* Set if we're building outside of the main Zeek source code tree. */
#ifndef ZEEK_PLUGIN_INTERNAL_BUILD
#define ZEEK_PLUGIN_INTERNAL_BUILD @ZEEK_PLUGIN_INTERNAL_BUILD@
#define ZEEK_PLUGIN_INTERNAL_BUILD true
#else
// Backwards compat for external plugins, include the version
// identifiers through zeek/zeek-version.h.
#if ! ZEEK_PLUGIN_INTERNAL_BUILD
#include "zeek/zeek-version.h"
#endif
/* A C function that has the Zeek version encoded into its name. */
#define ZEEK_VERSION_FUNCTION zeek_version_@VERSION_C_IDENT@
#ifdef __cplusplus
extern "C" {
#endif
extern const char* ZEEK_VERSION_FUNCTION();
#ifdef __cplusplus
}
//
// Not sure we can ever deprecate this without changing
// the names.
#endif
// GCC uses __SANITIZE_ADDRESS__, Clang uses __has_feature

19
zeek-version.h.in Normal file
View file

@ -0,0 +1,19 @@
#pragma once
/* Version number of package */
#define VERSION "@VERSION@"
// Zeek version number.
// This is the result of (major * 10000 + minor * 100 + patch)
// For example, 3.1.2 becomes 30102.
#define ZEEK_VERSION_NUMBER @ZEEK_VERSION_NUMBER@
/* A C function that has the Zeek version encoded into its name. */
#define ZEEK_VERSION_FUNCTION zeek_version_@VERSION_C_IDENT@
#ifdef __cplusplus
extern "C" {
#endif
extern const char* ZEEK_VERSION_FUNCTION();
#ifdef __cplusplus
}
#endif