HomePhabricator

[CMAKE] Only change obj/build.h if the content has changed

Description

[CMAKE] Only change obj/build.h if the content has changed

Summary:
This diff creates a temporary build.h.tmp file, then copies it to
obj/build.h only if it differs from it.
This avoid rebuilding due to the obj/build.h being touched while the
content remains unchanged.

In order to generate the intermediate file every time git HEAD is
updated, the .git/log/HEAD file is set as a dependency for the custom
command.

Test Plan:

mkdir buildcmake && cd buildcmake
cmake -GNinja ..
ninja util

Check the buildcmake/obj/build.h file is generated and the
buildcmake/obj/build.h.tmp is removed.

ninja util

Should return no work to do.
Amend the commit summary, then

ninja util

Check the buildcmake/obj/build.h file is generated again and the
buildcmake/obj/build.h.tmp is still not there.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4116

Details

Provenance
FabienAuthored on Sep 20 2019, 12:39
FabienPushed on Sep 24 2019, 16:01
Reviewer
Restricted Project
Differential Revision
D4116: [CMAKE] Only change obj/build.h if the content has changed
Parents
rSTAGING3629bb51288f: Run miner_tests with fixed options
Branches
Unknown
Tags
Unknown