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