Merge remote-tracking branch 'origin/topic/dnthayer/ticket1440'

* origin/topic/dnthayer/ticket1440:
  Remove build dependency on perl
This commit is contained in:
Robin Sommer 2015-08-06 22:25:19 -04:00
parent 67d529585c
commit 9efd54a08a
10 changed files with 141 additions and 159 deletions

13
CHANGES
View file

@ -1,4 +1,17 @@
2.4-78 | 2015-08-06 22:25:19 -0400
* Remove build dependency on Perl (now requiring Python instad).
(Daniel Thayer)
* CID 1314754: Fixing unreachable code in RSH analyzer. (Robin
Sommer)
* CID 1312752: Add comment to mark 'case' fallthrough as ok. (Robin
Sommer)
* CID 1312751: Removing redundant assignment. (Robin Sommer)
2.4-73 | 2015-07-31 08:53:49 -0700
* BIT-1429: SMTP logs now include CC: addresses. (Albert Zaharovits)

View file

@ -61,7 +61,7 @@ if (NOT SED_EXE)
endif ()
endif ()
FindRequiredPackage(Perl)
FindRequiredPackage(PythonInterp)
FindRequiredPackage(FLEX)
FindRequiredPackage(BISON)
FindRequiredPackage(PCAP)

2
NEWS
View file

@ -16,6 +16,8 @@ New Dependencies
- Bro now requires the C++ Actor Framework, CAF, which must be
installed first. See http://actor-framework.org.
- Bro now requires Python instead of Perl to compile the source code.
New Functionality
-----------------

View file

@ -1 +1 @@
2.4-73
2.4-78

@ -1 +1 @@
Subproject commit 07af9748f40dc47d3a2b3290db494a90dcbddbdc
Subproject commit 7012f7bb7768ffd56282e0d453c5f919b2142551

6
configure vendored
View file

@ -55,7 +55,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--with-binpac=PATH path to BinPAC install root
--with-flex=PATH path to flex executable
--with-bison=PATH path to bison executable
--with-perl=PATH path to perl executable
--with-python=PATH path to Python executable
--with-libcaf=PATH path to C++ Actor Framework installation
(a required Broker dependency)
@ -63,7 +63,6 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--with-geoip=PATH path to the libGeoIP install root
--with-perftools=PATH path to Google Perftools install root
--with-jemalloc=PATH path to jemalloc install root
--with-python=PATH path to Python interpreter
--with-python-lib=PATH path to libpython
--with-python-inc=PATH path to Python headers
--with-ruby=PATH path to ruby interpreter
@ -239,9 +238,6 @@ while [ $# -ne 0 ]; do
--with-bison=*)
append_cache_entry BISON_EXECUTABLE PATH $optarg
;;
--with-perl=*)
append_cache_entry PERL_EXECUTABLE PATH $optarg
;;
--with-geoip=*)
append_cache_entry LibGeoIP_ROOT_DIR PATH $optarg
;;

View file

