From a29087967c549eb8dc3bea58a60b007ca463a0ab Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 6 Jul 2020 20:02:58 -0700 Subject: [PATCH] Update plugin configure/test setup --- plugin/configure | 110 ++++++++++++++++++++++--------------------- plugin/src/rot13.bif | 4 ++ testing/tests/main | 2 +- testing/tests/rot13 | 2 +- 4 files changed, 62 insertions(+), 56 deletions(-) diff --git a/plugin/configure b/plugin/configure index 48b4fb7..6e26a00 100755 --- a/plugin/configure +++ b/plugin/configure @@ -14,22 +14,14 @@ if [ -e `dirname $0`/configure.plugin ]; then . `dirname $0`/configure.plugin fi -# Check for `cmake` command. -type cmake > /dev/null 2>&1 || { - echo "\ -This package requires CMake, please install it first, then you may -use this configure script to access CMake equivalent functionality.\ -" >&2; - exit 1; -} - usage() { cat 1>&2 </dev/null 2>&1; then - if bro-config --cmake_dir >/dev/null 2>&1; then - # Have a newer version of bro-config that has needed flags - append_cache_entry BRO_CONFIG_PREFIX PATH `bro-config --prefix` - append_cache_entry BRO_CONFIG_INCLUDE_DIR PATH `bro-config --include_dir` - append_cache_entry BRO_CONFIG_PLUGIN_DIR PATH `bro-config --plugin_dir` - append_cache_entry BRO_CONFIG_CMAKE_DIR PATH `bro-config --cmake_dir` - append_cache_entry CMAKE_MODULE_PATH PATH `bro-config --cmake_dir` +if [ -z "$CMakeCommand" ]; then + # prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL) + if command -v cmake3 >/dev/null 2>&1 ; then + CMakeCommand="cmake3" + elif command -v cmake >/dev/null 2>&1 ; then + CMakeCommand="cmake" + else + echo "This package requires CMake, please install it first." + echo "Then you may use this script to configure the CMake build." + echo "Note: pass --cmake=PATH to use cmake in non-standard locations." + exit 1; + fi +fi - build_type=`bro-config --build_type` +if [ -z "$zeekdist" ]; then + if type zeek-config >/dev/null 2>&1; then + zeek_config="zeek-config" + else + echo "Either 'zeek-config' must be in PATH or '--zeek-dist=' used" + exit 1 + fi - if [ "$build_type" = "debug" ]; then - append_cache_entry BRO_PLUGIN_ENABLE_DEBUG BOOL true - fi + append_cache_entry BRO_CONFIG_PREFIX PATH `${zeek_config} --prefix` + append_cache_entry BRO_CONFIG_INCLUDE_DIR PATH `${zeek_config} --include_dir` + append_cache_entry BRO_CONFIG_PLUGIN_DIR PATH `${zeek_config} --plugin_dir` + append_cache_entry BRO_CONFIG_CMAKE_DIR PATH `${zeek_config} --cmake_dir` + append_cache_entry CMAKE_MODULE_PATH PATH `${zeek_config} --cmake_dir` - if [ -z "$binpac_root" ]; then - append_cache_entry BinPAC_ROOT_DIR PATH `bro-config --binpac_root` - fi + build_type=`${zeek_config} --build_type` - if [ -z "$broker_root" ]; then - append_cache_entry BROKER_ROOT_DIR PATH `bro-config --broker_root` - fi + if [ "$build_type" = "debug" ]; then + append_cache_entry BRO_PLUGIN_ENABLE_DEBUG BOOL true + fi - if [ -z "$caf_root" ]; then - append_cache_entry CAF_ROOT_DIR PATH `bro-config --caf_root` - fi - else - brodist=`bro-config --bro_dist 2> /dev/null` + if [ -z "$binpac_root" ]; then + append_cache_entry BinPAC_ROOT_DIR PATH `${zeek_config} --binpac_root` + fi - if [ ! -e "$brodist/bro-path-dev.in" ]; then - echo "$brodist does not appear to be a valid Bro source tree." - exit 1 - fi + if [ -z "$broker_root" ]; then + append_cache_entry BROKER_ROOT_DIR PATH `${zeek_config} --broker_root` + fi - append_cache_entry BRO_DIST PATH $brodist - append_cache_entry CMAKE_MODULE_PATH PATH $brodist/cmake - fi - else - echo "Either 'bro-config' must be in PATH or '--bro-dist=' used" - exit 1 + if [ -z "$caf_root" ]; then + append_cache_entry CAF_ROOT_DIR PATH `${zeek_config} --caf_root` fi else - if [ ! -e "$brodist/bro-path-dev.in" ]; then - echo "$brodist does not appear to be a valid Bro source tree." - exit 1 + if [ ! -e "$zeekdist/zeek-path-dev.in" ]; then + echo "$zeekdist does not appear to be a valid Zeek source tree." + exit 1 fi - append_cache_entry BRO_DIST PATH $brodist - append_cache_entry CMAKE_MODULE_PATH PATH $brodist/cmake + # BRO_DIST is the canonical/historical name used by plugin CMake scripts + # ZEEK_DIST doesn't serve a function at the moment, but set/provided anyway + append_cache_entry BRO_DIST PATH $zeekdist + append_cache_entry ZEEK_DIST PATH $zeekdist + append_cache_entry CMAKE_MODULE_PATH PATH $zeekdist/cmake fi if [ "$installroot" != "default" ]; then @@ -174,12 +176,12 @@ if [ "$installroot" != "default" ]; then fi echo "Build Directory : $builddir" -echo "Bro Source Directory : $brodist" +echo "Zeek Source Directory : $zeekdist" mkdir -p $builddir cd $builddir -cmake $CMakeCacheEntries .. +"$CMakeCommand" $CMakeCacheEntries .. echo "# This is the command used to configure this build" > config.status echo $command >> config.status diff --git a/plugin/src/rot13.bif b/plugin/src/rot13.bif index 9e5356e..59ca7cd 100644 --- a/plugin/src/rot13.bif +++ b/plugin/src/rot13.bif @@ -1,3 +1,7 @@ +%%{ +#include "BroString.h" +%%} + module Demo; function rot13%(s: string%) : string diff --git a/testing/tests/main b/testing/tests/main index d00c921..b4af07d 100644 --- a/testing/tests/main +++ b/testing/tests/main @@ -1,3 +1,3 @@ -# @TEST-EXEC: bro bro-test-package > output +# @TEST-EXEC: zeek zeek-test-package > output # @TEST-EXEC: btest-diff output diff --git a/testing/tests/rot13 b/testing/tests/rot13 index f24f5b4..ba1237b 100644 --- a/testing/tests/rot13 +++ b/testing/tests/rot13 @@ -1,4 +1,4 @@ -# @TEST-EXEC: bro %INPUT > output +# @TEST-EXEC: zeek %INPUT > output # @TEST-EXEC: btest-diff output print Demo::rot13("Hello");