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:
parent
4cb084cd63
commit
50a4b5553a
|
@ -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()
|
||||
|
||||
|
|
|
@ -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" )
|
||||
|
|
|
@ -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} )
|
||||
|
||||
|
|
|
@ -151,6 +151,11 @@ supplied by KiCad. This option is disabled by default.
|
|||
The KICAD_SCRIPTING_WXPYTHON option is used to enable building the wxPython interface into
|
||||
Pcbnew including the wxPython console. This option is disabled by default.
|
||||
|
||||
## Github Plugin ## {#github_opt}
|
||||
|
||||
The BUILD_GITHUB_PLUGIN option is used to control if the Github plugin is built. This option is
|
||||
enabled by default.
|
||||
|
||||
## Build with Static Libraries ## {#static_lib_opt}
|
||||
|
||||
The KICAD_BUILD_STATIC option is used to build KiCad with static libraries. This option is
|
||||
|
@ -175,10 +180,30 @@ The USE_OSX_DEPS_BUILDER option forces the build configuration to download and b
|
|||
required dependencies to build KiCad on OSX. This option is not longer maintained and most
|
||||
likely is broken. Use it at your own peril.
|
||||
|
||||
## Github Plugin ## {#github_opt}
|
||||
## Setting the Build Version and Repository Name ## {#build_version_opt}
|
||||
|
||||
The BUILD_GITHUB_PLUGIN option is used to control if the Github plugin is built. This option is
|
||||
enabled by default.
|
||||
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
|
||||
| | |
|
||||
| | 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
|
||||
|
||||
# Getting the KiCad Source Code ## {#getting_src}
|
||||
|
||||
|
|
|
@ -115,17 +115,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}
|
||||
|
|
|
@ -38,7 +38,7 @@ wxString GetBuildVersion()
|
|||
{
|
||||
wxString msg = wxString::Format(
|
||||
wxT( "%s" ),
|
||||
wxT( KICAD_FULL_VERSION )
|
||||
wxT( KICAD_VERSION_FULL )
|
||||
);
|
||||
|
||||
return msg;
|
||||
|
|
Loading…
Reference in New Issue