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