mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Adding plugin API number into versioned function name, and removing
old runtime API version check.
This commit is contained in:
parent
8ae30d8aac
commit
78f8ff432f
6 changed files with 10 additions and 35 deletions
|
@ -40,6 +40,11 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.csh
|
||||||
"setenv PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
"setenv PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
||||||
|
|
||||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)
|
||||||
|
execute_process(COMMAND grep "^#define *BRO_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(REPLACE "." " " version_numbers ${VERSION})
|
string(REPLACE "." " " version_numbers ${VERSION})
|
||||||
separate_arguments(version_numbers)
|
separate_arguments(version_numbers)
|
||||||
|
@ -47,9 +52,9 @@ list(GET version_numbers 0 VERSION_MAJOR)
|
||||||
list(GET version_numbers 1 VERSION_MINOR)
|
list(GET version_numbers 1 VERSION_MINOR)
|
||||||
set(VERSION_MAJ_MIN "${VERSION_MAJOR}.${VERSION_MINOR}")
|
set(VERSION_MAJ_MIN "${VERSION_MAJOR}.${VERSION_MINOR}")
|
||||||
|
|
||||||
set(VERSION_C_IDENT "${VERSION}")
|
set(VERSION_C_IDENT "${VERSION}_plugin_${API_VERSION}")
|
||||||
string(REGEX REPLACE "-[0-9]*$" "_git" VERSION_C_IDENT "${VERSION_C_IDENT}")
|
string(REGEX REPLACE "-[0-9]*$" "_git" VERSION_C_IDENT "${VERSION_C_IDENT}")
|
||||||
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" VERSION_C_IDENT "${VERSION_C_IDENT}")
|
string(REGEX REPLACE "[^a-zA-Z0-9_\$]" "_" VERSION_C_IDENT "${VERSION_C_IDENT}")
|
||||||
|
|
||||||
if(${ENABLE_DEBUG})
|
if(${ENABLE_DEBUG})
|
||||||
set(VERSION_C_IDENT "${VERSION_C_IDENT}_debug")
|
set(VERSION_C_IDENT "${VERSION_C_IDENT}_debug")
|
||||||
|
|
|
@ -243,10 +243,6 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
||||||
|
|
||||||
plugins_by_path.insert(std::make_pair(normalize_path(dir), current_plugin));
|
plugins_by_path.insert(std::make_pair(normalize_path(dir), current_plugin));
|
||||||
|
|
||||||
if ( current_plugin->APIVersion() != BRO_PLUGIN_API_VERSION )
|
|
||||||
reporter->FatalError("plugin's API version does not match Bro (expected %d, got %d in %s)",
|
|
||||||
BRO_PLUGIN_API_VERSION, current_plugin->APIVersion(), path);
|
|
||||||
|
|
||||||
// We execute the pre-script initialization here; this in
|
// We execute the pre-script initialization here; this in
|
||||||
// fact could be *during* script initialization if we got
|
// fact could be *during* script initialization if we got
|
||||||
// triggered via @load-plugin.
|
// triggered via @load-plugin.
|
||||||
|
|
|
@ -242,11 +242,6 @@ VersionNumber Plugin::Version() const
|
||||||
return config.version;
|
return config.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Plugin::APIVersion() const
|
|
||||||
{
|
|
||||||
return config.api_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Plugin::DynamicPlugin() const
|
bool Plugin::DynamicPlugin() const
|
||||||
{
|
{
|
||||||
return dynamic;
|
return dynamic;
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
#include "iosource/Component.h"
|
#include "iosource/Component.h"
|
||||||
#include "logging/WriterBackend.h"
|
#include "logging/WriterBackend.h"
|
||||||
|
|
||||||
// We allow to override this externally for testing purposes.
|
// Increase this when making incompatible changes to the plugin API. Note
|
||||||
#ifndef BRO_PLUGIN_API_VERSION
|
// that the constant is never used in C code. It's picked up on by CMake.
|
||||||
#define BRO_PLUGIN_API_VERSION 5
|
#define BRO_PLUGIN_API_VERSION 6
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION
|
#define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION
|
||||||
|
|
||||||
|
@ -103,14 +102,12 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Plugin;
|
friend class Plugin;
|
||||||
int api_version; // Current BRO_PLUGIN_API_VERSION. Automatically set.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Configuration::Configuration()
|
inline Configuration::Configuration()
|
||||||
{
|
{
|
||||||
name = "";
|
name = "";
|
||||||
description = "";
|
description = "";
|
||||||
api_version = BRO_PLUGIN_API_VERSION;
|
|
||||||
bro_version = 0;
|
bro_version = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,15 +448,6 @@ public:
|
||||||
**/
|
**/
|
||||||
const std::string& PluginPath() const;
|
const std::string& PluginPath() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the internal version of the Bro API that this plugin
|
|
||||||
* relies on. Only plugins that match Bro's current API version can
|
|
||||||
* be used. For statically compiled plugins this is automatically the
|
|
||||||
* case, but dynamically loaded plugins may cause a mismatch if they
|
|
||||||
* were compiled for a different Bro version.
|
|
||||||
*/
|
|
||||||
int APIVersion() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all components the plugin provides.
|
* Returns a list of all components the plugin provides.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
fatal error in /home/robin/bro/plugins/scripts/base/init-bare.bro, line 1: plugin's API version does not match Bro (expected 2, got 42 in /home/robin/bro/plugins/testing/btest/.tmp/plugins.api-version-mismatch/build//lib/XXX)
|
|
|
@ -1,8 +0,0 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
|
||||||
# @TEST-EXEC: bash %INPUT
|
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
|
||||||
# @TEST-EXEC-FAIL: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >tmp 2>&1
|
|
||||||
# @TEST-EXEC: cat tmp | sed 's/Demo-Foo[-a-zA-Z0-9_.]*/XXX/' >>output
|
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
|
|
||||||
|
|
||||||
( echo '#define BRO_PLUGIN_API_VERSION 42'; cat src/Plugin.cc; ) >src/Plugin.cc.tmp && mv src/Plugin.cc.tmp src/Plugin.cc
|
|
Loading…
Add table
Add a link
Reference in a new issue