Update version string formatting after git migration

It is no longer necessary (or sensible) to include a simulated bzr
revision number, and we can reliably get a branch name now. Therefore,
the new version strings look like:

(2016-08-26 revision 67230ac)-master
 |                   |        |
 |                   |        branch name, "HEAD" if not on a branch,
 |                   |          or "unknown" if no .git present
 |                   |
 |                   abbreviated commit hash, or no-git if no .git
 |                     present
 |
 date of commit, or date of build if no .git present

Signed-off-by: Chris Pavlina <pavlina.chris@gmail.com>
This commit is contained in:
Chris Pavlina 2016-08-27 11:08:07 -04:00
parent cc3a93b2d7
commit 7318238daa
4 changed files with 39 additions and 11 deletions

View File

@ -1,3 +1,25 @@
#
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2007-2016 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
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you may find one here:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# or you may search the http://www.gnu.org website for the version 2 license,
# or you may write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
# Default to CMAKE_BUILD_TYPE = Release unless overridden on command line
# http://www.cmake.org/pipermail/cmake/2008-September/023808.html
@ -66,7 +88,7 @@ option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
option( KICAD_SPICE "Build Kicad with internal Spice simulator." OFF )
# This can be set to a custom name to brag about a particular branch in the "About" dialog:
set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this build came." )
set( KICAD_REPO_NAME "unknown" CACHE STRING "Name of the tree from which this build came." )
# Global setting: exports are explicit

View File

@ -2,7 +2,7 @@
# 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-2015 Kicad Developers, see AUTHORS.txt for contributors.
# Copyright (C) 2010-2016 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,9 +23,11 @@
#
macro( create_git_version_header _git_src_path )
# If bzr is not found or an error occurs using the git commands to determine the repo
# version, set the build version string to "no-git"
# If an error occurs using the git commands to determine the repo
# version, set the build version string to "no-git" and the default
# branch name to unknown
set( KICAD_BUILD_VERSION "no-git" )
set( KICAD_BRANCH_NAME ${KICAD_REPO_NAME} )
# Include Git support to automagically create version header file.
find_package( Git )
@ -72,17 +74,17 @@ macro( create_git_version_header _git_src_path )
execute_process(
COMMAND
${GIT_EXECUTABLE} rev-list HEAD --count
--first-parent
${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${_git_src_path}
OUTPUT_VARIABLE _git_SERIAL
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 "BZR ${_git_SERIAL}, Git ${_git_SHORT_HASH}" )
"\\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]+).*"
@ -99,6 +101,9 @@ macro( create_git_version_header _git_src_path )
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3"
_kicad_git_date ${Kicad_REPO_LAST_CHANGED_DATE} )
set( KICAD_BUILD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
if( NOT "${KICAD_REPO_NAME}" STREQUAL "unknown" )
set( KICAD_BRANCH_NAME ${_git_BRANCH} )
endif()
endif()
set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} )

View File

@ -2,7 +2,7 @@
# 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 KiCad Developers, see AUTHORS.txt for contributors.
# Copyright (C) 2015-2016 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
@ -74,6 +74,7 @@ if( _wvh_write_version_file )
#define __KICAD_VERSION_H__
#define KICAD_BUILD_VERSION \"${_wvh_version_str}\"
#define KICAD_BRANCH_NAME \"${KICAD_BRANCH_NAME}\"
#endif /* __KICAD_VERSION_H__ */
"

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2015-2016 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
@ -39,7 +39,7 @@ wxString GetBuildVersion()
wxString msg = wxString::Format(
wxT( "%s-%s" ),
wxT( KICAD_BUILD_VERSION ),
wxT( KICAD_REPO_NAME )
wxT( KICAD_BRANCH_NAME )
);
return msg;