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