diff --git a/CMakeLists.txt b/CMakeLists.txt index ad2a2b8aea..936fac8a50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,11 +106,13 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev.csh "setenv HILTI_CXX_INCLUDE_DIRS \"`${CMAKE_CURRENT_BINARY_DIR}/hilti-cxx-include-dirs`\"\n") file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1) -execute_process(COMMAND grep "^#define *BRO_PLUGIN_API_VERSION" +execute_process(COMMAND grep "^constexpr int PLUGIN_API_VERSION" INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/Plugin.h OUTPUT_VARIABLE API_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -string(REGEX REPLACE "^#define.*VERSION *" "" API_VERSION "${API_VERSION}") + +string(REGEX MATCH "^constexpr int PLUGIN_API_VERSION = ([0-9]+);" API_VERSION "${API_VERSION}") +set(API_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "[.-]" " " version_numbers ${VERSION}) separate_arguments(version_numbers) diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index c4f4f901a8..63525d4984 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -12,10 +12,6 @@ #include "zeek/ZeekArgs.h" #include "zeek/logging/WriterBackend.h" -// Increase this when making incompatible changes to the plugin API. Note -// that the constant is never used in C code. It's picked up on by CMake. -#define BRO_PLUGIN_API_VERSION 7 - #define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION namespace zeek::threading @@ -26,6 +22,10 @@ struct Field; namespace zeek { +// Increase this when making incompatible changes to the plugin API. Note +// that the constant is never used in C code. It's picked up on by CMake. +constexpr int PLUGIN_API_VERSION = 7; + class ODesc; class Event; class Func; @@ -1158,3 +1158,8 @@ private: } // namespace plugin } // namespace zeek + +// Increase this when making incompatible changes to the plugin API. Note +// that the constant is never used in C code. It's picked up on by CMake. +constexpr int BRO_PLUGIN_API_VERSION + [[deprecated("Remove in v6.1. Use zeek::PLUGIN_API_VERSION")]] = zeek::PLUGIN_API_VERSION;