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#if wxUSE_GLCANVAS_EGL
184 aMsg << " (EGL)";
185#endif
186 aMsg << eol;
187
188 aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
189 aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
190 aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
191
192 if( !aBrief )
193 aMsg << indent4 << GetKicadCurlVersion() << eol;
194
195 aMsg << eol;
196
197 wxString osDescription;
198
199#if __LINUX__
200 osDescription = wxGetLinuxDistributionInfo().Description;
201#endif
202
203 // Linux uses the lsb-release program to get the description of the OS, if lsb-release
204 // isn't installed, then the string will be empty and we fallback to the method used on
205 // the other platforms (to at least get the kernel/uname info).
206 if( osDescription.empty() )
207 osDescription = wxGetOsDescription();
208
209 {
210 // wxPlatformInfo is not thread-safe, so protect it
211 std::unique_lock lock( s_platformInfoMutex );
212
213 aMsg << "Platform: "
214 << osDescription << ", "
215 << GetPlatformGetBitnessName() << ", "
216 << wxPlatformInfo().GetEndiannessName() << ", "
217 << wxPlatformInfo().GetPortIdName();
218 }
219
220#ifdef __WXGTK__
221 if( wxTheApp && wxTheApp->IsGUI() )
222 {
223 aMsg << ", ";
224
225 switch( wxGetDisplayInfo().type )
226 {
227 case wxDisplayX11: aMsg << "X11"; break;
228 case wxDisplayWayland: aMsg << "Wayland"; break;
229 case wxDisplayNone: aMsg << "None"; break;
230 default: aMsg << "Unknown";
231 }
232 }
233
234 aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
235 << ", " << wxGetenv( "XDG_SESSION_TYPE" );
236#endif
237
238 wxString glMsg;
239
240 for( const wxString& str : { s_glVendor, s_glRenderer, s_glVersion, s_glBackend } )
241 {
242 if( str.empty() )
243 continue;
244
245 if( !glMsg.empty() )
246 glMsg << ", ";
247
248 glMsg << str;
249 }
250
251 if( !glMsg.empty() )
252 aMsg << eol << "OpenGL: " << glMsg;
253
254 aMsg << eol << eol;
255
256 if( !aBrief )
257 {
258 aMsg << "Build Info:" << eol;
259 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
260 }
261
262 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
263 aMsg << __WX_BO_UNICODE __WX_BO_STL;
264
265// wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
266#if wxCHECK_VERSION( 3, 3, 0 )
267 aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
268#else
269 aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
270#endif
271
272 // Get the GTK+ version where possible.
273#ifdef __WXGTK__
274 {
275 // wxPlatformInfo is not thread-safe, so protect it
276 std::unique_lock lock( s_platformInfoMutex );
277 int major, minor;
278
279 major = wxPlatformInfo().GetToolkitMajorVersion();
280 minor = wxPlatformInfo().GetToolkitMinorVersion();
281 aMsg << " GTK+ " << major << "." << minor;
282 }
283#endif
284
285 aMsg << eol;
286
287 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
288 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
289 << ( BOOST_VERSION % 100 ) << eol;
290
291 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
292 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
293
294#if defined( NGSPICE_BUILD_VERSION )
295 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
296#elif defined( NGSPICE_HAVE_CONFIG_H )
297 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
298 #include <ngspice/config.h>
299 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
300#elif defined( NGSPICE_PACKAGE_VERSION )
301 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
302#else
303 aMsg << indent4 << "ngspice: " << "unknown" << eol;
304#endif
305
306 aMsg << indent4 << "Compiler: ";
307#if defined(__clang__)
308 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
309#elif defined(__GNUG__)
310 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
311#elif defined(_MSC_VER)
312 aMsg << "Visual C++ " << _MSC_VER;
313#elif defined(__INTEL_COMPILER)
314 aMsg << "Intel C++ " << __INTEL_COMPILER;
315#else
316 aMsg << "Other Compiler ";
317#endif
318
319#if defined(__GXX_ABI_VERSION)
320 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
321#else
322 aMsg << " without C++ ABI" << eol;
323#endif
324
325 // Add build settings config (build options):
326#if defined( KICAD_USE_EGL ) || ! defined( NDEBUG )
327 aMsg << eol;
328 aMsg << "Build settings:" << eol;
329#endif
330
331#ifdef KICAD_USE_EGL
332 aMsg << indent4 << "KICAD_USE_EGL=" << ON;
333#endif
334
335#ifdef KICAD_IPC_API
336 aMsg << indent4 << "KICAD_IPC_API=" << ON;
337#else
338 aMsg << indent4 << "KICAD_IPC_API=" << OFF;
339#endif
340
341 aMsg << indent4 << "KICAD_USE_PCH=";
342#ifdef KICAD_USE_PCH
343 aMsg << ON;
344#else
345 aMsg << OFF;
346#endif
347
348#ifndef NDEBUG
349 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
350#ifdef KICAD_STDLIB_DEBUG
351 aMsg << ON;
352#else
353 aMsg << OFF;
354 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
355#ifdef KICAD_STDLIB_LIGHT_DEBUG
356 aMsg << ON;
357#else
358 aMsg << OFF;
359#endif
360#endif
361
362 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
363#ifdef KICAD_SANITIZE_ADDRESS
364 aMsg << ON;
365#else
366 aMsg << OFF;
367#endif
368
369 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
370#ifdef KICAD_SANITIZE_THREADS
371 aMsg << ON;
372#else
373 aMsg << OFF;
374#endif
375#endif
376
377 wxLocale* locale = wxGetLocale();
378
379 if( locale )
380 {
381 aMsg << eol;
382 aMsg << "Locale: " << eol;
383 aMsg << indent4 << "Lang: " << locale->GetCanonicalName() << eol;
384 aMsg << indent4 << "Enc: " << locale->GetSystemEncodingName() << eol;
385 aMsg << indent4 << "Num: "
386 << wxString::Format( "%d%s%.1f", 1,
387 locale->GetInfo( wxLocaleInfo::wxLOCALE_THOUSANDS_SEP ), 234.5 )
388 << eol;
389
390 wxString testStr( wxS( "кΩ丈" ) );
391 wxString expectedUtf8Hex( wxS( "D0BACEA9E4B888" ) );
392 wxString sysHex, utf8Hex;
393 {
394 const char* asChar = testStr.c_str().AsChar();
395 size_t length = strlen( asChar );
396
397 for( size_t i = 0; i < length; i++ )
398 sysHex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
399 }
400 {
401 const char* asChar = testStr.utf8_str().data();
402 size_t length = strlen( asChar );
403
404 for( size_t i = 0; i < length; i++ )
405 utf8Hex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
406 }
407
408 aMsg << indent4 << "Encoded " << testStr << ": " << sysHex << " (sys), " << utf8Hex
409 << " (utf8)" << eol;
410
411 wxASSERT_MSG( utf8Hex == expectedUtf8Hex,
412 wxString::Format( "utf8_str string %s encoding bad result: %s, expected "
413 "%s, system enc %s, lang %s",
414 testStr, utf8Hex, expectedUtf8Hex,
415 locale->GetSystemEncodingName(),
416 locale->GetCanonicalName() ) );
417 }
418
419 return aMsg;
420}
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:58
< Package version metadataPackage metadata
Definition pcm_data.h:92