summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-10-26 05:10:10 -0700
committerGitHub <noreply@github.com>2021-10-26 12:10:10 +0000
commitbda2c87c96bf69e37940bb5ad34222e639f139bb (patch)
tree0bc80d47a743540f654d2c1d89e88c746afa193a
parent03cc4a7e06ce714abfc745c5de6b76b8f33cc882 (diff)
Fix frequent rebuild of options target (#7450)
The mkoptions.py script only updates its output files if their content would actually change. This avoid a full rebuild on every run, and makes sure that only parts that actually change are rebuild. Unfortunately this interacts badly with how cmake/make/... do inter-target dependency tracking. This PR adds a stamp file options.stamp that is always updated by mkoptions.py and used by cmake as main output.
-rw-r--r--src/CMakeLists.txt59
-rw-r--r--src/options/mkoptions.py3
2 files changed, 36 insertions, 26 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a2ffc1f34..2cb3457e1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1244,36 +1244,43 @@ if (BUILD_DOCS)
)
endif()
+# The mkoptions.py script only updates its output files if their content would
+# actually change. This mechanism makes sure that running the script does not
+# automatically trigger a full rebuild, but only a rebuild of those parts that
+# include files that did actually change.
+# This approach also means that the output files (which gen-options used to
+# depend on) may not actually be updated and thus cmake would keep re-running
+# mkoptions.py over and over again.
+# We thus have an artificial options.stamp file that mkoptions.py always writes
+# to, and can thus be used to communicate that all options files have been
+# properly updated.
add_custom_command(
- OUTPUT
- ${options_gen_cpp_files} ${options_gen_h_files}
- ${options_gen_doc_files}
- COMMAND
- ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/options
- COMMAND
- ${PYTHON_EXECUTABLE}
- ${CMAKE_CURRENT_LIST_DIR}/options/mkoptions.py
- ${CMAKE_CURRENT_LIST_DIR}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${abs_toml_files}
- DEPENDS
- options/mkoptions.py
- ${options_toml_files}
- main/options_template.cpp
- options/module_template.h
- options/module_template.cpp
- options/options_public_template.cpp
- options/options_template.h
- options/options_template.cpp
-)
-
-add_custom_target(gen-options
+ OUTPUT
+ options/options.stamp
+ COMMAND
+ ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/options
+ COMMAND
+ ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_LIST_DIR}/options/mkoptions.py
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${abs_toml_files}
+ BYPRODUCTS
+ ${options_gen_cpp_files} ${options_gen_h_files} ${options_gen_doc_files}
DEPENDS
- ${options_gen_cpp_files}
- ${options_gen_h_files}
+ options/mkoptions.py
+ ${options_toml_files}
+ main/options_template.cpp
+ options/module_template.h
+ options/module_template.cpp
+ options/options_public_template.cpp
+ options/options_template.h
+ options/options_template.cpp
)
+add_custom_target(gen-options DEPENDS options/options.stamp)
+
#-----------------------------------------------------------------------------#
diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py
index badfd59f0..7288ede51 100644
--- a/src/options/mkoptions.py
+++ b/src/options/mkoptions.py
@@ -1047,6 +1047,9 @@ def mkoptions_main():
codegen_module(module, dst_dir, module_tpls)
codegen_all_modules(modules, build_dir, dst_dir, global_tpls)
+ # Generate output file to signal cmake when this script was run last
+ open(os.path.join(dst_dir, 'options/options.stamp'), 'w').write('')
+
if __name__ == "__main__":
mkoptions_main()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback