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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21// Date for KiCad build version
22#include <wx/wx.h>
23#include <config.h>
24#include <boost/version.hpp>
25#include <kiplatform/app.h>
26#include <font/version_info.h>
27#include <build_version.h>
28
29#include <tuple>
30#include <mutex>
31
32// kicad_curl.h must be included before wx headers, to avoid
33// conflicts for some defines, at least on Windows
34// kicad_curl.h can create conflicts for some defines, at least on Windows
35// so we are using here 2 proxy functions to know Curl version to avoid
36// including kicad_curl.h to know Curl version
37extern std::string GetKicadCurlVersion();
38extern std::string GetCurlLibVersion();
39
40#include <Standard_Version.hxx>
41
42#include <ngspice/sharedspice.h>
43
44// The include file version.h is always created even if the repo version cannot be
45// determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
46// that is set in KiCadVersion.cmake.
47#define INCLUDE_KICAD_VERSION
48#include <kicad_build_version.h>
49#undef INCLUDE_KICAD_VERSION
50
51// Mutex for wxPlatformInfo
52static std::recursive_mutex s_platformInfoMutex;
53
54// Remember OpenGL info
55static wxString s_glVendor;
56static wxString s_glRenderer;
57static wxString s_glVersion;
58static wxString s_glBackend;
59
60void SetOpenGLInfo( const char* aVendor, const char* aRenderer, const char* aVersion )
61{
62 s_glVendor = wxString::FromUTF8( aVendor );
63 s_glRenderer = wxString::FromUTF8( aRenderer );
64 s_glVersion = wxString::FromUTF8( aVersion );
65}
66
67
68void SetOpenGLBackendInfo( wxString aBackend )
69{
70 s_glBackend = aBackend;
71}
72
73
75{
76 // wxPlatformInfo is not thread-safe, so protect it
77 std::unique_lock lock(s_platformInfoMutex);
78
79 return wxPlatformInfo().GetBitnessName();
80}
81
82
84{
85 return !!KICAD_IS_NIGHTLY;
86}
87
88
90{
91 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
92 return msg;
93}
94
95
97{
98 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION ) );
99 return msg;
100}
101
102
103wxString GetBuildDate()
104{
105 wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
106 return msg;
107}
108
109
111{
112 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
113 return msg;
114}
115
116
118{
119 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
120 return msg;
121}
122
123
125{
126 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
127 return msg;
128}
129
130
132{
133 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
134 return msg;
135}
136
137
138const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
139{
140 static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
141
142 return retval;
143}
144
145
146wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
147{
148 wxString aMsg;
149 // DO NOT translate information in the msg_version string
150
151 wxString eol = aHtml ? "<br>" : "\n";
152
153 // Tabs instead of spaces for the plaintext version for shorter string length
154 wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
155
156#define ON "ON" << eol
157#define OFF "OFF" << eol
158
159 wxString version;
160 version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
161 : GetBuildVersion() )
162#ifdef DEBUG
163 << ", debug"
164#else
165 << ", release"
166#endif
167 << " build";
168
169 aMsg << "Application: " << aTitle;
170 aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
171
172 aMsg << eol << eol;
173
174
175 aMsg << "Version: " << version << eol << eol;
176 aMsg << "Libraries:" << eol;
177
178 aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << " ";
179
180#ifdef __WXGTK__
181 #if wxCHECK_VERSION( 3, 3, 2 )
182 #if wxHAS_EGL && wxHAS_GLX
183 aMsg << "EGL/GLX";
184 #elif wxHAS_EGL
185 aMsg << "EGL";
186 #elif wxHAS_GLX
187 aMsg << "GLX";
188 #endif
189 #else
190 #if wxUSE_GLCANVAS_EGL
191 aMsg << "EGL";
192 #else
193 aMsg << "GLX";
194 #endif
195 #endif
196#endif
197
198 aMsg << eol;
199
200 aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
201 aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
202 aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
203
204 if( !aBrief )
205 aMsg << indent4 << GetKicadCurlVersion() << eol;
206
207 aMsg << eol;
208
209 wxString osDescription;
210
211#if __LINUX__
212 osDescription = wxGetLinuxDistributionInfo().Description;
213#endif
214
215 // Linux uses the lsb-release program to get the description of the OS, if lsb-release
216 // isn't installed, then the string will be empty and we fallback to the method used on
217 // the other platforms (to at least get the kernel/uname info).
218 if( osDescription.empty() )
219 osDescription = wxGetOsDescription();
220
221 {
222 // wxPlatformInfo is not thread-safe, so protect it
223 std::unique_lock lock( s_platformInfoMutex );
224
225 aMsg << "Platform: "
226 << osDescription << ", "
227 << GetPlatformGetBitnessName() << ", "
228 << wxPlatformInfo().GetEndiannessName() << ", "
229 << wxPlatformInfo().GetPortIdName();
230 }
231
232#ifdef __WXGTK__
233 if( wxTheApp && wxTheApp->IsGUI() )
234 {
235 aMsg << ", ";
236
237 switch( wxGetDisplayInfo().type )
238 {
239 case wxDisplayX11: aMsg << "X11"; break;
240 case wxDisplayWayland: aMsg << "Wayland"; break;
241 case wxDisplayNone: aMsg << "None"; break;
242 default: aMsg << "Unknown";
243 }
244 }
245
246 aMsg << ", " << wxGetenv( "XDG_SESSION_TYPE" )
247 << ", " << wxGetenv( "XDG_CURRENT_DESKTOP" )
248 << ", " << wxGetenv( "XDG_SESSION_DESKTOP" );
249#endif
250
251 wxString glMsg;
252
253 for( const wxString& str : { s_glVendor, s_glRenderer, s_glVersion, s_glBackend } )
254 {
255 if( str.empty() )
256 continue;
257
258 if( !glMsg.empty() )
259 glMsg << ", ";
260
261 glMsg << str;
262 }
263
264 if( !glMsg.empty() )
265 aMsg << eol << "OpenGL: " << glMsg;
266
267 aMsg << eol << eol;
268
269 if( !aBrief )
270 {
271 aMsg << "Build Info:" << eol;
272 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
273 }
274
275 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
276 aMsg << __WX_BO_UNICODE __WX_BO_STL;
277
278// wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
279#if wxCHECK_VERSION( 3, 3, 0 )
280 aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
281#else
282 aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
283#endif
284
285 // Get the GTK+ version where possible.
286#ifdef __WXGTK__
287 {
288 // wxPlatformInfo is not thread-safe, so protect it
289 std::unique_lock lock( s_platformInfoMutex );
290 int major, minor;
291
292 major = wxPlatformInfo().GetToolkitMajorVersion();
293 minor = wxPlatformInfo().GetToolkitMinorVersion();
294 aMsg << " GTK+ " << major << "." << minor;
295 }
296#endif
297
298 aMsg << eol;
299
300 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
301 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
302 << ( BOOST_VERSION % 100 ) << eol;
303
304 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
305 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
306
307#if defined( NGSPICE_BUILD_VERSION )
308 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
309#elif defined( NGSPICE_HAVE_CONFIG_H )
310 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
311 #include <ngspice/config.h>
312 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
313#elif defined( NGSPICE_PACKAGE_VERSION )
314 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
315#else
316 aMsg << indent4 << "ngspice: " << "unknown" << eol;
317#endif
318
319 aMsg << indent4 << "Compiler: ";
320#if defined(__clang__)
321 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
322#elif defined(__GNUG__)
323 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
324#elif defined(_MSC_VER)
325 aMsg << "Visual C++ " << _MSC_VER;
326#elif defined(__INTEL_COMPILER)
327 aMsg << "Intel C++ " << __INTEL_COMPILER;
328#else
329 aMsg << "Other Compiler ";
330#endif
331
332#if defined(__GXX_ABI_VERSION)
333 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
334#else
335 aMsg << " without C++ ABI" << eol;
336#endif
337
338 // Add build settings config (build options):
339#if !defined( NDEBUG )
340 aMsg << eol;
341 aMsg << "Build settings:" << eol;
342#endif
343
344 aMsg << indent4 << "KICAD_USE_PCH=";
345#ifdef KICAD_USE_PCH
346 aMsg << ON;
347#else
348 aMsg << OFF;
349#endif
350
351#ifndef NDEBUG
352 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
353#ifdef KICAD_STDLIB_DEBUG
354 aMsg << ON;
355#else
356 aMsg << OFF;
357 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
358#ifdef KICAD_STDLIB_LIGHT_DEBUG
359 aMsg << ON;
360#else
361 aMsg << OFF;
362#endif
363#endif
364
365 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
366#ifdef KICAD_SANITIZE_ADDRESS
367 aMsg << ON;
368#else
369 aMsg << OFF;
370#endif
371
372 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
373#ifdef KICAD_SANITIZE_THREADS
374 aMsg << ON;
375#else
376 aMsg << OFF;
377#endif
378#endif
379
380 wxLocale* locale = wxGetLocale();
381
382 if( locale )
383 {
384 aMsg << eol;
385 aMsg << "Locale: " << eol;
386 aMsg << indent4 << "Lang: " << locale->GetCanonicalName() << eol;
387 aMsg << indent4 << "Enc: " << locale->GetSystemEncodingName() << eol;
388 aMsg << indent4 << "Num: "
389 << wxString::Format( "%d%s%.1f", 1,
390 locale->GetInfo( wxLocaleInfo::wxLOCALE_THOUSANDS_SEP ), 234.5 )
391 << eol;
392
393 wxString testStr( wxS( "кΩ丈" ) );
394 wxString expectedUtf8Hex( wxS( "D0BACEA9E4B888" ) );
395 wxString sysHex, utf8Hex;
396 {
397 const char* asChar = testStr.c_str().AsChar();
398 size_t length = strlen( asChar );
399
400 for( size_t i = 0; i < length; i++ )
401 sysHex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
402 }
403 {
404 const char* asChar = testStr.utf8_str().data();
405 size_t length = strlen( asChar );
406
407 for( size_t i = 0; i < length; i++ )
408 utf8Hex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
409 }
410
411 aMsg << indent4 << "Encoded " << testStr << ": " << sysHex << " (sys), " << utf8Hex
412 << " (utf8)" << eol;
413
414 wxASSERT_MSG( utf8Hex == expectedUtf8Hex,
415 wxString::Format( "utf8_str string %s encoding bad result: %s, expected "
416 "%s, system enc %s, lang %s",
417 testStr, utf8Hex, expectedUtf8Hex,
418 locale->GetSystemEncodingName(),
419 locale->GetCanonicalName() ) );
420 }
421
422 return aMsg;
423}
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
static wxString s_glRenderer
wxString GetCommitHash()
Get the commit hash as a string.
static std::recursive_mutex s_platformInfoMutex
void SetOpenGLInfo(const char *aVendor, const char *aRenderer, const char *aVersion)
A setter for OpenGL info when it's initialized.
std::string GetCurlLibVersion()
std::string GetKicadCurlVersion()
static wxString s_glVendor
wxString GetMajorMinorPatchVersion()
Get the major, minor and patch version in a string major.minor.patch This is extracted by CMake from ...
static wxString s_glVersion
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
static wxString s_glBackend
void SetOpenGLBackendInfo(wxString aBackend)
A setter for OpenGL backend info after the canvas is created.
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 unix/app.cpp:70
< Package version metadataPackage metadata
Definition pcm_data.h:92