bifcl: Remove submodule, adapt CMake configuration for Zeek build

This commit is contained in:
Tim Wojtulewicz 2025-08-17 20:43:16 -07:00
parent f6d9696bf1
commit c618bb7a56
7 changed files with 18 additions and 60 deletions

3
.gitmodules vendored
View file

@ -19,9 +19,6 @@
[submodule "auxil/netcontrol-connectors"]
path = auxil/netcontrol-connectors
url = https://github.com/zeek/zeek-netcontrol
[submodule "auxil/bifcl"]
path = auxil/bifcl
url = https://github.com/zeek/bifcl
[submodule "doc"]
path = doc
url = https://github.com/zeek/zeek-docs

View file

@ -904,11 +904,11 @@ set(_binpac_exe_path "included")
find_package(BinPAC REQUIRED)
add_executable(Zeek::BinPAC ALIAS binpac)
add_subdirectory(auxil/bifcl)
add_subdirectory(tools/bifcl)
add_executable(Zeek::BifCl ALIAS bifcl)
# FIXME: avoid hard-coding a path for multi-config generator support. See the
# TODO in ZeekPluginConfig.cmake.in.
set(BIFCL_EXE_PATH "${CMAKE_BINARY_DIR}/auxil/bifcl/bifcl${CMAKE_EXECUTABLE_SUFFIX}")
set(BIFCL_EXE_PATH "${CMAKE_BINARY_DIR}/tools/bifcl/bifcl${CMAKE_EXECUTABLE_SUFFIX}")
set(_bifcl_exe_path "included")
if (NOT GEN_ZAM_EXE_PATH)

@ -1 +0,0 @@
Subproject commit 5947749f7850b075f11d6a2aaefe7dad4f63cb62

View file

@ -1,70 +1,26 @@
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
project(BifCl C CXX)
include(cmake/CommonCMakeConfig.cmake)
include(cmake/RequireCXXStd.cmake)
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
if (MSVC)
add_compile_options(/J) # Similar to -funsigned-char on other platforms
set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "/wd4018")
else ()
set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
endif ()
include_directories(BEFORE ${BifCl_SOURCE_DIR}/include ${BifCl_BINARY_DIR})
set(BISON_FLAGS "--debug")
# BIF parser/scanner
bison_target(BIFParser builtin-func.y ${BifCl_BINARY_DIR}/bif_parse.cc
DEFINES_FILE ${BifCl_BINARY_DIR}/bif_parse.h COMPILE_FLAGS "${BISON_FLAGS}")
flex_target(BIFScanner builtin-func.l ${BifCl_BINARY_DIR}/bif_lex.cc)
bison_target(BIFParser builtin-func.y ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.cc
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.h COMPILE_FLAGS "${BISON_FLAGS}")
flex_target(BIFScanner builtin-func.l ${CMAKE_CURRENT_BINARY_DIR}/bif_lex.cc)
add_flex_bison_dependency(BIFScanner BIFParser)
set(bifcl_SRCS
${BISON_BIFParser_INPUT}
${FLEX_BIFScanner_INPUT}
${BISON_BIFParser_OUTPUTS}
${FLEX_BIFScanner_OUTPUTS}
bif_arg.cc
include/bif_arg.h
module_util.cc
include/module_util.h)
set(bifcl_SRCS ${BISON_BIFParser_INPUT} ${FLEX_BIFScanner_INPUT} ${BISON_BIFParser_OUTPUTS}
${FLEX_BIFScanner_OUTPUTS} bif_arg.cc module_util.cc)
add_executable(bifcl ${bifcl_SRCS})
target_include_directories(bifcl BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (MSVC)
# If building separately from zeek, we need to add the libunistd subdirectory
# so that linking doesn't fail.
if ("${CMAKE_PROJECT_NAME}" STREQUAL "BifCl")
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
endif ()
target_compile_options(bifcl PUBLIC "/J") # Similar to -funsigned-char on other platforms
target_compile_options(bifcl PUBLIC "/wd4018") # Similar to -Wno-sign-compare on other platforms
target_link_libraries(bifcl PRIVATE libunistd)
else ()
target_compile_options(bifcl PUBLIC "-Wno-sign-compare")
endif ()
install(TARGETS bifcl DESTINATION bin)
if (CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
endif ()
message(
"\n====================| Bifcl Build Summary |====================="
"\n"
"\nBuild type: ${CMAKE_BUILD_TYPE}"
"\nBuild dir: ${PROJECT_BINARY_DIR}"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\nDebug mode: ${ENABLE_DEBUG}"
"\n"
"\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
"\nCPP: ${CMAKE_CXX_COMPILER}"
"\n"
"\n================================================================\n")
include(UserChangedWarning)

View file

@ -1,3 +1,5 @@
// See the file "COPYING" in the main distribution directory for copyright.
#include "bif_arg.h"
#include <cstring>

View file

@ -1,3 +1,5 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include <cstdint>

View file

@ -1,3 +1,5 @@
// See the file "COPYING" in the main distribution directory for copyright.
//
// These functions are used by both Zeek and bifcl.
//