Expose more version strings from CMake
Let cmake generate the needed version strings, so we don't have to spend program time doing it. This simplifies the settings manager versioning. Also, convert some file line endings to UNIX from Windows. A more robust fix for https://gitlab.com/kicad/code/kicad/-/issues/4015.
This commit is contained in:
parent
01a6d0067b
commit
a2ad9d67ba
|
@ -1,38 +1,44 @@
|
|||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2016 - 2019 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
|
||||
#
|
||||
|
||||
# Note: unless you are the person responsible for creating releases,
|
||||
# do *not* change these variables. This way the KiCad project
|
||||
# can maintain control over what is an official KiCad build and
|
||||
# what is not. Setting these variable that conflict with KiCad
|
||||
# releases is a shooting offense.
|
||||
#
|
||||
# This file gets included in the WriteVersionHeader.cmake file to set
|
||||
# the default KiCad version when the source is provided in an archive
|
||||
# file or git is not available on the build system. When KiCad is
|
||||
# cloned using git, the git version is used. This version string should
|
||||
# be set after each version tag is added to the git repo. This will
|
||||
# give developers a reasonable idea where which branch was used to build
|
||||
# KiCad.
|
||||
set( KICAD_VERSION "5.99.0-unknown" )
|
||||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2016-2020 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
|
||||
#
|
||||
|
||||
# Note: unless you are the person responsible for creating releases,
|
||||
# do *not* change these variables. This way the KiCad project
|
||||
# can maintain control over what is an official KiCad build and
|
||||
# what is not. Setting these variable that conflict with KiCad
|
||||
# releases is a shooting offense.
|
||||
#
|
||||
# This file gets included in the WriteVersionHeader.cmake file to set
|
||||
# the default KiCad version when the source is provided in an archive
|
||||
# file or git is not available on the build system. When KiCad is
|
||||
# cloned using git, the git version is used. This version string should
|
||||
# be set after each version tag is added to the git repo. This will
|
||||
# give developers a reasonable idea where which branch was used to build
|
||||
# KiCad.
|
||||
#
|
||||
# Note: This version string should follow the semantic versioning system
|
||||
set( KICAD_SEMANTIC_VERSION "5.99.0-unknown" )
|
||||
|
||||
# Default the version to the semantic version.
|
||||
# This is overriden by the git repository tag though (if using git)
|
||||
set( KICAD_VERSION "${KICAD_SEMANTIC_VERSION}" )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
# Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2015-2020 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
|
||||
|
@ -26,16 +26,33 @@
|
|||
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
include( ${CMAKE_MODULE_PATH}/KiCadFullVersion.cmake )
|
||||
|
||||
# Extract the major and minor build version as a string
|
||||
string( REGEX MATCH
|
||||
"([0-9]+\\.[0-9]+)\\..*"
|
||||
KICAD_MAJOR_MINOR_VERSION
|
||||
"${KICAD_SEMANTIC_VERSION}"
|
||||
)
|
||||
|
||||
if( CMAKE_MATCH_COUNT EQUAL 1 )
|
||||
# Match slot 0 is the full string, so we want slot 1
|
||||
set( KICAD_MAJOR_MINOR_VERSION "${CMAKE_MATCH_1}" )
|
||||
else()
|
||||
message( FATAL_ERROR "Unable to extract major and minor version string" )
|
||||
endif()
|
||||
|
||||
|
||||
set( _wvh_new_version_text
|
||||
"/* Do not modify this file, it was automatically generated by CMake. */
|
||||
|
||||
/*
|
||||
* Define the KiCad build version string.
|
||||
* Define the KiCad build version strings.
|
||||
*/
|
||||
#ifndef __KICAD_VERSION_H__
|
||||
#define __KICAD_VERSION_H__
|
||||
|
||||
#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
|
||||
#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
|
||||
#define KICAD_SEMANTIC_VERSION \"${KICAD_SEMANTIC_VERSION}\"
|
||||
#define KICAD_MAJOR_MINOR_VERSION \"${KICAD_MAJOR_MINOR_VERSION}\"
|
||||
|
||||
#endif /* __KICAD_VERSION_H__ */
|
||||
" )
|
||||
|
|
|
@ -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-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 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
|
||||
|
@ -31,10 +31,6 @@
|
|||
#include <kicad_build_version.h>
|
||||
|
||||
|
||||
/**
|
||||
* Function GetBuildVersion
|
||||
* Return the build version string.
|
||||
*/
|
||||
wxString GetBuildVersion()
|
||||
{
|
||||
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
|
||||
|
@ -42,13 +38,22 @@ wxString GetBuildVersion()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function GetBuildDate
|
||||
* @return the build date string
|
||||
*
|
||||
*/
|
||||
wxString GetBuildDate()
|
||||
{
|
||||
wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
wxString GetSemanticVersion()
|
||||
{
|
||||
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
wxString GetMajorMinorVersion()
|
||||
{
|
||||
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -567,36 +567,8 @@ std::string SETTINGS_MANAGER::calculateUserSettingsPath( bool aIncludeVer, bool
|
|||
|
||||
std::string SETTINGS_MANAGER::GetSettingsVersion()
|
||||
{
|
||||
// A full build version looks like (x.y.z-nnn-g1234567) or x.y.z-xxx
|
||||
// The string after the major.minor.patch can contain all sorts of other information
|
||||
// We want to extract the x.y portion here
|
||||
wxString version = GetBuildVersion();
|
||||
|
||||
if( version.StartsWith( '(' ) )
|
||||
version = version.Mid( 1 );
|
||||
|
||||
// Trim everything starting from the second '.'
|
||||
|
||||
size_t mid = 0;
|
||||
int found = 0;
|
||||
|
||||
while( found < 2 && mid < version.size() )
|
||||
{
|
||||
if( version[mid] == '.' )
|
||||
found++;
|
||||
|
||||
if( found == 2 )
|
||||
{
|
||||
version = version.SubString( 0, mid - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
mid++;
|
||||
}
|
||||
|
||||
wxASSERT( version.Find( '.' ) != wxNOT_FOUND );
|
||||
|
||||
return version.ToStdString();
|
||||
// CMake computes the major.minor string for us.
|
||||
return GetMajorMinorVersion().ToStdString();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 1992-2020 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
|
||||
|
@ -31,13 +31,32 @@ class wxString;
|
|||
|
||||
|
||||
/**
|
||||
* Function GetBuildVersion
|
||||
* Return the build date and version
|
||||
* Get the full KiCad version string. This string contains platform-specific information
|
||||
* added by the packagers. It is created by CMake in the KICAD_FULL_VERSION variable.
|
||||
*
|
||||
* @return the full version string
|
||||
*/
|
||||
wxString GetBuildVersion();
|
||||
|
||||
/**
|
||||
* Function GetBuildDate
|
||||
* Get the semantic version string for KiCad defined inside the KiCadVersion.cmake file in
|
||||
* the variable KICAD_SEMANTIC_VERSION.
|
||||
*
|
||||
* @return the semantic version string
|
||||
*/
|
||||
wxString GetSemanticVersion();
|
||||
|
||||
/**
|
||||
* Get only the major and minor version in a string major.minor.
|
||||
* This is extracted by CMake from the KICAD_SEMANTIC_VERSION variable.
|
||||
*
|
||||
* @return the major and minor version as a string
|
||||
*/
|
||||
wxString GetMajorMinorVersion();
|
||||
|
||||
/**
|
||||
* Get the build date as a string.
|
||||
*
|
||||
* @return the build date string
|
||||
*/
|
||||
wxString GetBuildDate();
|
||||
|
|
Loading…
Reference in New Issue