better initial workflow, thanks to Jon Siwek

This commit is contained in:
Vern Paxson 2021-05-05 18:52:06 -07:00
parent 4a1d5adcf4
commit c116b2b8ad
3 changed files with 11 additions and 11 deletions

View file

@ -220,6 +220,10 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set(_gen_zeek_script_cpp ${CMAKE_CURRENT_BINARY_DIR}/../CPP-gen.cc)
add_custom_command(OUTPUT ${_gen_zeek_script_cpp}
COMMAND ${CMAKE_COMMAND} -E touch ${_gen_zeek_script_cpp})
set_source_files_properties(nb_dns.c PROPERTIES COMPILE_FLAGS
-fno-strict-aliasing)
@ -349,7 +353,7 @@ set(MAIN_SRCS
script_opt/CPP/Util.cc
script_opt/CPP/Vars.cc
script_opt/CPP/CPP-gen.cc
${_gen_zeek_script_cpp}
script_opt/DefItem.cc
script_opt/DefSetsMgr.cc

View file

@ -313,7 +313,7 @@ void CPPCompile::GenEpilog()
if ( addl_tag > 0 )
return;
Emit("#include \"zeek/script_opt/CPP/CPP-gen-addl.h\"\n");
Emit("#include \"CPP-gen-addl.h\"\n");
Emit("} // zeek::detail");
}

View file

@ -54,13 +54,9 @@ at the beginning of `Compile.h`.
Workflows
---------
The main code generated by the compiler resides in
`src/script_opt/CPP/CPP-gen.cc`. That file does not initially exist, but
`src/CMakeLists.txt` specifies it, so in order for `./configure` to
succeed to start building Zeek, you need to first issue `touch
src/script_opt/CPP/CPP-gen.cc`. (The branch does not include an empty
version in `git` to prevent the common error of checking in a non-empty
version after using the compiler.)
The main code generated by the compiler is taken from
`build/CPP-gen.cc`. An empty version of this is generated when
first building Zeek.
As a user, the most common workflow is to build a version of Zeek that
has a given target script (`target.zeek`) compiled into it. This means
@ -73,8 +69,8 @@ The generated code is written to
`CPP-gen-addl.h`. (This name is a reflection of some more complicated
features and probably should be changed.) The compiler will also produce
a file `CPP-hashes.dat`, for use by an advanced feature.
2. `mv CPP-gen-addl.h ../src/script_opt/CPP/CPP-gen.cc`
3. `touch ../src/script_opt/CPP/CPP-gen-addl.h`
2. `mv CPP-gen-addl.h CPP-gen.cc`
3. `touch CPP-gen-addl.h`
(Needed because `CPP-gen.cc`
expects the file to exist, again in support of more complicated features.)
4. `ninja` or `make` to recompile Zeek