zig icon indicating copy to clipboard operation
zig copied to clipboard

cmake: Mark `.git/HEAD` as a configure dependency

Open topolarity opened this issue 3 years ago • 1 comments

This ensures that the Zig version will be re-computed when jumping through the source tree. This can be important if bisecting across, e.g. AstGen, changes that must not use the old cache.

The basic outcome is that a CMake reconfigure is triggered if the HEAD changed:

$ ninja install
[1/2] Install the project...
-- Install configuration: "Debug"
$ git checkout HEAD^
...
$ ninja install
[0/1] Re-running CMake...
-- Configuring zig version 0.11.0-dev.1+841235b3f
-- Configuring done
-- Generating done
-- Build files have been written to: /home/topolarity/repos/zig/build
[4/5] Install the project...
-- Install configuration: "Debug"

-DZIG_VERSION behavior should not be affected by this change.

topolarity avatar Oct 31 '22 20:10 topolarity

Does it work properly outside of a git tree (e.g. when building from a source tarball)?

andrewrk avatar Nov 02 '22 20:11 andrewrk

Does it work properly outside of a git tree (e.g. when building from a source tarball)?

Yes - I tested it out by deleting .git, and I saw the expected -- Configuring zig version 0.11.0

CMake silently ignores any dependent files that are not present at configure time, and anyway this dependency is only marked if git describe succeeds (meaning we're in a git repo).

topolarity avatar Nov 09 '22 18:11 topolarity