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;
99  aMsg << "Version: " << version << eol;
100  aMsg << "Libraries:" << eol;
101 
102  aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
103 
104  if( !aBrief )
105  aMsg << indent4 << GetKicadCurlVersion() << eol;
106 
107  aMsg << "Platform: " << wxGetOsDescription() << ", "
108  << platform.GetArchName() << ", "
109  << platform.GetEndiannessName() << ", "
110  << platform.GetPortIdName() << eol;
111 
112  if( !aBrief )
113  aMsg << "Build Info:" << eol;
114 
115  if( !aBrief )
116  aMsg << indent4 << "Build date: " << GetBuildDate() << eol;
117 
118  aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
119  aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")";
120 
121  // Get the GTK+ version where possible.
122 #ifdef __WXGTK__
123  int major, minor;
124 
125  major = wxPlatformInfo().Get().GetToolkitMajorVersion();
126  minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
127  aMsg << " GTK+ " << major << "." << minor;
128 #endif
129 
130  aMsg << eol;
131 
132  aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
133  << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
134  << ( BOOST_VERSION % 100 ) << eol;
135 
136 #ifdef KICAD_USE_OCC
137  aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
138 #endif
139 
140 #ifdef KICAD_USE_OCE
141  aMsg << indent4 << "OCE: " << OCC_VERSION_COMPLETE << eol;
142 #endif
143 
144  aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
145 
146  aMsg << indent4 << "Compiler: ";
147 #if defined(__clang__)
148  aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
149 #elif defined(__GNUG__)
150  aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
151 #elif defined(_MSC_VER)
152  aMsg << "Visual C++ " << _MSC_VER;
153 #elif defined(__INTEL_COMPILER)
154  aMsg << "Intel C++ " << __INTEL_COMPILER;
155 #else
156  aMsg << "Other Compiler ";
157 #endif
158 
159 #if defined(__GXX_ABI_VERSION)
160  aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
161 #else
162  aMsg << " without C++ ABI";
163 #endif
164 
165  aMsg << eol;
166 
167  // Add build settings config (build options):
168  aMsg << "Build settings:" << eol;
169 
170  aMsg << indent4 << "KICAD_SCRIPTING=";
171 #ifdef KICAD_SCRIPTING
172  aMsg << ON;
173 #else
174  aMsg << OFF;
175 #endif
176 
177  aMsg << indent4 << "KICAD_SCRIPTING_MODULES=";
178 #ifdef KICAD_SCRIPTING_MODULES
179  aMsg << ON;
180 #else
181  aMsg << OFF;
182 #endif
183 
184  aMsg << indent4 << "KICAD_SCRIPTING_PYTHON3=";
185 #ifdef KICAD_SCRIPTING_PYTHON3
186  aMsg << ON;
187 #else
188  aMsg << OFF;
189 #endif
190 
191  aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON=";
192 #ifdef KICAD_SCRIPTING_WXPYTHON
193  aMsg << ON;
194 #else
195  aMsg << OFF;
196 #endif
197 
198  aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON_PHOENIX=";
199 #ifdef KICAD_SCRIPTING_WXPYTHON_PHOENIX
200  aMsg << ON;
201 #else
202  aMsg << OFF;
203 #endif
204 
205  aMsg << indent4 << "KICAD_SCRIPTING_ACTION_MENU=";
206 #ifdef KICAD_SCRIPTING_ACTION_MENU
207  aMsg << ON;
208 #else
209  aMsg << OFF;
210 #endif
211 
212  aMsg << indent4 << "BUILD_GITHUB_PLUGIN=";
213 #ifdef BUILD_GITHUB_PLUGIN
214  aMsg << ON;
215 #else
216  aMsg << OFF;
217 #endif
218 
219 #ifdef KICAD_USE_OCE
220  aMsg << indent4 << "KICAD_USE_OCE=" << ON;
221 #endif
222 
223 #ifdef KICAD_USE_OCC
224  aMsg << indent4 << "KICAD_USE_OCC=" << ON;
225 #endif
226 
227  aMsg << indent4 << "KICAD_SPICE=";
228 #ifdef KICAD_SPICE
229  aMsg << ON;
230 #else
231  aMsg << OFF;
232 #endif
233 
234 #ifndef NDEBUG
235  aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
236 #ifdef KICAD_STDLIB_DEBUG
237  aMsg << ON;
238 #else
239  aMsg << OFF;
240  aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
241 #ifdef KICAD_STDLIB_LIGHT_DEBUG
242  aMsg << ON;
243 #else
244  aMsg << OFF;
245 #endif
246 #endif
247 
248  aMsg << indent4 << "KICAD_SANITIZE=";
249 #ifdef KICAD_SANITIZE
250  aMsg << ON;
251 #else
252  aMsg << OFF;
253 #endif
254 #endif
255 
256  return aMsg;
257 }
#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:246
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:241
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:205
wxString GetSemanticVersion()
Get the semantic version string for KiCad defined inside the KiCadVersion.cmake file in the variable ...