You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

378 lines
11 KiB

16 years ago
16 years ago
16 years ago
16 years ago
  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 The 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. // Date for KiCad build version
  25. #include <wx/wx.h>
  26. #include <config.h>
  27. #include <boost/version.hpp>
  28. #include <kiplatform/app.h>
  29. #include <font/version_info.h>
  30. #include <build_version.h>
  31. #include <tuple>
  32. // kicad_curl.h must be included before wx headers, to avoid
  33. // conflicts for some defines, at least on Windows
  34. // kicad_curl.h can create conflicts for some defines, at least on Windows
  35. // so we are using here 2 proxy functions to know Curl version to avoid
  36. // including kicad_curl.h to know Curl version
  37. extern std::string GetKicadCurlVersion();
  38. extern std::string GetCurlLibVersion();
  39. #include <Standard_Version.hxx>
  40. #include <ngspice/sharedspice.h>
  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. #define INCLUDE_KICAD_VERSION
  45. #include <kicad_build_version.h>
  46. #undef INCLUDE_KICAD_VERSION
  47. // Remember OpenGL info
  48. static wxString s_glVendor;
  49. static wxString s_glRenderer;
  50. static wxString s_glVersion;
  51. void SetOpenGLInfo( const char* aVendor, const char* aRenderer, const char* aVersion )
  52. {
  53. s_glVendor = wxString::FromUTF8( aVendor );
  54. s_glRenderer = wxString::FromUTF8( aRenderer );
  55. s_glVersion = wxString::FromUTF8( aVersion );
  56. }
  57. wxString GetPlatformGetBitnessName()
  58. {
  59. wxPlatformInfo platform;
  60. return platform.GetBitnessName();
  61. }
  62. bool IsNightlyVersion()
  63. {
  64. return !!KICAD_IS_NIGHTLY;
  65. }
  66. wxString GetBuildVersion()
  67. {
  68. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
  69. return msg;
  70. }
  71. wxString GetBaseVersion()
  72. {
  73. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION ) );
  74. return msg;
  75. }
  76. wxString GetBuildDate()
  77. {
  78. wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
  79. return msg;
  80. }
  81. wxString GetSemanticVersion()
  82. {
  83. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
  84. return msg;
  85. }
  86. wxString GetMajorMinorVersion()
  87. {
  88. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
  89. return msg;
  90. }
  91. wxString GetCommitHash()
  92. {
  93. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
  94. return msg;
  95. }
  96. wxString GetMajorMinorPatchVersion()
  97. {
  98. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
  99. return msg;
  100. }
  101. const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
  102. {
  103. static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
  104. return retval;
  105. }
  106. wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
  107. {
  108. wxString aMsg;
  109. // DO NOT translate information in the msg_version string
  110. wxString eol = aHtml ? "<br>" : "\n";
  111. // Tabs instead of spaces for the plaintext version for shorter string length
  112. wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
  113. #define ON "ON" << eol
  114. #define OFF "OFF" << eol
  115. wxString version;
  116. version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
  117. : GetBuildVersion() )
  118. #ifdef DEBUG
  119. << ", debug"
  120. #else
  121. << ", release"
  122. #endif
  123. << " build";
  124. wxPlatformInfo platform;
  125. aMsg << "Application: " << aTitle;
  126. aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
  127. aMsg << eol << eol;
  128. aMsg << "Version: " << version << eol << eol;
  129. aMsg << "Libraries:" << eol;
  130. aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
  131. aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
  132. aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
  133. aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
  134. if( !aBrief )
  135. aMsg << indent4 << GetKicadCurlVersion() << eol;
  136. aMsg << eol;
  137. wxString osDescription;
  138. #if __LINUX__
  139. osDescription = wxGetLinuxDistributionInfo().Description;
  140. #endif
  141. // Linux uses the lsb-release program to get the description of the OS, if lsb-release
  142. // isn't installed, then the string will be empty and we fallback to the method used on
  143. // the other platforms (to at least get the kernel/uname info).
  144. if( osDescription.empty() )
  145. osDescription = wxGetOsDescription();
  146. aMsg << "Platform: "
  147. << osDescription << ", "
  148. << GetPlatformGetBitnessName() << ", "
  149. << platform.GetEndiannessName() << ", "
  150. << platform.GetPortIdName();
  151. #ifdef __WXGTK__
  152. if( wxTheApp && wxTheApp->IsGUI() )
  153. {
  154. aMsg << ", ";
  155. switch( wxGetDisplayInfo().type )
  156. {
  157. case wxDisplayX11: aMsg << "X11"; break;
  158. case wxDisplayWayland: aMsg << "Wayland"; break;
  159. case wxDisplayNone: aMsg << "None"; break;
  160. default: aMsg << "Unknown";
  161. }
  162. }
  163. aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
  164. << ", " << wxGetenv( "XDG_SESSION_TYPE" );
  165. #endif
  166. if( !s_glVendor.empty() || !s_glRenderer.empty() || !s_glVersion.empty() )
  167. {
  168. aMsg << eol;
  169. aMsg << "OpenGL: " << s_glVendor << ", " << s_glRenderer << ", " << s_glVersion;
  170. }
  171. aMsg << eol << eol;
  172. if( !aBrief )
  173. {
  174. aMsg << "Build Info:" << eol;
  175. aMsg << indent4 << "Date: " << GetBuildDate() << eol;
  176. }
  177. aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
  178. aMsg << __WX_BO_UNICODE __WX_BO_STL;
  179. // wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
  180. #if wxCHECK_VERSION( 3, 3, 0 )
  181. aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
  182. #else
  183. aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
  184. #endif
  185. // Get the GTK+ version where possible.
  186. #ifdef __WXGTK__
  187. int major, minor;
  188. major = wxPlatformInfo().Get().GetToolkitMajorVersion();
  189. minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
  190. aMsg << " GTK+ " << major << "." << minor;
  191. #endif
  192. aMsg << eol;
  193. aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
  194. << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
  195. << ( BOOST_VERSION % 100 ) << eol;
  196. aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
  197. aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
  198. #if defined( NGSPICE_BUILD_VERSION )
  199. aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
  200. #elif defined( NGSPICE_HAVE_CONFIG_H )
  201. #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
  202. #include <ngspice/config.h>
  203. aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
  204. #elif defined( NGSPICE_PACKAGE_VERSION )
  205. aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
  206. #else
  207. aMsg << indent4 << "ngspice: " << "unknown" << eol;
  208. #endif
  209. aMsg << indent4 << "Compiler: ";
  210. #if defined(__clang__)
  211. aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
  212. #elif defined(__GNUG__)
  213. aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
  214. #elif defined(_MSC_VER)
  215. aMsg << "Visual C++ " << _MSC_VER;
  216. #elif defined(__INTEL_COMPILER)
  217. aMsg << "Intel C++ " << __INTEL_COMPILER;
  218. #else
  219. aMsg << "Other Compiler ";
  220. #endif
  221. #if defined(__GXX_ABI_VERSION)
  222. aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
  223. #else
  224. aMsg << " without C++ ABI" << eol;
  225. #endif
  226. // Add build settings config (build options):
  227. #if defined( KICAD_USE_EGL ) || ! defined( NDEBUG )
  228. aMsg << eol;
  229. aMsg << "Build settings:" << eol;
  230. #endif
  231. #ifdef KICAD_USE_EGL
  232. aMsg << indent4 << "KICAD_USE_EGL=" << ON;
  233. #endif
  234. #ifdef KICAD_IPC_API
  235. aMsg << indent4 << "KICAD_IPC_API=" << ON;
  236. #else
  237. aMsg << indent4 << "KICAD_IPC_API=" << OFF;
  238. #endif
  239. #ifndef NDEBUG
  240. aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
  241. #ifdef KICAD_STDLIB_DEBUG
  242. aMsg << ON;
  243. #else
  244. aMsg << OFF;
  245. aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
  246. #ifdef KICAD_STDLIB_LIGHT_DEBUG
  247. aMsg << ON;
  248. #else
  249. aMsg << OFF;
  250. #endif
  251. #endif
  252. aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
  253. #ifdef KICAD_SANITIZE_ADDRESS
  254. aMsg << ON;
  255. #else
  256. aMsg << OFF;
  257. #endif
  258. aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
  259. #ifdef KICAD_SANITIZE_THREADS
  260. aMsg << ON;
  261. #else
  262. aMsg << OFF;
  263. #endif
  264. #endif
  265. wxLocale* locale = wxGetLocale();
  266. if( locale )
  267. {
  268. aMsg << eol;
  269. aMsg << "Locale: " << eol;
  270. aMsg << indent4 << "Lang: " << locale->GetCanonicalName() << eol;
  271. aMsg << indent4 << "Enc: " << locale->GetSystemEncodingName() << eol;
  272. aMsg << indent4 << "Num: "
  273. << wxString::Format( "%d%s%.1f", 1,
  274. locale->GetInfo( wxLocaleInfo::wxLOCALE_THOUSANDS_SEP ), 234.5 )
  275. << eol;
  276. wxString testStr( wxS( "кΩ丈" ) );
  277. wxString expectedUtf8Hex( wxS( "D0BACEA9E4B888" ) );
  278. wxString sysHex, utf8Hex;
  279. {
  280. const char* asChar = testStr.c_str().AsChar();
  281. size_t length = strlen( asChar );
  282. for( size_t i = 0; i < length; i++ )
  283. sysHex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
  284. }
  285. {
  286. const char* asChar = testStr.utf8_str().data();
  287. size_t length = strlen( asChar );
  288. for( size_t i = 0; i < length; i++ )
  289. utf8Hex << wxString::Format( "%02X", (unsigned int) (uint8_t) asChar[i] );
  290. }
  291. aMsg << indent4 << "Encoded " << testStr << ": " << sysHex << " (sys), " << utf8Hex
  292. << " (utf8)" << eol;
  293. wxASSERT_MSG( utf8Hex == expectedUtf8Hex,
  294. wxString::Format( "utf8_str string %s encoding bad result: %s, expected "
  295. "%s, system enc %s, lang %s",
  296. testStr, utf8Hex, expectedUtf8Hex,
  297. locale->GetSystemEncodingName(),
  298. locale->GetCanonicalName() ) );
  299. }
  300. return aMsg;
  301. }