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
|
@ -2,7 +2,7 @@
|
|||
# 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.
|
||||
# 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
|
||||
|
@ -35,4 +35,10 @@
|
|||
# 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" )
|
||||
#
|
||||
# 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_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