diff --git a/.gitmodules b/.gitmodules index 2df489a3b6..fefd52ec42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index e03c0d6d4b..17037915bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) # ############################################################################## diff --git a/auxil/spicy/spicy b/auxil/spicy similarity index 100% rename from auxil/spicy/spicy rename to auxil/spicy diff --git a/auxil/spicy/CMakeLists.txt b/auxil/spicy/CMakeLists.txt deleted file mode 100644 index d5bdd87022..0000000000 --- a/auxil/spicy/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/cmake b/cmake index 643ca94ad9..5cd120b82f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 643ca94ad9a425615414df942a4e8c8c553059b8 +Subproject commit 5cd120b82f68cb62efb6ca2d2be43bdd0fd89375 diff --git a/auxil/spicy/hilti-cxx-include-dirs.in b/hilti-cxx-include-dirs.in similarity index 74% rename from auxil/spicy/hilti-cxx-include-dirs.in rename to hilti-cxx-include-dirs.in index 6c4a140be9..0bc6a8c33b 100755 --- a/auxil/spicy/hilti-cxx-include-dirs.in +++ b/hilti-cxx-include-dirs.in @@ -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@ diff --git a/auxil/spicy/spicy-path.in b/spicy-path.in similarity index 54% rename from auxil/spicy/spicy-path.in rename to spicy-path.in index 3fab168230..464b56510f 100755 --- a/auxil/spicy/spicy-path.in +++ b/spicy-path.in @@ -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 diff --git a/testing/btest/btest.cfg b/testing/btest/btest.cfg index 1247fb44ce..8ece31ab15 100644 --- a/testing/btest/btest.cfg +++ b/testing/btest/btest.cfg @@ -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 diff --git a/testing/btest/spicy/spicy-dump.spicy b/testing/btest/spicy/spicy-dump.spicy index 149bf87aa6..e7016195a7 100644 --- a/testing/btest/spicy/spicy-dump.spicy +++ b/testing/btest/spicy/spicy-dump.spicy @@ -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.