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