KiCad PCB EDA Suite
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/outline_font.h>
31
32#include <tuple>
33
34// kicad_curl.h must be included before wx headers, to avoid
35// conflicts for some defines, at least on Windows
36// kicad_curl.h can create conflicts for some defines, at least on Windows
37// so we are using here 2 proxy functions to know Curl version to avoid
38// including kicad_curl.h to know Curl version
39extern std::string GetKicadCurlVersion();
40extern std::string GetCurlLibVersion();
41
42#include <Standard_Version.hxx>
43
44#if defined( KICAD_SPICE )
45#include <ngspice/sharedspice.h>
46#endif
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
56{
57 wxPlatformInfo platform;
58// TODO (ISM): Read conditional once our wx fork and flatpaks are running released 3.1.5
59// On Windows, use GetBitnessName if exists
60// I (J-PC) hope 3.1.6 has no problem
61#if defined( __WINDOWS__ ) && wxCHECK_VERSION( 3, 1, 5 )
62 return platform.GetBitnessName();
63#elif wxCHECK_VERSION( 3, 1, 6 )
64 return platform.GetBitnessName();
65#else
66 return platform.GetArchName();
67#endif
68}
69
70
72{
73 return !!KICAD_IS_NIGHTLY;
74}
75
76
78{
79 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
80 return msg;
81}
82
83
84wxString GetBuildDate()
85{
86 wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
87 return msg;
88}
89
90
92{
93 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
94 return msg;
95}
96
97
99{
100 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
101 return msg;
102}
103
104
106{
107 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
108 return msg;
109}
110
111
113{
114 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
115 return msg;
116}
117
118const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
119{
120 static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
121
122 return retval;
123}
124
125
126wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
127{
128 wxString aMsg;
129 // DO NOT translate information in the msg_version string
130
131 wxString eol = aHtml ? "<br>" : "\n";
132
133 // Tabs instead of spaces for the plaintext version for shorter string length
134 wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
135
136#define ON "ON" << eol
137#define OFF "OFF" << eol
138
139 wxString version;
140 version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
141 : GetBuildVersion() )
142#ifdef DEBUG
143 << ", debug"
144#else
145 << ", release"
146#endif
147 << " build";
148
149 wxPlatformInfo platform;
150 aMsg << "Application: " << aTitle;
151 #if wxCHECK_VERSION( 3, 1, 6 )
152 aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
153 #elif defined( KICAD_BUILD_ARCH_X64 )
154 aMsg << " (64-bit)";
155 #elif defined( KICAD_BUILD_ARCH_X86 )
156 aMsg << " (32-bit)";
157 #elif defined( KICAD_BUILD_ARCH_ARM )
158 aMsg << " (ARM 32-bit)";
159 #elif defined( KICAD_BUILD_ARCH_ARM64 )
160 aMsg << " (ARM 64-bit)";
161 #endif
162
163 aMsg << eol << eol;
164
165
166 aMsg << "Version: " << version << eol << eol;
167 aMsg << "Libraries:" << eol;
168
169 aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
170
171 aMsg << indent4 << "FreeType " << KIFONT::OUTLINE_FONT::FreeTypeVersion() << eol;
172 aMsg << indent4 << "HarfBuzz " << KIFONT::OUTLINE_FONT::HarfBuzzVersion() << eol;
173 aMsg << indent4 << "FontConfig " << KIFONT::OUTLINE_FONT::FontConfigVersion() << eol;
174
175 if( !aBrief )
176 aMsg << indent4 << GetKicadCurlVersion() << eol;
177
178 aMsg << eol;
179
180 aMsg << "Platform: "
181#if __LINUX__
182 << wxGetLinuxDistributionInfo().Description << ", "
183#else
184 << wxGetOsDescription() << ", "
185#endif
186 << GetPlatformGetBitnessName() << ", "
187 << platform.GetEndiannessName() << ", "
188 << platform.GetPortIdName();
189
190#ifdef __WXGTK__
191 aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
192 << ", " << wxGetenv( "XDG_SESSION_TYPE" );
193#endif
194
195 aMsg << eol << eol;
196
197 if( !aBrief )
198 {
199 aMsg << "Build Info:" << eol;
200 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
201 }
202
203 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
204 aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")";
205
206 // Get the GTK+ version where possible.
207#ifdef __WXGTK__
208 int major, minor;
209
210 major = wxPlatformInfo().Get().GetToolkitMajorVersion();
211 minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
212 aMsg << " GTK+ " << major << "." << minor;
213#endif
214
215 aMsg << eol;
216
217 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
218 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
219 << ( BOOST_VERSION % 100 ) << eol;
220
221 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
222 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
223
224#if defined( KICAD_SPICE )
225#if defined( NGSPICE_BUILD_VERSION )
226 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
227#elif defined( NGSPICE_HAVE_CONFIG_H )
228 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
229 #include <ngspice/config.h>
230 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
231#elif defined( NGSPICE_PACKAGE_VERSION )
232 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
233#else
234 aMsg << indent4 << "ngspice: " << "unknown" << eol;
235#endif
236#endif
237
238 aMsg << indent4 << "Compiler: ";
239#if defined(__clang__)
240 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
241#elif defined(__GNUG__)
242 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
243#elif defined(_MSC_VER)
244 aMsg << "Visual C++ " << _MSC_VER;
245#elif defined(__INTEL_COMPILER)
246 aMsg << "Intel C++ " << __INTEL_COMPILER;
247#else
248 aMsg << "Other Compiler ";
249#endif
250
251#if defined(__GXX_ABI_VERSION)
252 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
253#else
254 aMsg << " without C++ ABI" << eol;
255#endif
256
257 aMsg << eol;
258
259 // Add build settings config (build options):
260 aMsg << "Build settings:" << eol;
261
262#ifdef KICAD_USE_EGL
263 aMsg << indent4 << "KICAD_USE_EGL=" << ON;
264#endif
265
266 aMsg << indent4 << "KICAD_SPICE=";
267#ifdef KICAD_SPICE
268 aMsg << ON;
269#else
270 aMsg << OFF;
271#endif
272
273#ifndef NDEBUG
274 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
275#ifdef KICAD_STDLIB_DEBUG
276 aMsg << ON;
277#else
278 aMsg << OFF;
279 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
280#ifdef KICAD_STDLIB_LIGHT_DEBUG
281 aMsg << ON;
282#else
283 aMsg << OFF;
284#endif
285#endif
286
287 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
288#ifdef KICAD_SANITIZE_ADDRESS
289 aMsg << ON;
290#else
291 aMsg << OFF;
292#endif
293
294 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
295#ifdef KICAD_SANITIZE_THREADS
296 aMsg << ON;
297#else
298 aMsg << OFF;
299#endif
300#endif
301
302 return aMsg;
303}
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:142
std::string GetKicadCurlVersion()
Definition: kicad_curl.cpp:136
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 FreeTypeVersion()
static wxString FontConfigVersion()
static wxString HarfBuzzVersion()
bool IsOperatingSystemUnsupported()
Checks if the Operating System is explicitly unsupported and we want to prevent users from sending bu...
Definition: gtk/app.cpp:51
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
< Package version metadata Package metadata
Definition: pcm_data.h:74