Change how version strings are generated.
Git is always used to generate the KiCad version string using the command `git describe --dirty`. This gives a more concise and accurate version string than the previous method. When git is not available, the version string defaults to the value defined in KiCadVersion.cmake. It is imperative that moving forward that the default version string be updated the commit following a git tag so that when git is not available, the last known commit following a git tag will at least give some usable information about which development branch of KiCad was used for a build.
This commit is contained in:
parent
c95340fbaf
commit
a2df82537b
|
@ -1,8 +1,8 @@
|
|||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2010-2016 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2010 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2010-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -23,10 +23,6 @@
|
|||
#
|
||||
|
||||
macro( create_git_version_header _git_src_path )
|
||||
# If an error occurs using the git commands to determine the repo
|
||||
# version, set the build version string to "git-error".
|
||||
set( KICAD_GIT_BUILD_VERSION "git-error" )
|
||||
|
||||
# Include Git support to automagically create version header file.
|
||||
find_package( Git )
|
||||
|
||||
|
@ -34,72 +30,24 @@ macro( create_git_version_header _git_src_path )
|
|||
set( _Git_SAVED_LC_ALL "$ENV{LC_ALL}" )
|
||||
set( ENV{LC_ALL} C )
|
||||
|
||||
# Get latest commit hash
|
||||
# Use `git describe --dirty` to create the KiCad version string.
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} --no-pager log -1 HEAD
|
||||
--pretty=format:%H
|
||||
${GIT_EXECUTABLE} describe --dirty
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_LONG_HASH
|
||||
OUTPUT_VARIABLE _git_DESCRIBE
|
||||
ERROR_VARIABLE _git_log_error
|
||||
RESULT_VARIABLE _git_log_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if( ${_git_log_result} EQUAL 0 )
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} --no-pager log -1 HEAD
|
||||
--pretty=format:%h
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_SHORT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} --no-pager log -1 HEAD
|
||||
--pretty=format:%cn
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_LAST_COMITTER
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} --no-pager log -1 HEAD
|
||||
--pretty=format:%cd --date=short
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_LAST_CHANGE_LOG
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(STATUS "Git hash: ${_git_LONG_HASH}")
|
||||
message(STATUS "Git branch: ${_git_BRANCH}")
|
||||
|
||||
if( ${_git_log_result} EQUAL 0 )
|
||||
string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*"
|
||||
"\\2" Kicad_REPO_REVISION "revision ${_git_SHORT_HASH}" )
|
||||
string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*"
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_git_LAST_COMITTER}")
|
||||
string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*"
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_DATE "${_git_LAST_CHANGE_LOG}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set( ENV{LC_ALL} ${_Git_SAVED_LC_ALL} )
|
||||
endif( GIT_FOUND )
|
||||
|
||||
# Check to make sure 'git' command did not fail. Otherwise fallback
|
||||
# to "no-git" as the revision.
|
||||
if( Kicad_REPO_LAST_CHANGED_DATE )
|
||||
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3"
|
||||
_kicad_git_date ${Kicad_REPO_LAST_CHANGED_DATE} )
|
||||
set( KICAD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
|
||||
set( KICAD_BRANCH_NAME ${_git_BRANCH} )
|
||||
# to KiCadVersion.cmake as the revision level.
|
||||
if( _git_DESCRIBE )
|
||||
set( KICAD_VERSION "(${_git_DESCRIBE})" )
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2016 - 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -29,9 +29,10 @@
|
|||
# releases is a shooting offense.
|
||||
#
|
||||
# This file gets included in the WriteVersionHeader.cmake file to set
|
||||
# the KiCad version when the source is provided in an archive file.
|
||||
# When KiCad is cloned using git, the git version is used. The only
|
||||
# time this should be set to a value other than "no-vcs-found" is when
|
||||
# a source archive is created. This eliminates the need to set
|
||||
# KICAD_VERSION during the build configuration step.
|
||||
set( KICAD_VERSION "no-vcs-found" )
|
||||
# the default KiCad version when the source is provided in an archive
|
||||
# file or git is not available on the build system. When KiCad is
|
||||
# cloned using git, the git version is used. This version string should
|
||||
# be set after each version tag is added to the git repo. This will
|
||||
# give developers a reasonable idea where which branch was used to build
|
||||
# KiCad.
|
||||
set( KICAD_VERSION "5.0-dev-unknown" )
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -23,28 +23,20 @@
|
|||
#
|
||||
|
||||
# Automagically create version header file if the version string was
|
||||
# not defined during the build configuration. If
|
||||
# CreateGitVersionHeader cannot determine the current repo version, a
|
||||
# version.h file is still created with KICAD_VERSION set to "no-vcs-found".
|
||||
# not defined during the build configuration. If CreateGitVersionHeader
|
||||
# cannot determine the current repo version, a version.h file is still
|
||||
# created with KICAD_VERSION set in KiCadVersion.cmake.
|
||||
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
|
||||
# Attempt to detect if we have a git repo and set the version string if
|
||||
# the version wasn't set to something other than the default value in
|
||||
# KiCadVersion.cmake.
|
||||
if( KICAD_VERSION STREQUAL "no-vcs-found" AND EXISTS "${SRC_PATH}/.git" )
|
||||
message( STATUS "Using Git to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
|
||||
create_git_version_header( ${SRC_PATH} )
|
||||
endif()
|
||||
# Always use git if it's available to determine the version string.
|
||||
message( STATUS "Using Git to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
|
||||
create_git_version_header( ${SRC_PATH} )
|
||||
|
||||
# $KICAD_VERSION_FULL will always be set to something. Even if it is "no-vcs-found".
|
||||
# $KICAD_VERSION will always be set to something. Even if it is the default
|
||||
# value set in KiCadVersion.cmake
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION}" )
|
||||
|
||||
# Optional branch name detected by git or configuration defined option.
|
||||
if( KICAD_BRANCH_NAME )
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_BRANCH_NAME}" )
|
||||
endif()
|
||||
|
||||
# Optional user version information defined at configuration.
|
||||
if( KICAD_VERSION_EXTRA )
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_VERSION_EXTRA}" )
|
||||
|
|
Loading…
Reference in New Issue