mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
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
|
@ -333,5 +333,21 @@ add_library(rbtomcrypt
|
|||
)
|
||||
target_include_directories(rbtomcrypt PUBLIC ${CMAKE_CURRENT_LIST_DIR}/tomcrypt/src/headers)
|
||||
|
||||
|
||||
# target will always be build. File is only updated when contents change.
|
||||
add_custom_target(gitversion.h
|
||||
COMMENT "Updating gitversion.h"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DOUTFILE=${CMAKE_CURRENT_BINARY_DIR}/gitversion/gitversion.h
|
||||
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/gitversion.cmake
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gitversion/gitversion.h)
|
||||
|
||||
# link to get git version header.
|
||||
add_library(gitversion INTERFACE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gitversion/gitversion.h)
|
||||
|
||||
add_dependencies(gitversion gitversion.h)
|
||||
target_include_directories(gitversion INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/gitversion)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/deploy.cmake)
|
||||
add_subdirectory(rbutilqt)
|
||||
|
|
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}")
|
||||
|
|
@ -122,7 +122,7 @@ if(APPLE)
|
|||
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
target_link_libraries(RockboxUtility rbbase cutelogger
|
||||
target_link_libraries(RockboxUtility rbbase cutelogger gitversion
|
||||
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia)
|
||||
|
||||
target_include_directories(RockboxUtility PRIVATE
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "gitversion.h"
|
||||
|
||||
// PUREVERSION is needed to be able to just compare versions. It does not
|
||||
// contain a build timestamp because it needs to be the same in different
|
||||
// files
|
||||
|
@ -38,7 +40,7 @@
|
|||
#define VERSIONSTRING(a, b, c) STR(a) "." STR(b) "." STR(c)
|
||||
#define VERSION VERSIONSTRING(VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO) BUILDID
|
||||
// PUREVERSION should identify the build uniquely. Use version string for now.
|
||||
#define PUREVERSION "$Rev$"
|
||||
#define PUREVERSION GITHASH
|
||||
|
||||
#define FULLVERSION VERSION " (" PUREVERSION "), built " __DATE__ " " __TIME__
|
||||
#define FULLVERSION VERSION " (" GITHASH "), built " __DATE__ " " __TIME__
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue