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:
Ian McInerney 2020-03-07 18:43:24 +00:00
parent 01a6d0067b
commit a2ad9d67ba
5 changed files with 104 additions and 85 deletions

View File

@ -2,7 +2,7 @@
# This program source code file is part of KICAD, a free EDA CAD application. # 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 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 # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # 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 # 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 # give developers a reasonable idea where which branch was used to build
# KiCad. # 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}" )

View File

@ -2,7 +2,7 @@
# This program source code file is part of KICAD, a free EDA CAD application. # 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 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 # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # 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}/KiCadVersion.cmake )
include( ${CMAKE_MODULE_PATH}/KiCadFullVersion.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 set( _wvh_new_version_text
"/* Do not modify this file, it was automatically generated by CMake. */ "/* 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__ #ifndef __KICAD_VERSION_H__
#define __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__ */ #endif /* __KICAD_VERSION_H__ */
" ) " )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,10 +31,6 @@
#include <kicad_build_version.h> #include <kicad_build_version.h>
/**
* Function GetBuildVersion
* Return the build version string.
*/
wxString GetBuildVersion() wxString GetBuildVersion()
{ {
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) ); 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 GetBuildDate()
{ {
wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) ); wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
return msg; 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;
}

View File

@ -567,36 +567,8 @@ std::string SETTINGS_MANAGER::calculateUserSettingsPath( bool aIncludeVer, bool
std::string SETTINGS_MANAGER::GetSettingsVersion() std::string SETTINGS_MANAGER::GetSettingsVersion()
{ {
// A full build version looks like (x.y.z-nnn-g1234567) or x.y.z-xxx // CMake computes the major.minor string for us.
// The string after the major.minor.patch can contain all sorts of other information return GetMajorMinorVersion().ToStdString();
// 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();
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,13 +31,32 @@ class wxString;
/** /**
* Function GetBuildVersion * Get the full KiCad version string. This string contains platform-specific information
* Return the build date and version * added by the packagers. It is created by CMake in the KICAD_FULL_VERSION variable.
*
* @return the full version string
*/ */
wxString GetBuildVersion(); 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 * @return the build date string
*/ */
wxString GetBuildDate(); wxString GetBuildDate();