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

@ -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