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