Minor version string generation improvements.
Remove the KICAD_REPO_NAME option from the main cmake file and the generated config.h file since it is no longer used. Set the default branch name to "undefined" in CreateGitVersionHeader.cmake instead of the KICAD_REPO_NAME option. Remove generating KICAD_FULL_VERSION from CreateGitVersionHeader.cmake and add it to WriteVersionHeader.cmake so that the default settings and the new KiCadVersion.cmake definitions can be used to generate the full version string as well. Check to see if the branch name is set and only use the version to generate the full version string. This allows the use of the KiCad version cmake file to create a version only string like "4.0.4" with no trailing branch name. Change build_version.cpp to use the full version string rather than concatenating the version and branch strings.
This commit is contained in:
parent
1dc747c0ae
commit
9ca6405bcb
|
@ -105,9 +105,6 @@ mark_as_advanced( KICAD_SKIP_BOOST ) # Normal builders should build Boost.
|
|||
option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
|
||||
|
||||
|
||||
# This can be set to a custom name to brag about a particular branch in the "About" dialog:
|
||||
set( KICAD_REPO_NAME "unknown" CACHE STRING "Name of the tree from which this build came." )
|
||||
|
||||
|
||||
# All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they
|
||||
# would have to be downloaded over and over again. The default is to choose a directory that is
|
||||
|
|
|
@ -27,7 +27,7 @@ macro( create_git_version_header _git_src_path )
|
|||
# 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} )
|
||||
set( KICAD_BRANCH_NAME "undefined" )
|
||||
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}")
|
||||
|
||||
# Include Git support to automagically create version header file.
|
||||
|
@ -108,5 +108,4 @@ macro( create_git_version_header _git_src_path )
|
|||
endif()
|
||||
|
||||
set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} )
|
||||
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}")
|
||||
endmacro()
|
||||
|
|
|
@ -22,49 +22,31 @@
|
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#
|
||||
|
||||
# Automagically create version header file if the version string was not defined during
|
||||
# the build configuration. If CreateBzrVersionHeader or CreateGitVersionHeader cannot
|
||||
# determine the current repo version, a version.h file is still created with
|
||||
# KICAD_BUILD_VERSION set to "no-vcs-found".
|
||||
if( NOT KICAD_BUILD_VERSION )
|
||||
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
# 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".
|
||||
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
|
||||
# Detect the appropiate VCS and set the version string.
|
||||
if( EXISTS "${SRC_PATH}/.bzr" )
|
||||
message( STATUS "Using Bazaar to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateBzrVersionHeader.cmake )
|
||||
create_bzr_version_header( ${SRC_PATH} )
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
elseif( 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} )
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
endif()
|
||||
else()
|
||||
# Attempt to detect if we have a git repo and set the version string.
|
||||
if( 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} )
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
endif()
|
||||
|
||||
set( _wvh_write_version_file ON )
|
||||
|
||||
# Compare the version argument against the version in the existing header file for a mismatch.
|
||||
if( EXISTS ${OUTPUT_FILE} )
|
||||
file( STRINGS ${OUTPUT_FILE} _current_version_str
|
||||
REGEX "^#define[\t ]+KICAD_FULL_VERSION[\t ]+.*" )
|
||||
string( REGEX REPLACE "^#define KICAD_FULL_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 ${OUTPUT_FILE}" )
|
||||
set( _wvh_write_version_file OFF )
|
||||
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_BRANCH_NAME )
|
||||
set( KICAD_FULL_VERSION "${_wvh_version_str}-${KICAD_BRANCH_NAME}" )
|
||||
else()
|
||||
set( KICAD_FULL_VERSION "${_wvh_version_str}" )
|
||||
endif()
|
||||
|
||||
if( _wvh_write_version_file )
|
||||
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${_wvh_version_str}" )
|
||||
|
||||
file( WRITE ${OUTPUT_FILE}
|
||||
set( _wvh_new_version_text
|
||||
"/* Do not modify this file, it was automatically generated by CMake. */
|
||||
|
||||
/*
|
||||
|
@ -78,8 +60,23 @@ if( _wvh_write_version_file )
|
|||
#define KICAD_FULL_VERSION \"${KICAD_FULL_VERSION}\"
|
||||
|
||||
#endif /* __KICAD_VERSION_H__ */
|
||||
"
|
||||
)
|
||||
" )
|
||||
|
||||
set( _wvh_write_version_file ON )
|
||||
|
||||
# Only write the header if it has changed, to avoid rebuilds
|
||||
if( EXISTS ${OUTPUT_FILE} )
|
||||
file( READ ${OUTPUT_FILE} _wvh_old_version_text )
|
||||
if( _wvh_old_version_text STREQUAL _wvh_new_version_text )
|
||||
message( STATUS "Not updating ${OUTPUT_FILE}" )
|
||||
set( _wvh_write_version_file OFF )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( _wvh_write_version_file )
|
||||
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${_wvh_version_str}" )
|
||||
|
||||
file( WRITE ${OUTPUT_FILE} ${_wvh_new_version_text} )
|
||||
|
||||
endif()
|
||||
|
||||
|
|
|
@ -77,7 +77,4 @@
|
|||
#define KIFACE_SUFFIX wxT( "@KIFACE_SUFFIX@" )
|
||||
#define KIFACE_PREFIX wxT( "@KIFACE_PREFIX@" )
|
||||
|
||||
/// Name of repo from which this build came.
|
||||
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"
|
||||
|
||||
#endif // CONFIG_H_
|
||||
|
|
|
@ -37,9 +37,8 @@
|
|||
wxString GetBuildVersion()
|
||||
{
|
||||
wxString msg = wxString::Format(
|
||||
wxT( "%s-%s" ),
|
||||
wxT( KICAD_BUILD_VERSION ),
|
||||
wxT( KICAD_BRANCH_NAME )
|
||||
wxT( "%s" ),
|
||||
wxT( KICAD_FULL_VERSION )
|
||||
);
|
||||
|
||||
return msg;
|
||||
|
|
Loading…
Reference in New Issue