diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-04 17:21:39 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-04 17:21:39 +0400 |
commit | 2010c6ad6cae41b5f13b36339404ff60c98ae915 (patch) | |
tree | 543e34b74bf56ce9338f3ae0e029852cdd78905a /build_files/cmake/buildinfo.cmake | |
parent | d07f3f793b8c7596e36249d589aafcf63611cc1d (diff) |
Made buildinfo aware of builds from GIT
- Use commit number since last annotated tag as a
revision number replacement. It'll eb followed
by 'M' symbol if there're local modification in
the source tree.
- Commit short SHA1 is included. Helps getting
information about commit used to build blender
with much faster.
- If build is not done from master branch, this also
will be noticed in the splash screen.
This commit also replaces revision stored in the
files with git-specific fields (change and hash).
This is kind of breaks compatibility, meaning
files which were saved before this change wouldn't
display any information about which revision they
were saved with. When we'll finally switch to git,
we'll see proper hash and change number since
previous release in the files, for until then
svn version will be used as a change number and
hash will be empty.
Not a huge deal, since this field was only used
by developers to help torubleshooting things and
isn't needed for blender itself.
Some additional tweaks are probably needed :)
Diffstat (limited to 'build_files/cmake/buildinfo.cmake')
-rw-r--r-- | build_files/cmake/buildinfo.cmake | 84 |
1 files changed, 76 insertions, 8 deletions
diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index e68015e36d3..ae2f87b49be 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -1,16 +1,82 @@ # This is called by cmake as an extermal process from # ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h -# The FindSubversion.cmake module is part of the standard distribution -include(FindSubversion) - # Extract working copy information for SOURCE_DIR into MY_XXX variables # with a default in case anything fails, for examble when using git-svn -set(MY_WC_REVISION "unknown") +set(MY_WC_HASH "") +set(MY_WC_BRANCH "") +set(MY_WC_CHANGE "unknown") + # Guess if this is a SVN working copy and then look up the revision -if(EXISTS ${SOURCE_DIR}/.svn/) - if(Subversion_FOUND) - Subversion_WC_INFO(${SOURCE_DIR} MY) +if(EXISTS ${SOURCE_DIR}/.git/) + if(EXISTS ${SOURCE_DIR}/.git/) + # The FindSubversion.cmake module is part of the standard distribution + include(FindGit) + if(GIT_FOUND) + execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Get latest version tag + execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0 + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_latest_version_tag + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT _git_latest_version_tag STREQUAL "") + execute_process(COMMAND git rev-list HEAD ^${_git_latest_version_tag} --count + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_CHANGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + # For the time being we don't have annotated release tags, + # count all the revisions in branch. + execute_process(COMMAND git rev-list HEAD --count + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_CHANGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + + # Update GIT index before getting dirty files + execute_process(COMMAND git update-index -q --refresh + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND git diff-index --name-only HEAD -- + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_changed_files + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT _git_changed_files STREQUAL "") + set(MY_WC_CHANGE "${MY_WC_CHANGE}M") + endif() + + unset(_git_changed_files) + unset(_git_latest_version_tag) + endif() + endif() +else() + # Some crazy folks like me could have hacked git-svn chekout in a way + # so svnversion gives proper svn revision for themm which required having + # empty .svn folder. + # + # For such a crazy blokes put svn check into an else branch. + # + # (sergey) + if(EXISTS ${SOURCE_DIR}/.svn/) + # The FindSubversion.cmake module is part of the standard distribution + include(FindSubversion) + + if(Subversion_FOUND) + Subversion_WC_INFO(${SOURCE_DIR} MY) + set(MY_WC_CHANGE "${MY_WC_REVISION}") + endif() endif() endif() @@ -27,7 +93,9 @@ endif() # Write a file with the SVNVERSION define file(WRITE buildinfo.h.txt - "#define BUILD_REV \"${MY_WC_REVISION}\"\n" + "#define BUILD_HASH \"${MY_WC_HASH}\"\n" + "#define BUILD_CHANGE \"${MY_WC_CHANGE}\"\n" + "#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n" "#define BUILD_DATE \"${BUILD_DATE}\"\n" "#define BUILD_TIME \"${BUILD_TIME}\"\n" ) |