Avoid rebuilding with each commit

We shouldn't include the kicad_build_info.h outside of the wrapper
build_info.h.  Also adds an error directive to prevent re-introduction
of define dependencies
This commit is contained in:
Seth Hillbrand 2023-01-03 13:54:20 -08:00
parent 7c0b6c1e87
commit 98d55ce82f
10 changed files with 108 additions and 43 deletions

View File

@ -67,6 +67,10 @@ set( _wvh_new_version_text
#ifndef __KICAD_VERSION_H__
#define __KICAD_VERSION_H__
#ifndef INCLUDE_KICAD_VERSION
#error Do not include kicad_build_version.h directly. Include build_version.h instead.
#endif
#define KICAD_COMMIT_HASH \"${KICAD_COMMIT_HASH}\"
#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
#define KICAD_SEMANTIC_VERSION \"${KICAD_SEMANTIC_VERSION}\"

View File

@ -29,6 +29,8 @@
#include <kiplatform/app.h>
#include <font/outline_font.h>
#include <tuple>
// kicad_curl.h must be included before wx headers, to avoid
// conflicts for some defines, at least on Windows
// kicad_curl.h can create conflicts for some defines, at least on Windows
@ -46,8 +48,9 @@ extern std::string GetCurlLibVersion();
// The include file version.h is always created even if the repo version cannot be
// determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
// that is set in KiCadVersion.cmake.
#define INCLUDE_KICAD_VERSION
#include <kicad_build_version.h>
#undef INCLUDE_KICAD_VERSION
wxString GetPlatformGetBitnessName()
{
@ -65,6 +68,12 @@ wxString GetPlatformGetBitnessName()
}
bool IsNightlyVersion()
{
return !!KICAD_IS_NIGHTLY;
}
wxString GetBuildVersion()
{
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
@ -93,6 +102,27 @@ wxString GetMajorMinorVersion()
}
wxString GetCommitHash()
{
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
return msg;
}
wxString GetMajorMinorPatchVersion()
{
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
return msg;
}
const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
{
static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
return retval;
}
wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
{
wxString aMsg;

View File

@ -26,7 +26,7 @@
#include <config.h>
#include <string>
#include <kicad_build_version.h>
#include <build_version.h>
#include <wx/clipbrd.h>
#include <wx/msgdlg.h>
@ -79,11 +79,12 @@ DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo )
else
{
wxIcon icon;
#if KICAD_IS_NIGHTLY
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
#else
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
#endif
if( IsNightlyVersion() )
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
else
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
SetIcon( icon );
m_bitmapApp->SetBitmap( icon );
}

View File

@ -68,7 +68,7 @@
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <sentry.h>
#include <kicad_build_version.h>
#include <build_version.h>
#endif
/**
@ -325,11 +325,10 @@ void PGM_BASE::sentryInit()
sentry_options_set_symbolize_stacktraces( options, true );
sentry_options_set_auto_session_tracking( options, false );
#if !KICAD_IS_NIGHTLY
sentry_options_set_release( options, KICAD_SEMANTIC_VERSION );
#else
sentry_options_set_release( options, KICAD_COMMIT_HASH );
#endif
if( IsNightlyVersion() )
sentry_options_set_release( options, GetSemanticVersion().ToStdString().c_str() );
else
sentry_options_set_release( options, GetCommitHash().ToStdString().c_str() );
sentry_init( options );
@ -337,7 +336,7 @@ void PGM_BASE::sentryInit()
sentry_value_set_by_key( user, "id", sentry_value_new_string( m_sentryUid.c_str() ) );
sentry_set_user( user );
sentry_set_tag( "kicad.version", KICAD_VERSION_FULL );
sentry_set_tag( "kicad.version", GetBuildVersion().ToStdString().c_str() );
}
}

View File

@ -27,8 +27,9 @@
#ifndef KICAD_BUILD_VERSION_H
#define KICAD_BUILD_VERSION_H
class wxString;
#include <tuple>
class wxString;
/**
* Get the full KiCad version string. This string contains platform-specific information
@ -59,6 +60,14 @@ wxString GetSemanticVersion();
*/
wxString GetMajorMinorVersion();
/**
* Get the major, minor and patch version in a string major.minor.patch
* This is extracted by CMake from the KICAD_SEMANTIC_VERSION variable.
*
* @return the major.minor.patch version as a string
*/
wxString GetMajorMinorPatchVersion();
/**
* Get the build date as a string.
*
@ -66,6 +75,25 @@ wxString GetMajorMinorVersion();
*/
wxString GetBuildDate();
/**
* Get the commit hash as a string.
*
* @return the commit hash string
*/
wxString GetCommitHash();
/**
* Get the build version numbers as a tuple
*
* @return A tuple with three ints for major/minor/patch revisions
*/
const std::tuple<int,int,int>& GetMajorMinorPatchTuple();
/**
* Check if the build is meant to be nightly
* @return true if running nightly build
*/
bool IsNightlyVersion();
/**
* Create a version info string for bug reports and the about dialog

View File

@ -21,7 +21,7 @@
#include "command_version.h"
#include <cli/exit_codes.h>
#include <wx/crt.h>
#include <kicad_build_version.h>
#include <build_version.h>
#include <macros.h>
#include <build_version.h>
@ -41,11 +41,11 @@ int CLI::VERSION_COMMAND::doPerform( KIWAY& aKiway )
wxString format = FROM_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );
if( format == wxS( "plain" ) )
{
wxPrintf( KICAD_MAJOR_MINOR_PATCH_VERSION );
wxPrintf( GetMajorMinorPatchVersion() );
}
else if( format == wxS( "commit" ) )
{
wxPrintf( KICAD_COMMIT_HASH );
wxPrintf( GetCommitHash() );
}
else if( format == wxS( "about" ) )
{
@ -59,4 +59,4 @@ int CLI::VERSION_COMMAND::doPerform( KIWAY& aKiway )
}
return 0;
}
}

View File

@ -43,7 +43,7 @@
#include "pgm_kicad.h"
#include "kicad_manager_frame.h"
#include <kicad_build_version.h>
#include <build_version.h>
#include <kiplatform/app.h>
#include <kiplatform/environment.h>
@ -289,7 +289,7 @@ bool PGM_KICAD::OnPgmInit()
int PGM_KICAD::OnPgmRun()
{
argparse::ArgumentParser argParser( std::string( "kicad-cli" ), KICAD_MAJOR_MINOR_VERSION,
argparse::ArgumentParser argParser( std::string( "kicad-cli" ), GetMajorMinorVersion().ToStdString(),
argparse::default_arguments::none );
argParser.add_argument( "-v", ARG_VERSION )

View File

@ -40,7 +40,7 @@
#include <gestfich.h>
#include <kiplatform/app.h>
#include <kiplatform/policy.h>
#include <kicad_build_version.h>
#include <build_version.h>
#include <kiway.h>
#include <kiway_express.h>
#include <launch_ext.h>
@ -141,21 +141,24 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
wxIcon icon;
wxIconBundle icon_bundle;
#if KICAD_IS_NIGHTLY
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
icon_bundle.AddIcon( icon );
#else
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
icon_bundle.AddIcon( icon );
#endif
if( IsNightlyVersion())
{
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
icon_bundle.AddIcon( icon );
}
else
{
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
icon_bundle.AddIcon( icon );
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
icon_bundle.AddIcon( icon );
}
SetIcons( icon_bundle );

View File

@ -24,7 +24,7 @@
#include <kicad_curl/kicad_curl.h>
#include "core/wx_stl_compat.h"
#include "kicad_build_version.h"
#include "build_version.h"
#include "paths.h"
#include "pcm.h"
#include "pgm_base.h"
@ -45,7 +45,7 @@
const std::tuple<int, int, int> PLUGIN_CONTENT_MANAGER::m_kicad_version =
KICAD_MAJOR_MINOR_PATCH_TUPLE;
GetMajorMinorPatchTuple();
class THROWING_ERROR_HANDLER : public nlohmann::json_schema::error_handler
@ -199,7 +199,7 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER(
PACKAGE_VERSION version;
version.version = "0.0";
version.status = PVS_STABLE;
version.kicad_version = KICAD_MAJOR_MINOR_VERSION;
version.kicad_version = GetMajorMinorVersion();
entry.package.versions.emplace_back( version );

View File

@ -24,15 +24,15 @@
#pragma SWIG nowarn=305
%include kicad_build_version.h
%include build_version.h
%pythoncode
%{
def Version():
"""Return the semantic version of KiCad"""
return KICAD_SEMANTIC_VERSION
return GetSemanticVersion()
def FullVersion():
"""Return the full, git-based version of KiCad"""
return KICAD_VERSION_FULL
return GetBuildVersion()
%}