bif files declared with bif_target() are now automatically compiled

in.

No more manual includes to pull them in.

(It doesn't quite work fully automatically yet for some bifs that need
script-level types defined, like the input and logging frameworks.
They still do a manual "@load foo.bif" in their main.bro to get the
order right. It's a bit tricky to fix that and would probably need
splitting main.bro into two parts; not sure that's worth it.)
This commit is contained in:
Robin Sommer 2013-07-25 09:45:10 -07:00
parent febb7e8395
commit 4a7046848c
11 changed files with 42 additions and 10 deletions

10
CHANGES
View file

@ -1,4 +1,14 @@
2.1-826 | 2013-07-25 10:12:26 -0700
* bif files declared with bif_target() are now automatically
compiled in. No more manual includes to pull them in. (Robin
Sommer)
* Covenience make target in testing/btest to update the three
coverage tests that usually need tweaking when scripts get
added/removed. (Robin Sommer)
2.1-824 | 2013-07-22 14:25:14 -0400 2.1-824 | 2013-07-22 14:25:14 -0400
* Fixed a scriptland state issue that manifested especially badly on proxies. (Seth Hall) * Fixed a scriptland state issue that manifested especially badly on proxies. (Seth Hall)

View file

@ -1 +1 @@
2.1-824 2.1-826

@ -1 +1 @@
Subproject commit c39bd478b9d0ecd05b1b83aa9d09a7887893977c Subproject commit 0c91feea55d00d3a1787203b3a43e3f9044d66e0

2
cmake

@ -1 +1 @@
Subproject commit 0187b33a29d5ec824f940feff60dc5d8c2fe314f Subproject commit 026639f8368e56742c0cb5d9fb390ea64e60ec50

View file

@ -3050,3 +3050,5 @@ const snaplen = 8192 &redef;
@load base/frameworks/input @load base/frameworks/input
@load base/frameworks/analyzer @load base/frameworks/analyzer
@load base/frameworks/file-analysis @load base/frameworks/file-analysis
@load base/bif

View file

@ -6,6 +6,9 @@ include_directories(BEFORE
# This collects generated bif and pac files from subdirectories. # This collects generated bif and pac files from subdirectories.
set(bro_ALL_GENERATED_OUTPUTS CACHE INTERNAL "automatically generated files" FORCE) set(bro_ALL_GENERATED_OUTPUTS CACHE INTERNAL "automatically generated files" FORCE)
# This collects bif inputs that we'll load automatically.
set(bro_AUTO_BIFS CACHE INTERNAL "BIFs for automatic inclusion" FORCE)
# If TRUE, use CMake's object libraries for sub-directories instead of # If TRUE, use CMake's object libraries for sub-directories instead of
# static libraries. This requires CMake >= 2.8.8. # static libraries. This requires CMake >= 2.8.8.
set(bro_HAVE_OBJECT_LIBRARIES FALSE) set(bro_HAVE_OBJECT_LIBRARIES FALSE)
@ -382,8 +385,21 @@ set(BRO_EXE bro
CACHE STRING "Bro executable binary" FORCE) CACHE STRING "Bro executable binary" FORCE)
# Target to create all the autogenerated files. # Target to create all the autogenerated files.
add_custom_target(generate_outputs_stage1)
add_dependencies(generate_outputs_stage1 ${bro_ALL_GENERATED_OUTPUTS})
# Target to create the joint includes files that pull in the bif code.
bro_bif_create_includes(generate_outputs_stage2 ${CMAKE_CURRENT_BINARY_DIR} "${bro_AUTO_BIFS}")
add_dependencies(generate_outputs_stage2 generate_outputs_stage1)
# Global target to trigger creation of autogenerated code.
add_custom_target(generate_outputs) add_custom_target(generate_outputs)
add_dependencies(generate_outputs ${bro_ALL_GENERATED_OUTPUTS}) add_dependencies(generate_outputs generate_outputs_stage2)
# Build __load__.bro files for standard *.bif.bro.
bro_bif_create_loader(bif_loader ${CMAKE_BINARY_DIR}/scripts/base/bif)
add_dependencies(bif_loader ${bro_SUBDIRS})
add_dependencies(bro bif_loader)
# Build __load__.bro files for plugins/*.bif.bro. # Build __load__.bro files for plugins/*.bif.bro.
bro_bif_create_loader(bif_loader_plugins ${CMAKE_BINARY_DIR}/scripts/base/bif/plugins) bro_bif_create_loader(bif_loader_plugins ${CMAKE_BINARY_DIR}/scripts/base/bif/plugins)

View file

@ -560,6 +560,8 @@ void builtin_error(const char* msg, BroObj* arg)
#include "reporter.bif.func_def" #include "reporter.bif.func_def"
#include "strings.bif.func_def" #include "strings.bif.func_def"
#include "__all__.bif.cc" // Autogenerated for compiling in the bif_target() code.
void init_builtin_funcs() void init_builtin_funcs()
{ {
bro_resources = internal_type("bro_resources")->AsRecordType(); bro_resources = internal_type("bro_resources")->AsRecordType();
@ -574,6 +576,8 @@ void init_builtin_funcs()
#include "reporter.bif.func_init" #include "reporter.bif.func_init"
#include "strings.bif.func_init" #include "strings.bif.func_init"
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
did_builtin_init = true; did_builtin_init = true;
} }

View file

@ -103,7 +103,6 @@ void Manager::InitPreScript()
void Manager::InitPostScript() void Manager::InitPostScript()
{ {
#include "analyzer.bif.init.cc"
} }
void Manager::DumpDebug() void Manager::DumpDebug()

View file

@ -60,7 +60,6 @@ void Manager::RegisterAnalyzerComponent(Component* component)
void Manager::InitPostScript() void Manager::InitPostScript()
{ {
#include "file_analysis.bif.init.cc"
} }
void Manager::Terminate() void Manager::Terminate()

View file

@ -3,7 +3,7 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path loaded_scripts #path loaded_scripts
#open 2013-07-05-05-20-50 #open 2013-07-25-17-10-49
#fields name #fields name
#types string #types string
scripts/base/init-bare.bro scripts/base/init-bare.bro
@ -87,6 +87,7 @@ scripts/base/init-bare.bro
scripts/base/frameworks/file-analysis/__load__.bro scripts/base/frameworks/file-analysis/__load__.bro
scripts/base/frameworks/file-analysis/main.bro scripts/base/frameworks/file-analysis/main.bro
build/scripts/base/bif/file_analysis.bif.bro build/scripts/base/bif/file_analysis.bif.bro
build/scripts/base/bif/__load__.bro
scripts/policy/misc/loaded-scripts.bro scripts/policy/misc/loaded-scripts.bro
scripts/base/utils/paths.bro scripts/base/utils/paths.bro
#close 2013-07-05-05-20-50 #close 2013-07-25-17-10-49

View file

@ -3,7 +3,7 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path loaded_scripts #path loaded_scripts
#open 2013-07-10-21-18-31 #open 2013-07-25-17-10-50
#fields name #fields name
#types string #types string
scripts/base/init-bare.bro scripts/base/init-bare.bro
@ -87,6 +87,7 @@ scripts/base/init-bare.bro
scripts/base/frameworks/file-analysis/__load__.bro scripts/base/frameworks/file-analysis/__load__.bro
scripts/base/frameworks/file-analysis/main.bro scripts/base/frameworks/file-analysis/main.bro
build/scripts/base/bif/file_analysis.bif.bro build/scripts/base/bif/file_analysis.bif.bro
build/scripts/base/bif/__load__.bro
scripts/base/init-default.bro scripts/base/init-default.bro
scripts/base/utils/site.bro scripts/base/utils/site.bro
scripts/base/utils/patterns.bro scripts/base/utils/patterns.bro
@ -195,4 +196,4 @@ scripts/base/init-default.bro
scripts/base/protocols/tunnels/__load__.bro scripts/base/protocols/tunnels/__load__.bro
scripts/base/misc/find-checksum-offloading.bro scripts/base/misc/find-checksum-offloading.bro
scripts/policy/misc/loaded-scripts.bro scripts/policy/misc/loaded-scripts.bro
#close 2013-07-10-21-18-31 #close 2013-07-25-17-10-50