Move Spicy submodule a layer up.

This moves `auxil/spicy/spicy` to `auxil/spicy`. It relocates the
pieces previously inside that intermediary directory. The main change
is that now tweak the compilation flags for Spicy through target
options.

This is on top of `topic/robin/spicy-plugin`.
This commit is contained in:
Robin Sommer 2023-05-12 15:18:50 +02:00
parent 85f8da6766
commit 10477b38aa
No known key found for this signature in database
GPG key ID: D8187293B3FFE5D0
9 changed files with 38 additions and 78 deletions

2
.gitmodules vendored
View file

@ -59,7 +59,7 @@
path = auxil/out_ptr
url = https://github.com/soasis/out_ptr.git
[submodule "auxil/spicy"]
path = auxil/spicy/spicy
path = auxil/spicy
url = https://github.com/zeek/spicy
[submodule "auxil/filesystem"]
path = auxil/filesystem

View file

@ -497,7 +497,7 @@ file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev.sh
"export ZEEKPATH=`${cmake_binary_dir}/zeek-path-dev`\n"
"export ZEEK_PLUGIN_PATH=\"${cmake_binary_dir}/src\":$\{ZEEK_PLUGIN_PATH\}\n"
"export PATH=\"${cmake_binary_dir}\":\"${cmake_binary_dir}/src\":\"${cmake_binary_dir}/auxil/spicy/spicy/bin\":\"${cmake_binary_dir}/src/spicy/spicyz\":$\{PATH\}\n"
"export PATH=\"${cmake_binary_dir}\":\"${cmake_binary_dir}/src\":\"${cmake_binary_dir}/auxil/spicy/bin\":\"${cmake_binary_dir}/src/spicy/spicyz\":$\{PATH\}\n"
"export SPICY_PATH=`${cmake_binary_dir}/spicy-path`\n"
"export HILTI_CXX_INCLUDE_DIRS=`${cmake_binary_dir}/hilti-cxx-include-dirs`\n"
"export ZEEK_SPICY_LIBRARY_PATH=${cmake_source_dir}/scripts/spicy\n")
@ -506,7 +506,7 @@ file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev.csh
"setenv ZEEKPATH `${cmake_binary_dir}/zeek-path-dev`\n"
"setenv ZEEK_PLUGIN_PATH \"${cmake_binary_dir}/src\":$\{ZEEK_PLUGIN_PATH\}\n"
"setenv PATH \"${cmake_binary_dir}\":\"${cmake_binary_dir}/src\":\"${cmake_binary_dir}/auxil/spicy/spicy/bin\":\"${cmake_binary_dir}/src/spicy/spicyz\":$\{PATH\}\n"
"setenv PATH \"${cmake_binary_dir}\":\"${cmake_binary_dir}/src\":\"${cmake_binary_dir}/auxil/spicy/bin\":\"${cmake_binary_dir}/src/spicy/spicyz\":$\{PATH\}\n"
"setenv SPICY_PATH \"`${cmake_binary_dir}/spicy-path`\"\n"
"setenv HILTI_CXX_INCLUDE_DIRS \"`${cmake_binary_dir}/hilti-cxx-include-dirs`\"\n"
"setenv ZEEK_SPICY_LIBRARY_PATH \"${cmake_source_dir}/scripts/spicy\"\n")
@ -724,6 +724,11 @@ if (NOT MSVC)
endif ()
FindRequiredPackage(ZLIB)
if (NOT BINARY_PACKAGING_MODE)
# TODO: Broker seems to always turn on static libraries. We don't want that for Spicy by default.
set(BUILD_SHARED_LIBS yes)
endif ()
# Forward user-defined hint for OpenSSL to the plugins. Use a cache variable to
# make sure this variable survives CMake re-runs. Note: This variable is picked
# up in ZeekPluginConfig.cmake.in.
@ -899,13 +904,26 @@ if (NOT DISABLE_SPICY)
spicy_print_summary()
else ()
set(HAVE_SPICY yes)
add_subdirectory(auxil/spicy)
zeek_add_dependencies(spicy)
# Spicy needs the full prefix for Flex and Bison while Zeek captures
# only the paths to the executables. Derive the prefixes from the
# binary paths under the assumption that their bindir is under their
# prefix (which also implies that one such prefix even exists).
get_filename_component(dir ${FLEX_EXECUTABLE} DIRECTORY ABSOLUTE)
set(FLEX_ROOT ${dir}/..)
get_directory_property(
SPICY_VERSION_NUMBER DIRECTORY ${PROJECT_SOURCE_DIR}/auxil/spicy/spicy DEFINITION
SPICY_VERSION_NUMBER)
get_filename_component(dir ${BISON_EXECUTABLE} DIRECTORY ABSOLUTE)
set(BISON_ROOT ${dir}/..)
# The script generating precompiled headers for Spicy expects a
# different build system layout than provided for a bundled Spicy,
# disable it.
set(HILTI_DEV_PRECOMPILE_HEADERS OFF)
add_subdirectory(auxil/spicy)
include(ConfigureSpicyBuild) # set some options different for building Spicy
zeek_add_dependencies(spicy)
set(HAVE_SPICY yes)
endif ()
set(USE_SPICY_ANALYZERS yes)
@ -1247,8 +1265,8 @@ checkoptionalbuildsources(auxil/zeek-client ZeekClient INSTALL_ZEEK_CLIENT)
# Generate Spicy helper scripts referenced in e.g., `zeek-path-dev.*`. These
# set Spicy-side environment variables to run it out of the build directory.
configure_file(${CMAKE_SOURCE_DIR}/auxil/spicy/spicy-path.in ${CMAKE_BINARY_DIR}/spicy-path @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/auxil/spicy/hilti-cxx-include-dirs.in
configure_file(${CMAKE_SOURCE_DIR}/spicy-path.in ${CMAKE_BINARY_DIR}/spicy-path @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/hilti-cxx-include-dirs.in
${CMAKE_BINARY_DIR}/hilti-cxx-include-dirs @ONLY)
# ##############################################################################

View file

@ -1,58 +0,0 @@
# Spicy needs the full prefix for Flex and Bison while Zeek captures only the
# paths to the executables. Derive the prefixes from the binary paths under the
# assumption that their bindir is under their prefix (which also implies that
# one such prefix even exists).
if ( NOT FLEX_EXECUTABLE )
find_package(FLEX REQUIRED)
endif ()
get_filename_component(dir ${FLEX_EXECUTABLE} DIRECTORY ABSOLUTE)
set(FLEX_ROOT ${dir}/..)
if ( NOT BISON_EXECUTABLE )
find_package(BISON REQUIRED)
endif ()
get_filename_component(dir ${BISON_EXECUTABLE} DIRECTORY ABSOLUTE)
set(BISON_ROOT ${dir}/..)
if ( NOT BINARY_PACKAGING_MODE )
# TODO: Broker seems to always turn on static libraries. We don't want that for Spicy by default.
set(BUILD_SHARED_LIBS yes)
endif ()
# Spicy uses slightly less strict warnings than Zeek proper. Mute a few warnings for Spicy.
# NOTE: Compiler flags are inherited down the directory tree, so in order to
# set these flags we do need a customizable subdirectory above the Spicy
# sources.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-braces")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla")
# GCC 13 adds a new flag to check whether a symbol changes meaning. Due to an issue in one
# of the dependencies used by Spicy, this causes Zeek to fail to build on that compiler.
# Until this is fixed, ignore that warning, but check to to make sure the flag exists first.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-changes-meaning" _has_no_changes_meaning_flag)
if ( _has_no_changes_meaning_flag )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-changes-meaning")
endif ()
# The script generating precompiled headers for Spicy expects a different build
# system layout than provided for a bundled Spicy, disable it.
set(HILTI_DEV_PRECOMPILE_HEADERS OFF)
add_subdirectory(spicy)
# Disable Spicy unit test targets.
#
# Spicy builds its unit tests as part of `ALL`. They are usually not only
# uninteresting for us but might cause problems. Since any configuration
# we do for our unit tests happens through global C++ compiler flags, they
# would get inherited directly by Spicy which can cause issues, e.g., we set
# `-DDOCTEST_CONFIG_DISABLE` if `ENABLE_ZEEK_UNIT_TESTS` is false, but Spicy
# unit test do not anticipate this define being set.
set_target_properties(
hilti-rt-tests
hilti-rt-configuration-tests
spicy-rt-tests
hilti-toolchain-tests
spicy-toolchain-tests
PROPERTIES EXCLUDE_FROM_ALL TRUE)

2
cmake

@ -1 +1 @@
Subproject commit 643ca94ad9a425615414df942a4e8c8c553059b8
Subproject commit 5cd120b82f68cb62efb6ca2d2be43bdd0fd89375

View file

@ -5,9 +5,9 @@
# variable `HILTI_CXX_INCLUDE_DIRS`.
# Paths to support compiling Spicy parsers in the build tree.
PATHS=@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/hilti/runtime/include
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/spicy/runtime/include
PATHS=$PATHS:@CMAKE_BINARY_DIR@/auxil/spicy/spicy/include
PATHS=@CMAKE_SOURCE_DIR@/auxil/spicy/hilti/runtime/include
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/runtime/include
PATHS=$PATHS:@CMAKE_BINARY_DIR@/auxil/spicy/include
# Paths to support compiling against a build tree Zeek.
PATHS=$PATHS:@CMAKE_BINARY_DIR@

View file

@ -4,7 +4,7 @@
# Spicy tooling in the build tree.
PATHS=.
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/spicy/lib
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/hilti/lib
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/spicy/lib
PATHS=$PATHS:@CMAKE_SOURCE_DIR@/auxil/spicy/hilti/lib
echo $PATHS

View file

@ -18,7 +18,7 @@ ZEEK_PLUGIN_PATH=
TZ=UTC
LC_ALL=C
BTEST_PATH=%(testbase)s/../../auxil/btest
PATH=%(testbase)s/../../%(build_dir)s/src%(pathsep)s%(testbase)s/../scripts%(pathsep)s%(testbase)s/../../auxil/btest%(pathsep)s%(testbase)s/../../%(build_dir)s/auxil/zeek-aux/zeek-cut%(pathsep)s%(testbase)s/../../%(build_dir)s/auxil/spicy/spicy/bin%(pathsep)s%(testbase)s/../../%(build_dir)s/src/spicy/spicyz%(pathsep)s%(testbase)s/../../auxil/btest/sphinx%(pathsep)s%(default_path)s%(pathsep)s/sbin
PATH=%(testbase)s/../../%(build_dir)s/src%(pathsep)s%(testbase)s/../scripts%(pathsep)s%(testbase)s/../../auxil/btest%(pathsep)s%(testbase)s/../../%(build_dir)s/auxil/zeek-aux/zeek-cut%(pathsep)s%(testbase)s/../../%(build_dir)s/auxil/spicy/bin%(pathsep)s%(testbase)s/../../%(build_dir)s/src/spicy/spicyz%(pathsep)s%(testbase)s/../../auxil/btest/sphinx%(pathsep)s%(default_path)s%(pathsep)s/sbin
TRACES=%(testbase)s/Traces
FILES=%(testbase)s/Files
SCRIPTS=%(testbase)s/../scripts

View file

@ -1,6 +1,6 @@
# @TEST-REQUIRES: have-spicy && test -x ${BUILD}/auxil/spicy/spicy/bin/spicy-dump
# @TEST-REQUIRES: have-spicy && test -x ${BUILD}/auxil/spicy/bin/spicy-dump
#
# @TEST-EXEC: printf 12345 | ${BUILD}/auxil/spicy/spicy/bin/spicy-dump -d %INPUT >output
# @TEST-EXEC: printf 12345 | ${BUILD}/auxil/spicy/bin/spicy-dump -d %INPUT >output
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Smoke test for a bundled Spicy.