mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:07:46 +00:00
Build: Support make's and ninja's restat optimization
After running a build command, make by default stat()s the command's output, and if it wasn't touched, then it cancels all build steps that were scheduled only because this command was expected to change the output. Ninja has the same feature, but it's opt-in behind the per-command "restat = 1" setting. However, CMake enables it by default for all custom commands. Use Meta/write-only-on-difference.sh to write the output to a temporary file, and then copy the temporary file only to the final location if the contents of the output have changed since last time. write-only-on-difference.sh automatically creates the output's parent directory, so stop doing that in CMake. Reduces the number of build steps that run after touching a file in LibCore from 522 to 312. Since we now no longer trigger the CMake special case "If COMMAND specifies an executable target name (created by the add_executable() command), it will automatically be replaced by the location of the executable created at build time", we now need to use qualified paths to the generators. Somewhat related to #2877.
This commit is contained in:
parent
1d08cab9ab
commit
d8b6314018
2 changed files with 8 additions and 11 deletions
|
@ -51,6 +51,8 @@ add_subdirectory(DevTools/FormCompiler)
|
|||
add_subdirectory(Libraries/LibWeb/CodeGenerators)
|
||||
add_subdirectory(AK/Tests)
|
||||
|
||||
set(write_if_different ${CMAKE_SOURCE_DIR}/Meta/write-only-on-difference.sh)
|
||||
|
||||
function(serenity_install_headers target_name)
|
||||
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
foreach(header ${headers})
|
||||
|
@ -96,7 +98,7 @@ function(compile_ipc source output)
|
|||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND IPCCompiler ${source} > ${output}
|
||||
COMMAND ${write_if_different} ${output} ${CMAKE_BINARY_DIR}/DevTools/IPCCompiler/IPCCompiler ${source}
|
||||
VERBATIM
|
||||
DEPENDS IPCCompiler
|
||||
MAIN_DEPENDENCY ${source}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue