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// kicad_curl.h must be included before wx headers, to avoid
33// conflicts for some defines, at least on Windows
34// kicad_curl.h can create conflicts for some defines, at least on Windows
35// so we are using here 2 proxy functions to know Curl version to avoid
36// including kicad_curl.h to know Curl version
37extern std::string GetKicadCurlVersion();
38extern std::string GetCurlLibVersion();
39
40#include <Standard_Version.hxx>
41
42#if defined( KICAD_SPICE )
43#include <ngspice/sharedspice.h>
44#endif
45
46// The include file version.h is always created even if the repo version cannot be
47// determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
48// that is set in KiCadVersion.cmake.
49#include <kicad_build_version.h>
50
51
53{
54 wxPlatformInfo platform;
55// TODO (ISM): Read conditional once our wx fork and flatpaks are running released 3.1.5
56// On Windows, use GetBitnessName if exists
57// I (J-PC) hope 3.1.6 has no problem
58#if defined( __WINDOWS__ ) && wxCHECK_VERSION( 3, 1, 5 )
59 return platform.GetBitnessName();
60#elif wxCHECK_VERSION( 3, 1, 6 )
61 return platform.GetBitnessName();
62#else
63 return platform.GetArchName();
64#endif
65}
66
67
69{
70 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
71 return msg;
72}
73
74
75wxString GetBuildDate()
76{
77 wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
78 return msg;
79}
80
81
83{
84 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
85 return msg;
86}
87
88
90{
91 wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
92 return msg;
93}
94
95
96wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
97{
98 wxString aMsg;
99 // DO NOT translate information in the msg_version string
100
101 wxString eol = aHtml ? "<br>" : "\n";
102
103 // Tabs instead of spaces for the plaintext version for shorter string length
104 wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
105
106#define ON "ON" << eol
107#define OFF "OFF" << eol
108
109 wxString version;
110 version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? "(UNSUPPORTED)"
111 : GetBuildVersion() )
112#ifdef DEBUG
113 << ", debug"
114#else
115 << ", release"
116#endif
117 << " build";
118
119 wxPlatformInfo platform;
120 aMsg << "Application: " << aTitle;
121
122 #if defined( KICAD_BUILD_ARCH_X64 )
123 aMsg << " (64-bit)";
124 #elif defined( KICAD_BUILD_ARCH_X86 )
125 aMsg << " (32-bit)";
126 #elif defined( KICAD_BUILD_ARCH_ARM )
127 aMsg << " (ARM 32-bit)";
128 #elif defined( KICAD_BUILD_ARCH_ARM64 )
129 aMsg << " (ARM 64-bit)";
130 #endif
131
132 aMsg << eol << eol;
133
134
135 aMsg << "Version: " << version << eol << eol;
136 aMsg << "Libraries:" << eol;
137
138 aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
139
140 aMsg << indent4 << "FreeType " << KIFONT::OUTLINE_FONT::FreeTypeVersion() << eol;
141 aMsg << indent4 << "HarfBuzz " << KIFONT::OUTLINE_FONT::HarfBuzzVersion() << eol;
142 aMsg << indent4 << "FontConfig " << KIFONT::OUTLINE_FONT::FontConfigVersion() << eol;
143
144 if( !aBrief )
145 aMsg << indent4 << GetKicadCurlVersion() << eol;
146
147 aMsg << eol;
148
149 aMsg << "Platform: " << wxGetOsDescription() << ", "
150 << GetPlatformGetBitnessName() << ", "
151 << platform.GetEndiannessName() << ", "
152 << platform.GetPortIdName();
153
154#ifdef __WXGTK__
155 aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
156 << ", " << wxGetenv( "XDG_SESSION_TYPE" );
157#endif
158
159 aMsg << eol << eol;
160
161 if( !aBrief )
162 {
163 aMsg << "Build Info:" << eol;
164 aMsg << indent4 << "Date: " << GetBuildDate() << eol;
165 }
166
167 aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
168 aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")";
169
170 // Get the GTK+ version where possible.
171#ifdef __WXGTK__
172 int major, minor;
173
174 major = wxPlatformInfo().Get().GetToolkitMajorVersion();
175 minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
176 aMsg << " GTK+ " << major << "." << minor;
177#endif
178
179 aMsg << eol;
180
181 aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
182 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
183 << ( BOOST_VERSION % 100 ) << eol;
184
185 aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
186 aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
187
188#if defined( KICAD_SPICE )
189#if defined( NGSPICE_BUILD_VERSION )
190 aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
191#elif defined( NGSPICE_HAVE_CONFIG_H )
192 #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
193 #include <ngspice/config.h>
194 aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
195#elif defined( NGSPICE_PACKAGE_VERSION )
196 aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
197#else
198 aMsg << indent4 << "ngspice: " << "unknown" << eol;
199#endif
200#endif
201
202 aMsg << indent4 << "Compiler: ";
203#if defined(__clang__)
204 aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
205#elif defined(__GNUG__)
206 aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
207#elif defined(_MSC_VER)
208 aMsg << "Visual C++ " << _MSC_VER;
209#elif defined(__INTEL_COMPILER)
210 aMsg << "Intel C++ " << __INTEL_COMPILER;
211#else
212 aMsg << "Other Compiler ";
213#endif
214
215#if defined(__GXX_ABI_VERSION)
216 aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
217#else
218 aMsg << " without C++ ABI" << eol;
219#endif
220
221 aMsg << eol;
222
223 // Add build settings config (build options):
224 aMsg << "Build settings:" << eol;
225
226#ifdef KICAD_USE_EGL
227 aMsg << indent4 << "KICAD_USE_EGL=" << ON;
228#endif
229
230 aMsg << indent4 << "KICAD_SPICE=";
231#ifdef KICAD_SPICE
232 aMsg << ON;
233#else
234 aMsg << OFF;
235#endif
236
237#ifndef NDEBUG
238 aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
239#ifdef KICAD_STDLIB_DEBUG
240 aMsg << ON;
241#else
242 aMsg << OFF;
243 aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
244#ifdef KICAD_STDLIB_LIGHT_DEBUG
245 aMsg << ON;
246#else
247 aMsg << OFF;
248#endif
249#endif
250
251 aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
252#ifdef KICAD_SANITIZE_ADDRESS
253 aMsg << ON;
254#else
255 aMsg << OFF;
256#endif
257
258 aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
259#ifdef KICAD_SANITIZE_THREADS
260 aMsg << ON;
261#else
262 aMsg << OFF;
263#endif
264#endif
265
266 return aMsg;
267}
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
std::string GetCurlLibVersion()
Definition: kicad_curl.cpp:142
std::string GetKicadCurlVersion()
Definition: kicad_curl.cpp:136
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()
#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