Minor version string generation changes.
* Fix CMake macro create_bzr_version_header to always update version.h file whenever a repo change is found. Running `make rebuild_cache is no longer required. * Add new CMake function for writing version.h file. * Always use version.h file for build version string instead of meaningless hard coded date. * Only use bzr version string when build version is not defined at configuration time for stable release version strings. * Minor cleanup of FindBazaar.cmake. * Remove unnecessary version.h.cmake file.
This commit is contained in:
parent
c1bbf3ecb4
commit
9d69b73b85
|
@ -685,10 +685,16 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
|||
|
||||
endif()
|
||||
|
||||
|
||||
# Automagically create version header file.
|
||||
# Automagically create version header file if the version string was not defined during
|
||||
# the build configuration. If CreateBzrVersionHeader cannot determine the current repo,
|
||||
# version, a version.h file is still created with KICAD_BUILD_VERSION set to "no-bzr".
|
||||
if( KICAD_BUILD_VERSION )
|
||||
include( WriteVersionHeader )
|
||||
write_version_header( ${KICAD_BUILD_VERSION} )
|
||||
else()
|
||||
include( CreateBzrVersionHeader )
|
||||
create_bzr_version_header()
|
||||
endif()
|
||||
|
||||
if( EXISTS ${CMAKE_SOURCE_DIR}/include/config.h )
|
||||
# This file may exist ( created by an alternate process to the svn test above),
|
||||
|
|
|
@ -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 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2010-2015 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
|
||||
|
@ -22,7 +22,13 @@
|
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#
|
||||
|
||||
include( WriteVersionHeader )
|
||||
|
||||
macro( create_bzr_version_header )
|
||||
# If bzr is not found or an error occurs using the bzr commands to determine the repo
|
||||
# version, set the build version string to "no-bzr"
|
||||
set( KICAD_BUILD_VERSION "no-bzr" )
|
||||
|
||||
# Include Bazaar support to automagically create version header file.
|
||||
find_package( Bazaar )
|
||||
|
||||
|
@ -30,53 +36,42 @@ macro( create_bzr_version_header )
|
|||
set( _Bazaar_SAVED_LC_ALL "$ENV{LC_ALL}" )
|
||||
set( ENV{LC_ALL} C )
|
||||
|
||||
# Get the tree revison
|
||||
execute_process( COMMAND
|
||||
${Bazaar_EXECUTABLE} revno --tree ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE _bazaar_TREE_DATE
|
||||
# Get the tree revision
|
||||
execute_process(
|
||||
COMMAND ${Bazaar_EXECUTABLE} revno --tree ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE _bzr_TREE_DATE
|
||||
RESULT_VARIABLE _bzr_revno_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
|
||||
if( ${_bzr_revno_result} EQUAL 0 )
|
||||
# Get more info about that revision
|
||||
execute_process( COMMAND
|
||||
${Bazaar_EXECUTABLE} log -r${_bazaar_TREE_DATE} ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE _bazaar_LAST_CHANGE_LOG
|
||||
ERROR_VARIABLE _bazaar_log_error
|
||||
RESULT_VARIABLE _bazaar_log_result
|
||||
execute_process(
|
||||
COMMAND ${Bazaar_EXECUTABLE} log -r${_bzr_TREE_DATE} ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE _bzr_LAST_CHANGE_LOG
|
||||
ERROR_VARIABLE _bzr_log_error
|
||||
RESULT_VARIABLE _bzr_log_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
|
||||
if( NOT ${_bzr_log_result} EQUAL 0 )
|
||||
message(STATUS "Using <build_version.h> for version string.")
|
||||
else( NOT ${_bzr_log_result} EQUAL 0 )
|
||||
if( ${_bzr_log_result} EQUAL 0 )
|
||||
string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*"
|
||||
"\\2" Kicad_REPO_REVISION "${_bazaar_LAST_CHANGE_LOG}" )
|
||||
"\\2" Kicad_REPO_REVISION "${_bzr_LAST_CHANGE_LOG}" )
|
||||
string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*"
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_bazaar_LAST_CHANGE_LOG}" )
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_bzr_LAST_CHANGE_LOG}" )
|
||||
string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*"
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_DATE "${_bazaar_LAST_CHANGE_LOG}" )
|
||||
endif( NOT ${_bzr_log_result} EQUAL 0 )
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_DATE "${_bzr_LAST_CHANGE_LOG}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set( ENV{LC_ALL} ${_Bazaar_SAVED_LC_ALL} )
|
||||
endif( Bazaar_FOUND )
|
||||
endif()
|
||||
|
||||
# Check to make sure 'bzr log' command did not fail. Otherwise fallback
|
||||
# to version strings defined in "<kicad-src-dir>/include/build_version.h".
|
||||
# Check to make sure 'bzr log' command did not fail. Otherwise, default
|
||||
# to "no-bzr" as the revision.
|
||||
if( Kicad_REPO_LAST_CHANGED_DATE )
|
||||
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3"
|
||||
_kicad_bzr_date ${Kicad_REPO_LAST_CHANGED_DATE} )
|
||||
set( KICAD_BUILD_VERSION "(${_kicad_bzr_date} BZR ${Kicad_REPO_REVISION})" )
|
||||
endif()
|
||||
|
||||
# Definition to conditionally use date and revision returned from the
|
||||
# Bazaar log command instead of hand coded date and revision in
|
||||
# "include/build_version.h". If Bazaar is not found then the date
|
||||
# and version information must be manually edited.
|
||||
# Directive means bzr build, program version and build version will
|
||||
# reflect this.
|
||||
add_definitions( -DHAVE_SVN_VERSION )
|
||||
|
||||
# Generate version.h.
|
||||
configure_file( ${CMAKE_SOURCE_DIR}/CMakeModules/version.h.cmake
|
||||
${CMAKE_BINARY_DIR}/version.h)
|
||||
|
||||
message( STATUS "Kicad Bazaar build version: ${KICAD_BUILD_VERSION}")
|
||||
endif(Kicad_REPO_LAST_CHANGED_DATE)
|
||||
endmacro(create_bzr_version_header)
|
||||
write_version_header( ${KICAD_BUILD_VERSION} )
|
||||
endmacro()
|
||||
|
|
|
@ -64,18 +64,18 @@ if( Bazaar_EXECUTABLE )
|
|||
string( REGEX REPLACE "^[\n]*Bazaar \\(bzr\\) ([0-9.a-z]+).*"
|
||||
"\\1" Bazaar_VERSION "${_bzr_version_output}" )
|
||||
message( STATUS "Bazaar version control system version ${Bazaar_VERSION} found." )
|
||||
endif( ${_bzr_version_result} EQUAL 0 )
|
||||
endif()
|
||||
|
||||
# restore the previous LC_ALL
|
||||
set( ENV{LC_ALL} ${_Bazaar_SAVED_LC_ALL} )
|
||||
endif( Bazaar_EXECUTABLE )
|
||||
endif()
|
||||
|
||||
if( NOT Bazaar_FOUND )
|
||||
if( NOT Bazaar_FIND_QUIETLY )
|
||||
message( STATUS "Bazaar version control command line client was not found." )
|
||||
else( NOT Bazaar_FIND_QUIETLY )
|
||||
else()
|
||||
if( Bazaar_FIND_REQUIRED )
|
||||
message( FATAL_ERROR "Bazaar version control command line client was not found." )
|
||||
endif( Bazaar_FIND_REQUIRED )
|
||||
endif( NOT Bazaar_FIND_QUIETLY )
|
||||
endif( NOT Bazaar_FOUND )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
function( write_version_header _wvh_version_str_arg )
|
||||
|
||||
if( NOT ${_wvh_version_str_arg} )
|
||||
set( _wvh_version_str ${_wvh_version_str_arg} )
|
||||
else()
|
||||
set( _wvh_version_str "undefined" )
|
||||
endif()
|
||||
|
||||
set( _wvh_write_version_file ON )
|
||||
|
||||
# Compare the version argument against the version in the existing header file for a mismatch.
|
||||
if( EXISTS ${CMAKE_BINARY_DIR}/version.h )
|
||||
file( STRINGS ${CMAKE_BINARY_DIR}/version.h _current_version_str
|
||||
REGEX "^#define[\t ]+KICAD_BUILD_VERSION[\t ]+.*" )
|
||||
string( REGEX REPLACE "^#define KICAD_BUILD_VERSION \"([()a-zA-Z0-9 -.]+)\".*"
|
||||
"\\1" _wvh_last_version "${_current_version_str}" )
|
||||
|
||||
# No change, do not write version.h
|
||||
if( _wvh_version_str STREQUAL _wvh_last_version )
|
||||
message( STATUS "Not updating ${CMAKE_BINARY_DIR}/version.h" )
|
||||
set( _wvh_write_version_file OFF )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( _wvh_write_version_file )
|
||||
message( STATUS "Writing version.h file with version: ${_wvh_version_str}" )
|
||||
|
||||
file( WRITE ${CMAKE_BINARY_DIR}/version.h
|
||||
"/* Do not modify this file, it was automatically generated by CMake. */
|
||||
|
||||
/*
|
||||
* Define the KiCad build version string.
|
||||
*/
|
||||
#ifndef __KICAD_VERSION_H__
|
||||
#define __KICAD_VERSION_H__
|
||||
|
||||
#define KICAD_BUILD_VERSION \"${_wvh_version_str}\"
|
||||
|
||||
#endif /* __KICAD_VERSION_H__ */
|
||||
"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# There should always be a valid version.h file. Otherwise, the build will fail.
|
||||
if( NOT EXISTS ${CMAKE_BINARY_DIR}/version.h )
|
||||
message( FATAL_ERROR "Configuration failed to write file ${CMAKE_BINARY_DIR}/version.h." )
|
||||
endif()
|
||||
endfunction()
|
|
@ -25,17 +25,14 @@
|
|||
/* Date for KiCad build version */
|
||||
#include <fctsys.h>
|
||||
|
||||
#ifdef HAVE_SVN_VERSION
|
||||
#include <version.h> // define the KICAD_BUILD_VERSION
|
||||
#endif
|
||||
// The include file version.h is always created even if the repo version cannot be
|
||||
// determined. In this case KICAD_BUILD_VERSION will default to "no-bzr".
|
||||
#include <version.h>
|
||||
|
||||
#ifndef KICAD_BUILD_VERSION
|
||||
# define KICAD_BUILD_VERSION "(after 2015-may-25 BZR unknown)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function GetBuildVersion
|
||||
* Return the build date and version
|
||||
* Return the build version string.
|
||||
*/
|
||||
wxString GetBuildVersion()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue