Version string improvements.

Define empty string variable KICAD_BRANCH_NAME that can be used as an
optional version string element.  When git is used to build the version
string, this variable is set to the git branch name.  It can also be
defined at configuration time as an optional string appended to the
$KICAD_VERSION variable.

Define empty string variable KICAD_VERSION_EXTRA that can be set by
the user at configuration.

The variables KICAD_BRANCH_NAME and KICAD_VERSION_EXTRA are only
appended to KICAD_VERSION if they are set.  Otherwise, only KICAD_VERSION
is uses as the version string.

Update the developer building from source document to reflect the changes.
This commit is contained in:
Wayne Stambaugh 2016-11-24 12:37:34 -05:00
parent 8806fc03dc
commit fd54d394bd
6 changed files with 44 additions and 43 deletions

View File

@ -24,11 +24,8 @@
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 "no-git" and the default
# branch name to unknown
set( KICAD_GIT_BUILD_VERSION "no-git" )
set( KICAD_BRANCH_NAME "undefined" )
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}")
# 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 )
@ -101,7 +98,7 @@ macro( create_git_version_header _git_src_path )
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_GIT_BUILD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
set( KICAD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
set( KICAD_BRANCH_NAME ${_git_BRANCH} )
endif()

View File

@ -33,8 +33,5 @@
# 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_BUILD_VERSION during the build configuration step.
set( _wvh_version_str "no-vcs-found" )
# Set the KiCad branch name to stable for stable source releases.
set( KICAD_BRANCH_NAME "undefined" )
# KICAD_VERSION during the build configuration step.
set( KICAD_VERSION "no-vcs-found" )

View File

@ -25,30 +25,29 @@
# 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_BUILD_VERSION set to
# "no-vcs-found".
# version.h file is still created with KICAD_VERSION set to "no-vcs-found".
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( _wvh_version_str STREQUAL "no-vcs-found" AND EXISTS "${SRC_PATH}/.git" )
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()
# If KICAD_BRANCH_NAME is empty, set KICAD_FULL_VERSION to just the build
# version rather than the concatenation of the build version and the branch
# name.
if( KICAD_BUILD_VERSION AND KICAD_REPO_NAME )
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_REPO_NAME}" )
elseif( KICAD_BUILD_VERSION )
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}" )
elseif( KICAD_BRANCH_NAME AND KICAD_GIT_BUILD_VERSION )
set( KICAD_FULL_VERSION "${KICAD_GIT_BUILD_VERSION}-${KICAD_BRANCH_NAME}" )
else()
set( KICAD_FULL_VERSION "unknown" )
# $KICAD_VERSION_FULL will always be set to something. Even if it is "no-vcs-found".
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}" )
endif()
set( _wvh_new_version_text
@ -60,7 +59,7 @@ set( _wvh_new_version_text
#ifndef __KICAD_VERSION_H__
#define __KICAD_VERSION_H__
#define KICAD_FULL_VERSION \"${KICAD_FULL_VERSION}\"
#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
#endif /* __KICAD_VERSION_H__ */
" )
@ -77,7 +76,7 @@ if( EXISTS ${OUTPUT_FILE} )
endif()
if( _wvh_write_version_file )
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_FULL_VERSION}" )
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_VERSION_FULL}" )
file( WRITE ${OUTPUT_FILE} ${_wvh_new_version_text} )

View File

@ -151,11 +151,11 @@ enabled by default.
## Integrated Spice simulator ## {#spice_opt}
The KICAD_SPICE option is used to control if the Spice simulator interface for eeschema is built. When
The KICAD_SPICE option is used to control if the Spice simulator interface for Eeschema is built. When
this option is enabled, it requires [ngspice][] to be available as a shared library. This option is
disabled by default.
## New schmatic file format ## {#sch_io_mgr_opt}
## New schematic file format ## {#sch_io_mgr_opt}
The KICAD_USE_SCH_IO_MANAGER option is used to control if the new Eeschema I/O manager for handling
schematic and symbol library I/O is enabled. This option is disabled by default.
@ -164,7 +164,7 @@ schematic and symbol library I/O is enabled. This option is disabled by default.
The KICAD_USE_OCE is used for the 3D viewer plugin to support STEP and IGES 3D models. Build tools
and plugins related to OpenCascade Community Edition (OCE) are enabled with this option. When
enabled it requires [OCE][] to be available, and the location of the installed OCE libary to be
enabled it requires [OCE][] to be available, and the location of the installed OCE library to be
passed via the OCE_DIR flag. This option is disabled by default.
## Demos and Examples ## {#demo_install_opt}
@ -176,8 +176,17 @@ $PREFIX/share/kicad/demos by default.
## Setting the Build Version and Repository Name ## {#build_version_opt}
By default, KiCad builds the version string information from the [git][] repository information
as follows:
The KiCad version string is defined by the three CMake variables KICAD_VERSION, KICAD_BRANCH_NAME,
and KICAD_VERSION_EXTRA. Variables KICAD_BRANCH_NAME and KICAD_VERSION_EXTRA are defined as empty
strings and can be set at configuration. Unless the source branch is a stable release archive,
KICAD_VERSION is set to "no-vcs-found". If an optional variable is not define, it is not appended
to the full version string. If an optional variable is defined it is appended along with a leading
'-' to the full version string as follows:
KICAD_VERSION[-KICAD_BRANCH_NAME][-KICAD_VERSION_EXTRA]
When the version string is set to "no-vcs-found", the build script automatically creates the
version string information from the [git][] repository information as follows:
(2016-08-26 revision 67230ac)-master
| | |
@ -189,10 +198,6 @@ as follows:
|
date of commit, or date of build if no .git present
Package developers can set the version string information by using the KICAD_BUILD_VERSION and
KICAD_REPO_NAME configuration variables during CMake configuration for custom versions and
when building from the source archives.
# Getting the KiCad Source Code ## {#getting_src}
There are several ways to get the KiCad source. If you want to build the stable version you

View File

@ -128,17 +128,20 @@ install( TARGETS lib_kicad
endif()
# KiCad build version string defaults to undefined which forces the build version header
# command to look for Bazaar to create the version string header.
set( KICAD_BUILD_VERSION "" CACHE STRING "Version string defined at configuration time." )
set( KICAD_REPO_NAME "" CACHE STRING "KiCad repository name." )
# KiCad build version string defaults to "no-vcs-found" which forces the build version header
# command to look for git to create the version string header when the .git path is found in
# the source path.
set( KICAD_BRANCH_NAME "" CACHE STRING "KiCad repository name." )
set( KICAD_VERSION_EXTRA "" CACHE STRING
"User defined configuration string to append to KiCad version." )
# Generate version header file.
add_custom_target(
version_header ALL
COMMAND ${CMAKE_COMMAND}
-DKICAD_BUILD_VERSION=${KICAD_BUILD_VERSION}
-DKICAD_REPO_NAME=${KICAD_REPO_NAME}
-DKICAD_VERSION=${KICAD_VERSION}
-DKICAD_BRANCH_NAME=${KICAD_BRANCH_NAME}
-DKICAD_VERSION_EXTRA=${KICAD_VERSION_EXTRA}
-DOUTPUT_FILE=${CMAKE_BINARY_DIR}/kicad_build_version.h
-DSRC_PATH=${PROJECT_SOURCE_DIR}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}

View File

@ -38,7 +38,7 @@ wxString GetBuildVersion()
{
wxString msg = wxString::Format(
wxT( "%s" ),
wxT( KICAD_FULL_VERSION )
wxT( KICAD_VERSION_FULL )
);
return msg;