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