forked from len0rd/rockbox
rbutil: Create git version information at build time.
Change-Id: Iaf701f4d64d6852423f6a28a753b27abc43477e2
This commit is contained in:
parent
6783b2c8a7
commit
eb8dc75d38
4 changed files with 79 additions and 3 deletions
58
utils/cmake/gitversion.cmake
Normal file
58
utils/cmake/gitversion.cmake
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# __________ __ ___.
|
||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
# \/ \/ \/ \/ \/
|
||||
#
|
||||
# All files in this archive are subject to the GNU General Public License.
|
||||
# See the file COPYING in the source tree root for full license agreement.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
|
||||
find_package(Git QUIET)
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify --short=10 HEAD
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
ERROR_QUIET)
|
||||
|
||||
# Check whether we got any revision (which isn't
|
||||
# always the case, e.g. when someone downloaded a zip
|
||||
# file from Github instead of a checkout)
|
||||
if ("${GIT_HASH}" STREQUAL "")
|
||||
set(GIT_HASH "N/A")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git diff --quiet --exit-code
|
||||
RESULT_VARIABLE GIT_DIFF_EXITCODE)
|
||||
|
||||
string(STRIP "${GIT_HASH}" GIT_HASH)
|
||||
if (${GIT_DIFF_EXITCODE})
|
||||
set(GIT_DIFF "M")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(TIMESTAMP TODAY "%y%m%d")
|
||||
set(VERSION "
|
||||
#ifndef GITVERSION
|
||||
#define GITVERSION \"${GIT_HASH}${GIT_DIFF}-${TODAY}\"
|
||||
#define GITHASH \"${GIT_HASH}${GIT_DIFF}\"
|
||||
#define BUILDDATE \"${TODAY}\"
|
||||
#endif
|
||||
")
|
||||
|
||||
if(EXISTS ${OUTFILE})
|
||||
file(READ "${OUTFILE}" _version)
|
||||
else()
|
||||
set(_version "")
|
||||
endif()
|
||||
|
||||
if (NOT "${VERSION}" STREQUAL "${_version}")
|
||||
file(WRITE "${OUTFILE}" "${VERSION}")
|
||||
endif()
|
||||
|
||||
message("-- Revision: ${GIT_HASH}${GIT_DIFF}")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue