This is an archive of the discontinued LLVM Phabricator instance.

CMake: Clean up VersionFromVCS.cmake
ClosedPublic

Authored by tstellar on Feb 17 2017, 6:45 AM.

Details

Summary

Fix a few problems in VersionFromVCS.cmake to make it more reliable:

  • Stop using git svn info to retrieve the svn revision. I am unable to determine what the svn revision returned by this command means. During my testing this command returned a revision from a month ago which was not the HEAD of any of my local branches.

    Also, this revision was never actually added to the version string due to a typo in the script. All it was used for was to reject the revision number returned by git svn find-rev HEAD when the revision numbers didn't match.
  • Populate LLVM_REPOSITORY variable using git svn info --url. This lets avoid having to do a search and replace on the output of git svn info
  • Populate GIT_COMMIT even when we detect a git repo without any svn information.

Diff Detail

Repository
rL LLVM

Event Timeline

tstellar created this revision.Feb 17 2017, 6:45 AM
mgorny added inline comments.Feb 17 2017, 7:28 AM
cmake/modules/VersionFromVCS.cmake
39 ↗(On Diff #88880)

Sorry for a bit offtopic but any idea why are we having a timeout for git commands? AFAICS they do not involve any network activity, so I don't see a good reason to timeout here. Furthermore, git can be a bit slow which makes 5 seconds kinda dangerous.

tstellar added inline comments.Feb 17 2017, 7:43 AM
cmake/modules/VersionFromVCS.cmake
39 ↗(On Diff #88880)

I think it was probably just a copy and paste from the svn commands. I can fix this in a follow up commit.

beanz edited edge metadata.Feb 17 2017, 3:19 PM

Mostly looks good, a few inline comments below.

cmake/modules/VersionFromVCS.cmake
37 ↗(On Diff #88880)

If the git svn information hasn't been updated recently the output of this command will also contain the log of rebuilding the git-svn data. Maybe run git svn fetch first to rebuild. Then when you run git svn info --url the only output should be the url.

43 ↗(On Diff #88880)

Instead of doing this strip you could add OUTPUT_STRIP_TRAILING_WHITESPACE to the execute_process call. The same applies to the other places we call string(STRIP...)

tstellar updated this revision to Diff 90036.Feb 28 2017, 8:01 AM

Use OUTPUT_STRIP_TRAILING_WHITESPACE for some of the git commands.

Also, revert the changes made to the git svn info invocation. What
we have now works, and I think trying to use --url and add the additional
git svn fetch will complicate the patch too much. I really just want
to get the vcs revision parsing working.

beanz accepted this revision.Mar 1 2017, 1:31 PM

LGTM!

This revision is now accepted and ready to land.Mar 1 2017, 1:31 PM
This revision was automatically updated to reflect the committed changes.