This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Avoid __FakeVCSRevision.h with no git repository
ClosedPublic

Authored by Hahnfeld on Dec 5 2020, 4:10 AM.

Details

Summary

Set the return variable to "" in find_first_existing_vc_file to
say that there is a repository, but no file to depend on. This works
transparently for all other callers that handle undefinedness and
equality to an empty string the same way.

Use the knowledge to avoid depending on __FakeVCSRevision.h if there
is no git repository at all (for example when building a release) as
there is no point in regenerating an empty VCSRevision.h.

Diff Detail

Event Timeline

Hahnfeld created this revision.Dec 5 2020, 4:10 AM
Hahnfeld requested review of this revision.Dec 5 2020, 4:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2020, 4:10 AM

The change makes sense to me, but at this point it might be good to add a comment for find_first_existing_vc_file to say what it does and what each possible return value means. Maybe something like:

# If the sources being configured are under version control, set `out_var`
# to the the path of a file which will be modified when the VCS revision
# changes, attempting to create that file if it does not exist; if no such
# file exists and one cannot be created, instead set `out_var` to the
# empty string.
#
# If the sources being configured are not under version control, do not
# define `out_var`.
Hahnfeld updated this revision to Diff 311989.Dec 15 2020, 12:13 PM

Add comment for find_first_existing_vc_file, thanks @scott.linder.

scott.linder accepted this revision.Dec 15 2020, 2:08 PM

LGTM, thank you!

This revision is now accepted and ready to land.Dec 15 2020, 2:08 PM
This revision was automatically updated to reflect the committed changes.