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