Squashed commit of the following:
commit
e644105f5c593f23cabcf6486d1c32e4ce87472e
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date: Fri Apr 9 14:17:58 2021 +0300
build: add better support for flex lexer
Thanks to Özkan KIRIK and Moin for reporting the issue.
commit
67548b869fa80173561b141b1733e0da41da84bf
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date: Thu Apr 8 21:22:21 2021 +0300
utils: enable Flex C++ mode via its option
* cmake to build from source
* daq from https://github.com/snort3/libdaq for packet IO
* dnet from https://github.com/dugsong/libdnet.git for network utility functions
+* flex >= 2.6.0 from https://github.com/westes/flex for JavaScript syntax parser
* g++ >= 5 or other C++14 compiler
* hwloc from https://www.open-mpi.org/projects/hwloc/ for CPU affinity management
* LuaJIT from http://luajit.org for configuration and scripting
--- /dev/null
+
+find_package(FLEX 2.6.0 REQUIRED)
+
+find_path(FLEX_INCLUDES "FlexLexer.h"
+ HINTS ${FLEX_INCLUDE_DIR_HINT}
+ PATHS ${FLEX_INCLUDE_DIRS}
+ REQUIRED
+)
+
+mark_as_advanced(FLEX_INCLUDES)
set(FLATBUFFERS_CPPFLAGS "-I${FLATBUFFERS_INCLUDE_DIR}")
endif()
+if(FLEX_INCLUDES)
+ set(FLEX_CPPFLAGS "-I${FLEX_INCLUDES}")
+endif()
+
if(HS_INCLUDE_DIR)
set(HYPERSCAN_CPPFLAGS "-I${HS_INCLUDE_DIR}")
endif()
find_package(Threads REQUIRED)
find_package(DAQ REQUIRED)
find_package(DNET REQUIRED)
-find_package(FLEX REQUIRED)
+find_package(FlexLexer REQUIRED)
find_package(HWLOC REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(OpenSSL REQUIRED)
flatbuffers include directory
--with-flatbuffers-libraries=DIR
flatbuffers library directory
+ --with-flex-prefix=DIR
+ flex prefix directory
+ --with-flex-includes=DIR
+ flex include directory
--with-iconv-includes=DIR
libiconv include directory
--with-iconv-libraries=DIR
--with-flatbuffers-libraries=*)
append_cache_entry FLATBUFFERS_LIBRARIES_DIR_HINT PATH $optarg
;;
+ --with-flex-prefix=*)
+ append_cache_entry CMAKE_PREFIX_PATH PATH $optarg
+ ;;
+ --with-flex-includes=*)
+ append_cache_entry FLEX_INCLUDE_DIR_HINT PATH $optarg
+ ;;
--with-iconv-includes=*)
append_cache_entry ICONV_INCLUDE_DIR_HINT PATH $optarg
;;
DNET_CPPFLAGS=@DNET_CPPFLAGS@
DAQ_CPPFLAGS=@DAQ_CPPFLAGS@
FLATBUFFERS_CPPFLAGS=@FLATBUFFERS_CPPFLAGS@
+FLEX_CPPFLAGS=@FLEX_CPPFLAGS@
OPENSSL_CPPFLAGS=@OPENSSL_CPPFLAGS@
HWLOC_CPPFLAGS=@HWLOC_CPPFLAGS@
PCRE_CPPFLAGS=@PCRE_CPPFLAGS@
set(EXTERNAL_INCLUDES
${DAQ_INCLUDE_DIR}
${DNET_INCLUDE_DIR}
+ ${FLEX_INCLUDES}
${HWLOC_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${PCAP_INCLUDE_DIR}
util_utf.h
)
-set (FLEX_EXECUTABLE flex++)
-
FLEX_TARGET ( js_tokenizer ${CMAKE_CURRENT_SOURCE_DIR}/js_tokenizer.l
${CMAKE_CURRENT_BINARY_DIR}/js_tokenizer.cc
COMPILE_FLAGS -Ca
%option yyclass="JSTokenizer"
/* Disable yywrap() generation */
%option noyywrap
+/* Generate C++ scanner */
+%option c++
%{
#ifdef HAVE_CONFIG_H