@ -45,7 +45,7 @@ To build Bro from source, the following additional dependencies are required:
* Libpcap headers (http://www.tcpdump.org)
* OpenSSL headers (http://www.openssl.org)
* zlib headers
* Perl
* Python
.. todo::
@ -72,7 +72,7 @@ To install the required dependencies, you can use:
.. console::
sudo pkg install bash cmake swig bison python perl5 py27-sqlite3
sudo pkg install bash cmake swig bison python py27-sqlite3
Note that in older versions of FreeBSD, you might have to use the
"pkg_add -r" command instead of "pkg install".

View file

@ -223,16 +223,16 @@ endmacro(COLLECT_HEADERS _var)
cmake_policy(POP)
# define a command that's used to run the make_dbg_constants.pl script
# define a command that's used to run the make_dbg_constants.py script
# building the bro binary depends on the outputs of this script
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h
${CMAKE_CURRENT_BINARY_DIR}/DebugCmdInfoConstants.cc
COMMAND ${PERL_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.pl
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.py
${CMAKE_CURRENT_SOURCE_DIR}/DebugCmdInfoConstants.in
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.pl
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.py
${CMAKE_CURRENT_SOURCE_DIR}/DebugCmdInfoConstants.in
COMMENT "[Perl] Processing debug commands"
COMMENT "[Python] Processing debug commands"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

View file

@ -1,143 +0,0 @@
# Build the DebugCmdConstants.h and DebugCmdInfoConstants.h files from the
# DebugCmdInfoConstants.in file.
#
# We do this via a script rather than maintaining them directly because
# the struct is a little complicated, so has to be initialized from code,
# plus we want to make adding new constants somewhat less painful.
#
# The input filename should be supplied as an argument
#
# DebugCmds are printed to DebugCmdConstants.h
# DebugCmdInfos are printed to DebugCmdInfoConstants.h
#
# The input format is:
#
# cmd: [DebugCmd]
# names: [space delimited names of cmd]
# resume: ['true' or 'false': should execution resume after this command?]
# help: [some help text]
#
# Blank lines are skipped.
# Comments should start with // and should be on a line by themselves.
use strict;
open INPUT, $ARGV[0] or die "Input file $ARGV[0] not found.";
open DEBUGCMDS, ">DebugCmdConstants.h"
or die "Unable to open DebugCmdConstants.h";
open DEBUGCMDINFOS, ">DebugCmdInfoConstants.cc"
or die "Unable to open DebugCmdInfoConstants.cc";
my $init_tmpl =
'
{
DebugCmdInfo* info;
@@name_init
info = new DebugCmdInfo (@@cmd, names, @@num_names, @@resume, "@@help",
@@repeatable);
g_DebugCmdInfos.push_back(info);
}
';
my $enum_str = "
//
// This file was automatically generated from $ARGV[0]
// DO NOT EDIT.
//
enum DebugCmd {
";
my $init_str = "
//
// This file was automatically generated from $ARGV[0]
// DO NOT EDIT.
//
#include \"util.h\"
void init_global_dbg_constants () {
";
my %dbginfo;
# { cmd, num_names, \@names, name_init, resume, help, repeatable }
no strict "refs";
sub OutputRecord {
$dbginfo{name_init} .= "const char * const names[] = {\n\t";
$_ = "\"$_\"" foreach @{$dbginfo{names}}; # put quotes around the strings
my $name_strs = join ",\n\t", @{$dbginfo{names}};
$dbginfo{name_init} .= "$name_strs\n };\n";
$dbginfo{num_names} = scalar @{$dbginfo{names}};
# substitute into template
my $init = $init_tmpl;
$init =~ s/(\@\@(\w+))/defined $dbginfo{$2} ? $dbginfo{$2} : ""/eg;
$init_str .= $init;
$enum_str .= "\t$dbginfo{cmd},\n";
}
use strict "refs";
sub InitDbginfo
{
my $dbginfo = shift;
%$dbginfo = ( num_names => 0, names => [], resume => 'false', help => '',
repeatable => 'false' );
}
InitDbginfo(\%dbginfo);
while (<INPUT>) {
chomp ($_);
next if $_ =~ /^\s*$/; # skip blank
next if $_ =~ /^\s*\/\//; # skip comments
$_ =~ /^\s*([a-z]+):\s*(.*)$/ or
die "Error in debug constant file on line: $_";
if ($1 eq 'cmd')
{
my $newcmd = $2;
if (defined $dbginfo{cmd}) { # output the previous record
OutputRecord();
InitDbginfo(\%dbginfo);
}
$dbginfo{cmd} = $newcmd;
}
elsif ($1 eq 'names')
{
my @names = split / /, $2;
$dbginfo{names} = \@names;
}
elsif ($1 eq 'resume')
{
$dbginfo{resume} = $2;
}
elsif ($1 eq 'help')
{
$dbginfo{help} = $2;
$dbginfo{help} =~ s{\"}{\\\"}g; # escape quotation marks
}
elsif ($1 eq 'repeatable')
{
$dbginfo{repeatable} = $2;
}
else {
die "Unknown command: $_\n";
}
}
# output the last record
OutputRecord();
$init_str .= " \n}\n";
$enum_str .= " dcLast\n};\n";
print DEBUGCMDS $enum_str;
close DEBUGCMDS;
print DEBUGCMDINFOS $init_str;
close DEBUGCMDINFOS;

114
src/make_dbg_constants.py Normal file
View file

@ -0,0 +1,114 @@
# Build the DebugCmdConstants.h and DebugCmdInfoConstants.cc files from the
# DebugCmdInfoConstants.in file.
#
# We do this via a script rather than maintaining them directly because
# the struct is a little complicated, so has to be initialized from code,
# plus we want to make adding new constants somewhat less painful.
#
# The input filename should be supplied as an argument.
#
# DebugCmds are printed to DebugCmdConstants.h
# DebugCmdInfos are printed to DebugCmdInfoConstants.cc
#
# The input format is:
#
# cmd: [DebugCmd]
# names: [space delimited names of cmd]
# resume: ['true' or 'false': should execution resume after this command?]
# help: [some help text]
#
# Blank lines are skipped.
# Comments should start with // and should be on a line by themselves.
import sys
inputfile = sys.argv[1]
init_tmpl = '''
{
DebugCmdInfo* info;
%(name_init)s
info = new DebugCmdInfo (%(cmd)s, names, %(num_names)s, %(resume)s, "%(help)s",
%(repeatable)s);
g_DebugCmdInfos.push_back(info);
}
'''
enum_str = '''
//
// This file was automatically generated from %s
// DO NOT EDIT.
//
enum DebugCmd {
''' % inputfile
init_str = '''
//
// This file was automatically generated from %s
// DO NOT EDIT.
//
#include "util.h"
void init_global_dbg_constants () {
''' % inputfile
def outputrecord():
global init_str, enum_str
dbginfo["name_init"] = "const char * const names[] = {\n\t%s\n };\n" % ",\n\t".join(dbginfo["names"])
dbginfo["num_names"] = len(dbginfo["names"])
# substitute into template
init_str += init_tmpl % dbginfo
enum_str += "\t%s,\n" % dbginfo["cmd"]
def initdbginfo():
return {"cmd": "", "name_init": "", "num_names": 0, "names": [],
"resume": "false", "help": "", "repeatable": "false"}
dbginfo = initdbginfo()
inputf = open(inputfile, "r")
for line in inputf:
line = line.strip()
if not line or line.startswith("//"): # skip empty lines and comments
continue
fields = line.split(":", 1)
if len(fields) != 2:
raise RuntimeError("Error in debug constant file on line: %s" % line)
f1, f2 = fields
f2 = f2.strip()
if f1 == "cmd":
if dbginfo[f1]: # output the previous record
outputrecord()
dbginfo = initdbginfo()
dbginfo[f1] = f2
elif f1 == "names":
# put quotes around the strings
dbginfo[f1] = [ '"%s"' % n for n in f2.split() ]
elif f1 == "help":
dbginfo[f1] = f2.replace('"', '\\"') # escape quotation marks
elif f1 in ("resume", "repeatable"):
dbginfo[f1] = f2
else:
raise RuntimeError("Unknown command: %s" % line)
# output the last record
outputrecord()
init_str += " \n}\n"
enum_str += " dcLast\n};\n"
debugcmds = open("DebugCmdConstants.h", "w")
debugcmds.write(enum_str)
debugcmds.close()
debugcmdinfos = open("DebugCmdInfoConstants.cc", "w")
debugcmdinfos.write(init_str)
debugcmdinfos.close()