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