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 (C) 2015-2020 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
55{
56 wxPlatformInfo platform;
57 return platform.GetBitnessName();
58}
59
60
62{
63 return !!KICAD_IS_NIGHTLY;
64}
65
66
68{
69 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
70 return msg;
71}
72
73
74wxString GetBuildDate()
75{
76 wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
77 return msg;
78}
79
80
82{
83 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
84 return msg;
85}
86
87
89{
90 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
91 return msg;
92}
93
94
95wxString GetCommitHash()
96{
97 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
98 return msg;
99}
100
101
103{
104 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
105 return msg;
106}
107
108const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
109{
110 static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
111
112 return retval;
113}
114
115
116wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
117{
118 wxString aMsg;
119 // DO NOT translate information in the msg_version string
120
121 wxString eol = aHtml ? "<br>" : "\n";
122
123 // Tabs instead of spaces for the plaintext version for shorter string length
124 wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
125
126#define ON "ON" << eol
127#define OFF "OFF" << eol
128
129 wxString version;
130 version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
131 : GetBuildVersion() )
132#ifdef DEBUG
133 << ", debug"
134#else
135 << ", release"
136#endif
137 << " build";
138
139 wxPlatformInfo platform;
140 aMsg << "Application: " << aTitle;
141 aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
142
143 aMsg << eol << eol;
144
145
146 aMsg << "Version: " << version << eol << eol;
147 aMsg << "Libraries:" << eol;
148
149 aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
150
151 aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
152 aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
153 aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
154
155 if( !aBrief )
156 aMsg << indent4 << GetKicadCurlVersion() << eol;
157
158 aMsg << eol;
159
160 wxString osDescription;
161
162#if __LINUX__
163 osDescription = wxGetLinuxDistributionInfo().Description;
164#endif
165
166 // Linux uses the lsb-release program to get the description of the OS, if lsb-release
167 // isn't installed, then the string will be empty and we fallback to the method used on
168 // the other platforms (to at least get the kernel/uname info).
169 if( osDescription.empty() )
170 osDescription = wxGetOsDescription();
171
172 aMsg << "Platform: "
173 << osDescription << ", "
174 << GetPlatformGetBitnessName() << ", "
175 << platform.GetEndiannessName() << ", "
176 << platform.GetPortIdName();
177
178#ifdef __WXGTK__
179 if( wxTheApp && wxTheApp->IsGUI() )
180 {
181 aMsg << ", ";
182
183 switch( wxGetDisplayInfo().type )
184 {
185 case wxDisplayX11: aMsg << "X11"; break;
186 case wxDisplayWayland: aMsg << "Wayland"; break;
187 case wxDisplayNone: aMsg << "None"; break;
188 default: aMsg << "Unknown";
189 }
190 }
191
192 aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
193 << ", " << wxGetenv( "XDG_SESSION_TYPE" );
194#endif
195
196 aMsg << eol << eol;
197
198 if( !aBrief )
199 {
200 aMsg << "Build Info:" << eol;
201 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
202 }
203
204 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
205 aMsg << __WX_BO_UNICODE __WX_BO_STL;
206
207// wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
208#if wxCHECK_VERSION( 3, 3, 0 )
209 aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
210#else
211 aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
212#endif
213
214 // Get the GTK+ version where possible.
215#ifdef __WXGTK__
216 int major, minor;
217
218 major = wxPlatformInfo().Get().GetToolkitMajorVersion();
219 minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
220 aMsg << " GTK+ " << major << "." << minor;
221#endif
222
223 aMsg << eol;
224
225 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
226 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
227 << ( BOOST_VERSION % 100 ) << eol;
228
229 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
230 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
231
232#if defined( NGSPICE_BUILD_VERSION )
233 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
234#elif defined( NGSPICE_HAVE_CONFIG_H )
235 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
236 #include <ngspice/config.h>
237 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
238#elif defined( NGSPICE_PACKAGE_VERSION )
239 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
240#else
241 aMsg << indent4 << "ngspice: " << "unknown" << eol;
242#endif
243
244 aMsg << indent4 << "Compiler: ";
245#if defined(__clang__)
246 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
247#elif defined(__GNUG__)
248 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
249#elif defined(_MSC_VER)
250 aMsg << "Visual C++ " << _MSC_VER;
251#elif defined(__INTEL_COMPILER)
252 aMsg << "Intel C++ " << __INTEL_COMPILER;
253#else
254 aMsg << "Other Compiler ";
255#endif
256
257#if defined(__GXX_ABI_VERSION)
258 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
259#else
260 aMsg << " without C++ ABI" << eol;
261#endif
262
263 aMsg << eol;
264
265 // Add build settings config (build options):
266 aMsg << "Build settings:" << eol;
267
268#ifdef KICAD_USE_EGL
269 aMsg << indent4 << "KICAD_USE_EGL=" << ON;
270#endif
271
272#ifndef NDEBUG
273 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
274#ifdef KICAD_STDLIB_DEBUG
275 aMsg << ON;
276#else
277 aMsg << OFF;
278 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
279#ifdef KICAD_STDLIB_LIGHT_DEBUG
280 aMsg << ON;
281#else
282 aMsg << OFF;
283#endif
284#endif
285
286 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
287#ifdef KICAD_SANITIZE_ADDRESS
288 aMsg << ON;
289#else
290 aMsg << OFF;
291#endif
292
293 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
294#ifdef KICAD_SANITIZE_THREADS
295 aMsg << ON;
296#else
297 aMsg << OFF;
298#endif
299#endif
300
301 return aMsg;
302}
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
wxString GetCommitHash()
Get the commit hash as a string.
std::string GetCurlLibVersion()
Definition: kicad_curl.cpp:54
std::string GetKicadCurlVersion()
Definition: kicad_curl.cpp:48
wxString GetMajorMinorPatchVersion()
Get the major, minor and patch version in a string major.minor.patch This is extracted by CMake from ...
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: gtk/app.cpp:58
< Package version metadata Package metadata
Definition: pcm_data.h:75