KiCad PCB EDA Suite
Loading...
Searching...
No Matches
build_version.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25// Date for KiCad build version
26#include <wx/wx.h>
27#include <config.h>
28#include <boost/version.hpp>
29#include <kiplatform/app.h>
30#include <font/version_info.h>
31#include <build_version.h>
32
33#include <tuple>
34
35// kicad_curl.h must be included before wx headers, to avoid
36// conflicts for some defines, at least on Windows
37// kicad_curl.h can create conflicts for some defines, at least on Windows
38// so we are using here 2 proxy functions to know Curl version to avoid
39// including kicad_curl.h to know Curl version
40extern std::string GetKicadCurlVersion();
41extern std::string GetCurlLibVersion();
42
43#include <Standard_Version.hxx>
44
45#include <ngspice/sharedspice.h>
46
47// The include file version.h is always created even if the repo version cannot be
48// determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
49// that is set in KiCadVersion.cmake.
50#define INCLUDE_KICAD_VERSION
51#include <kicad_build_version.h>
52#undef INCLUDE_KICAD_VERSION
53
55{
56 wxPlatformInfo platform;
57 return platform.GetBitnessName();
58}
59
60
62{
63 return !!KICAD_IS_NIGHTLY;
64}
65
66
68{
69 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
70 return msg;
71}
72
73
75{
76 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION ) );
77 return msg;
78}
79
80
81wxString GetBuildDate()
82{
83 wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
84 return msg;
85}
86
87
89{
90 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
91 return msg;
92}
93
94
96{
97 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
98 return msg;
99}
100
101
103{
104 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
105 return msg;
106}
107
108
110{
111 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
112 return msg;
113}
114
115const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
116{
117 static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
118
119 return retval;
120}
121
122
123wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
124{
125 wxString aMsg;
126 // DO NOT translate information in the msg_version string
127
128 wxString eol = aHtml ? "<br>" : "\n";
129
130 // Tabs instead of spaces for the plaintext version for shorter string length
131 wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
132
133#define ON "ON" << eol
134#define OFF "OFF" << eol
135
136 wxString version;
137 version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
138 : GetBuildVersion() )
139#ifdef DEBUG
140 << ", debug"
141#else
142 << ", release"
143#endif
144 << " build";
145
146 wxPlatformInfo platform;
147 aMsg << "Application: " << aTitle;
148 aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
149
150 aMsg << eol << eol;
151
152
153 aMsg << "Version: " << version << eol << eol;
154 aMsg << "Libraries:" << eol;
155
156 aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
157
158 aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
159 aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
160 aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
161
162 if( !aBrief )
163 aMsg << indent4 << GetKicadCurlVersion() << eol;
164
165 aMsg << eol;
166
167 wxString osDescription;
168
169#if __LINUX__
170 osDescription = wxGetLinuxDistributionInfo().Description;
171#endif
172
173 // Linux uses the lsb-release program to get the description of the OS, if lsb-release
174 // isn't installed, then the string will be empty and we fallback to the method used on
175 // the other platforms (to at least get the kernel/uname info).
176 if( osDescription.empty() )
177 osDescription = wxGetOsDescription();
178
179 aMsg << "Platform: "
180 << osDescription << ", "
181 << GetPlatformGetBitnessName() << ", "
182 << platform.GetEndiannessName() << ", "
183 << platform.GetPortIdName();
184
185#ifdef __WXGTK__
186 if( wxTheApp && wxTheApp->IsGUI() )
187 {
188 aMsg << ", ";
189
190 switch( wxGetDisplayInfo().type )
191 {
192 case wxDisplayX11: aMsg << "X11"; break;
193 case wxDisplayWayland: aMsg << "Wayland"; break;
194 case wxDisplayNone: aMsg << "None"; break;
195 default: aMsg << "Unknown";
196 }
197 }
198
199 aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
200 << ", " << wxGetenv( "XDG_SESSION_TYPE" );
201#endif
202
203 aMsg << eol << eol;
204
205 if( !aBrief )
206 {
207 aMsg << "Build Info:" << eol;
208 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
209 }
210
211 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
212 aMsg << __WX_BO_UNICODE __WX_BO_STL;
213
214// wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
215#if wxCHECK_VERSION( 3, 3, 0 )
216 aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
217#else
218 aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
219#endif
220
221 // Get the GTK+ version where possible.
222#ifdef __WXGTK__
223 int major, minor;
224
225 major = wxPlatformInfo().Get().GetToolkitMajorVersion();
226 minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
227 aMsg << " GTK+ " << major << "." << minor;
228#endif
229
230 aMsg << eol;
231
232 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
233 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
234 << ( BOOST_VERSION % 100 ) << eol;
235
236 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
237 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
238
239#if defined( NGSPICE_BUILD_VERSION )
240 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
241#elif defined( NGSPICE_HAVE_CONFIG_H )
242 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
243 #include <ngspice/config.h>
244 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
245#elif defined( NGSPICE_PACKAGE_VERSION )
246 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
247#else
248 aMsg << indent4 << "ngspice: " << "unknown" << eol;
249#endif
250
251 aMsg << indent4 << "Compiler: ";
252#if defined(__clang__)
253 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
254#elif defined(__GNUG__)
255 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
256#elif defined(_MSC_VER)
257 aMsg << "Visual C++ " << _MSC_VER;
258#elif defined(__INTEL_COMPILER)
259 aMsg << "Intel C++ " << __INTEL_COMPILER;
260#else
261 aMsg << "Other Compiler ";
262#endif
263
264#if defined(__GXX_ABI_VERSION)
265 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
266#else
267 aMsg << " without C++ ABI" << eol;
268#endif
269
270 aMsg << eol;
271
272 // Add build settings config (build options):
273 aMsg << "Build settings:" << eol;
274
275#ifdef KICAD_USE_EGL
276 aMsg << indent4 << "KICAD_USE_EGL=" << ON;
277#endif
278
279#ifndef NDEBUG
280 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
281#ifdef KICAD_STDLIB_DEBUG
282 aMsg << ON;
283#else
284 aMsg << OFF;
285 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
286#ifdef KICAD_STDLIB_LIGHT_DEBUG
287 aMsg << ON;
288#else
289 aMsg << OFF;
290#endif
291#endif
292
293 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
294#ifdef KICAD_SANITIZE_ADDRESS
295 aMsg << ON;
296#else
297 aMsg << OFF;
298#endif
299
300 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
301#ifdef KICAD_SANITIZE_THREADS
302 aMsg << ON;
303#else
304 aMsg << OFF;
305#endif
306#endif
307
308 return aMsg;
309}
wxString GetBaseVersion()
Get the KiCad version string without the information added by the packagers.
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
wxString GetVersionInfoData(const wxString &aTitle, bool aHtml, bool aBrief)
Create a version info string for bug reports and the about dialog.
#define OFF
wxString GetCommitHash()
Get the commit hash as a string.
std::string GetCurlLibVersion()
Definition: kicad_curl.cpp:54
std::string GetKicadCurlVersion()
Definition: kicad_curl.cpp:48
wxString GetMajorMinorPatchVersion()
Get the major, minor and patch version in a string major.minor.patch This is extracted by CMake from ...
const std::tuple< int, int, int > & GetMajorMinorPatchTuple()
Get the build version numbers as a tuple.
wxString GetBuildVersion()
Get the full KiCad version string.
wxString GetSemanticVersion()
Get the semantic version string for KiCad defined inside the KiCadVersion.cmake file in the variable ...
wxString GetPlatformGetBitnessName()
bool IsNightlyVersion()
Check if the build is meant to be nightly.
#define ON
wxString GetBuildDate()
Get the build date as a string.
static wxString FontConfig()
static wxString FreeType()
static wxString HarfBuzz()
bool IsOperatingSystemUnsupported()
Checks if the Operating System is explicitly unsupported and we want to prevent users from sending bu...
Definition: gtk/app.cpp:58
< Package version metadata Package metadata
Definition: pcm_data.h:75