diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37036504c4..8c403330b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/script_opt/CPP/Driver.cc b/src/script_opt/CPP/Driver.cc index 92a8e21cd6..3efe5177a1 100644 --- a/src/script_opt/CPP/Driver.cc +++ b/src/script_opt/CPP/Driver.cc @@ -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"); } diff --git a/src/script_opt/CPP/README.md b/src/script_opt/CPP/README.md index 789a260734..6cabc2cd7c 100644 --- a/src/script_opt/CPP/README.md +++ b/src/script_opt/CPP/README.md @@ -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