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