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