mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Add missing .cmake-format.json, reformat with pre-commit
This commit is contained in:
parent
dacfe747b9
commit
670c4dcbcf
4 changed files with 86 additions and 106 deletions
|
@ -14,10 +14,10 @@ set(BINPAC_SOVERSION 0)
|
|||
|
||||
set(ENABLE_SHARED true)
|
||||
|
||||
if(ENABLE_STATIC_ONLY)
|
||||
set(ENABLE_STATIC true)
|
||||
set(ENABLE_SHARED false)
|
||||
endif()
|
||||
if (ENABLE_STATIC_ONLY)
|
||||
set(ENABLE_STATIC true)
|
||||
set(ENABLE_SHARED false)
|
||||
endif ()
|
||||
|
||||
# Set default install paths
|
||||
include(GNUInstallDirs)
|
||||
|
@ -28,9 +28,9 @@ include(GNUInstallDirs)
|
|||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/J) # Similar to -funsigned-char on other platforms
|
||||
endif()
|
||||
if (MSVC)
|
||||
add_compile_options(/J) # Similar to -funsigned-char on other platforms
|
||||
endif ()
|
||||
|
||||
# ##############################################################################
|
||||
# System Introspection
|
||||
|
@ -48,38 +48,38 @@ add_subdirectory(src)
|
|||
# ##############################################################################
|
||||
# Build Summary
|
||||
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
||||
endif()
|
||||
if (CMAKE_BUILD_TYPE)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
||||
endif ()
|
||||
|
||||
macro(display test desc summary)
|
||||
if(${test})
|
||||
set(${summary} ${desc})
|
||||
else()
|
||||
set(${summary} no)
|
||||
endif()
|
||||
endmacro()
|
||||
macro (display test desc summary)
|
||||
if (${test})
|
||||
set(${summary} ${desc})
|
||||
else ()
|
||||
set(${summary} no)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
display(ENABLE_SHARED yes shared_summary)
|
||||
display(ENABLE_STATIC yes static_summary)
|
||||
|
||||
message(
|
||||
"\n==================| BinPAC Build Summary |===================="
|
||||
"\nVersion: ${BINPAC_VERSION}"
|
||||
"\nSO version: ${BINPAC_SOVERSION}"
|
||||
"\n"
|
||||
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
|
||||
"\nDebug mode: ${ENABLE_DEBUG}"
|
||||
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
||||
"\nShared libs: ${shared_summary}"
|
||||
"\nStatic libs: ${static_summary}"
|
||||
"\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")
|
||||
"\n==================| BinPAC Build Summary |===================="
|
||||
"\nVersion: ${BINPAC_VERSION}"
|
||||
"\nSO version: ${BINPAC_SOVERSION}"
|
||||
"\n"
|
||||
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
|
||||
"\nDebug mode: ${ENABLE_DEBUG}"
|
||||
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
||||
"\nShared libs: ${shared_summary}"
|
||||
"\nStatic libs: ${static_summary}"
|
||||
"\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)
|
||||
|
|
|
@ -4,58 +4,48 @@ test_big_endian(HOST_BIGENDIAN)
|
|||
include(CheckTypeSize)
|
||||
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/binpac.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/binpac.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/binpac.h.in ${CMAKE_CURRENT_BINARY_DIR}/binpac.h)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(binpac_headers
|
||||
${CMAKE_CURRENT_BINARY_DIR}/binpac.h binpac_analyzer.h binpac_buffer.h
|
||||
binpac_bytestring.h binpac_exception.h binpac_regex.h)
|
||||
set(binpac_headers ${CMAKE_CURRENT_BINARY_DIR}/binpac.h binpac_analyzer.h binpac_buffer.h
|
||||
binpac_bytestring.h binpac_exception.h binpac_regex.h)
|
||||
|
||||
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc
|
||||
${binpac_headers})
|
||||
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc ${binpac_headers})
|
||||
|
||||
if(ENABLE_SHARED)
|
||||
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
||||
target_compile_features(binpac_lib PRIVATE cxx_std_17)
|
||||
set_target_properties(
|
||||
binpac_lib
|
||||
PROPERTIES CXX_EXTENSIONS OFF
|
||||
SOVERSION ${BINPAC_SOVERSION}
|
||||
VERSION ${BINPAC_VERSION_MAJOR}.${BINPAC_VERSION_MINOR}
|
||||
MACOSX_RPATH true
|
||||
OUTPUT_NAME binpac)
|
||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
if (ENABLE_SHARED)
|
||||
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
||||
target_compile_features(binpac_lib PRIVATE cxx_std_17)
|
||||
set_target_properties(
|
||||
binpac_lib
|
||||
PROPERTIES CXX_EXTENSIONS OFF
|
||||
SOVERSION ${BINPAC_SOVERSION}
|
||||
VERSION ${BINPAC_VERSION_MAJOR}.${BINPAC_VERSION_MINOR}
|
||||
MACOSX_RPATH true
|
||||
OUTPUT_NAME binpac)
|
||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif ()
|
||||
|
||||
if(ENABLE_STATIC)
|
||||
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
||||
target_compile_features(binpac_static PRIVATE cxx_std_17)
|
||||
set_target_properties(binpac_static PROPERTIES CXX_EXTENSIONS OFF OUTPUT_NAME
|
||||
binpac)
|
||||
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
if (ENABLE_STATIC)
|
||||
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
||||
target_compile_features(binpac_static PRIVATE cxx_std_17)
|
||||
set_target_properties(binpac_static PROPERTIES CXX_EXTENSIONS OFF OUTPUT_NAME binpac)
|
||||
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif ()
|
||||
|
||||
if(ZEEK_ROOT_DIR)
|
||||
# Installed in binpac subdir just for organization purposes.
|
||||
install(FILES ${binpac_headers}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binpac)
|
||||
else()
|
||||
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
endif()
|
||||
if (ZEEK_ROOT_DIR)
|
||||
# Installed in binpac subdir just for organization purposes.
|
||||
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binpac)
|
||||
else ()
|
||||
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
endif ()
|
||||
|
||||
# This is set to assist superprojects that want to build BinPac from source and
|
||||
# rely on it as a target
|
||||
if(ENABLE_SHARED)
|
||||
set(BinPAC_LIBRARY
|
||||
binpac_lib
|
||||
CACHE STRING "BinPAC library" FORCE)
|
||||
else()
|
||||
set(BinPAC_LIBRARY
|
||||
binpac_static
|
||||
CACHE STRING "BinPAC library" FORCE)
|
||||
endif()
|
||||
if (ENABLE_SHARED)
|
||||
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
|
||||
else ()
|
||||
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
|
||||
endif ()
|
||||
|
||||
set(BinPAC_INCLUDE_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
set(BinPAC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
CACHE STRING "BinPAC header directories" FORCE)
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
bison_target(
|
||||
PACParser pac_parse.yy ${BinPAC_BINARY_DIR}/src/pac_parse.cc
|
||||
DEFINES_FILE ${BinPAC_BINARY_DIR}/src/pac_parse.h
|
||||
COMPILE_FLAGS "--debug")
|
||||
bison_target(PACParser pac_parse.yy ${BinPAC_BINARY_DIR}/src/pac_parse.cc
|
||||
DEFINES_FILE ${BinPAC_BINARY_DIR}/src/pac_parse.h COMPILE_FLAGS "--debug")
|
||||
flex_target(PACScanner pac_scan.ll ${BinPAC_BINARY_DIR}/pac_scan.cc)
|
||||
add_flex_bison_dependency(PACScanner PACParser)
|
||||
if(MSVC)
|
||||
set_property(
|
||||
SOURCE pac_scan.cc
|
||||
APPEND_STRING
|
||||
PROPERTY COMPILE_FLAGS "/wd4018")
|
||||
else()
|
||||
set_property(
|
||||
SOURCE pac_scan.cc
|
||||
APPEND_STRING
|
||||
PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
|
||||
endif()
|
||||
if (MSVC)
|
||||
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "/wd4018")
|
||||
else ()
|
||||
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
|
||||
endif ()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
|
||||
|
||||
|
@ -110,19 +102,17 @@ add_executable(binpac ${binpac_SRCS})
|
|||
target_compile_features(binpac PRIVATE cxx_std_17)
|
||||
set_target_properties(binpac PROPERTIES CXX_EXTENSIONS OFF)
|
||||
|
||||
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 "BinPAC")
|
||||
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
target_link_libraries(binpac PRIVATE libunistd)
|
||||
endif()
|
||||
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 "BinPAC")
|
||||
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
|
||||
endif ()
|
||||
target_link_libraries(binpac PRIVATE libunistd)
|
||||
endif ()
|
||||
|
||||
install(TARGETS binpac DESTINATION bin)
|
||||
|
||||
# This is set to assist superprojects that want to build BinPac from source and
|
||||
# rely on it as a target
|
||||
set(BinPAC_EXE
|
||||
binpac
|
||||
CACHE STRING "BinPAC executable" FORCE)
|
||||
set(BinPAC_EXE binpac CACHE STRING "BinPAC executable" FORCE)
|
||||
|
|
|
@ -138,8 +138,8 @@ void HelperDecl::GenCode(Output* out_h, Output* out_cc) {
|
|||
Decl *decl = Decl::LookUpDecl(context_id_);
|
||||
if ( ! decl )
|
||||
{
|
||||
throw Exception(context_id_,
|
||||
fmt("cannot find declaration for %s",
|
||||
throw Exception(context_id_,
|
||||
fmt("cannot find declaration for %s",
|
||||
context_id_->Name()));
|
||||
}
|
||||
env = decl->env();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue