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.

309 lines
8.6 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 (C) 2015-2024 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. wxString GetPlatformGetBitnessName()
  48. {
  49. wxPlatformInfo platform;
  50. return platform.GetBitnessName();
  51. }
  52. bool IsNightlyVersion()
  53. {
  54. return !!KICAD_IS_NIGHTLY;
  55. }
  56. wxString GetBuildVersion()
  57. {
  58. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
  59. return msg;
  60. }
  61. wxString GetBaseVersion()
  62. {
  63. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION ) );
  64. return msg;
  65. }
  66. wxString GetBuildDate()
  67. {
  68. wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
  69. return msg;
  70. }
  71. wxString GetSemanticVersion()
  72. {
  73. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
  74. return msg;
  75. }
  76. wxString GetMajorMinorVersion()
  77. {
  78. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
  79. return msg;
  80. }
  81. wxString GetCommitHash()
  82. {
  83. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
  84. return msg;
  85. }
  86. wxString GetMajorMinorPatchVersion()
  87. {
  88. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
  89. return msg;
  90. }
  91. const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
  92. {
  93. static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
  94. return retval;
  95. }
  96. wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
  97. {
  98. wxString aMsg;
  99. // DO NOT translate information in the msg_version string
  100. wxString eol = aHtml ? "<br>" : "\n";
  101. // Tabs instead of spaces for the plaintext version for shorter string length
  102. wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
  103. #define ON "ON" << eol
  104. #define OFF "OFF" << eol
  105. wxString version;
  106. version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
  107. : GetBuildVersion() )
  108. #ifdef DEBUG
  109. << ", debug"
  110. #else
  111. << ", release"
  112. #endif
  113. << " build";
  114. wxPlatformInfo platform;
  115. aMsg << "Application: " << aTitle;
  116. aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
  117. aMsg << eol << eol;
  118. aMsg << "Version: " << version << eol << eol;
  119. aMsg << "Libraries:" << eol;
  120. aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
  121. aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
  122. aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
  123. aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
  124. if( !aBrief )
  125. aMsg << indent4 << GetKicadCurlVersion() << eol;
  126. aMsg << eol;
  127. wxString osDescription;
  128. #if __LINUX__
  129. osDescription = wxGetLinuxDistributionInfo().Description;
  130. #endif
  131. // Linux uses the lsb-release program to get the description of the OS, if lsb-release
  132. // isn't installed, then the string will be empty and we fallback to the method used on
  133. // the other platforms (to at least get the kernel/uname info).
  134. if( osDescription.empty() )
  135. osDescription = wxGetOsDescription();
  136. aMsg << "Platform: "
  137. << osDescription << ", "
  138. << GetPlatformGetBitnessName() << ", "
  139. << platform.GetEndiannessName() << ", "
  140. << platform.GetPortIdName();
  141. #ifdef __WXGTK__
  142. if( wxTheApp && wxTheApp->IsGUI() )
  143. {
  144. aMsg << ", ";
  145. switch( wxGetDisplayInfo().type )
  146. {
  147. case wxDisplayX11: aMsg << "X11"; break;
  148. case wxDisplayWayland: aMsg << "Wayland"; break;
  149. case wxDisplayNone: aMsg << "None"; break;
  150. default: aMsg << "Unknown";
  151. }
  152. }
  153. aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
  154. << ", " << wxGetenv( "XDG_SESSION_TYPE" );
  155. #endif
  156. aMsg << eol << eol;
  157. if( !aBrief )
  158. {
  159. aMsg << "Build Info:" << eol;
  160. aMsg << indent4 << "Date: " << GetBuildDate() << eol;
  161. }
  162. aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
  163. aMsg << __WX_BO_UNICODE __WX_BO_STL;
  164. // wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
  165. #if wxCHECK_VERSION( 3, 3, 0 )
  166. aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
  167. #else
  168. aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
  169. #endif
  170. // Get the GTK+ version where possible.
  171. #ifdef __WXGTK__
  172. int major, minor;
  173. major = wxPlatformInfo().Get().GetToolkitMajorVersion();
  174. minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
  175. aMsg << " GTK+ " << major << "." << minor;
  176. #endif
  177. aMsg << eol;
  178. aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
  179. << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
  180. << ( BOOST_VERSION % 100 ) << eol;
  181. aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
  182. aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
  183. #if defined( NGSPICE_BUILD_VERSION )
  184. aMsg << indent4 << "ngspice: " << NGSPICE_BUILD_VERSION << eol;
  185. #elif defined( NGSPICE_HAVE_CONFIG_H )
  186. #undef HAVE_STRNCASECMP /* is redefined in ngspice/config.h */
  187. #include <ngspice/config.h>
  188. aMsg << indent4 << "ngspice: " << PACKAGE_VERSION << eol;
  189. #elif defined( NGSPICE_PACKAGE_VERSION )
  190. aMsg << indent4 << "ngspice: " << NGSPICE_PACKAGE_VERSION << eol;
  191. #else
  192. aMsg << indent4 << "ngspice: " << "unknown" << eol;
  193. #endif
  194. aMsg << indent4 << "Compiler: ";
  195. #if defined(__clang__)
  196. aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
  197. #elif defined(__GNUG__)
  198. aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
  199. #elif defined(_MSC_VER)
  200. aMsg << "Visual C++ " << _MSC_VER;
  201. #elif defined(__INTEL_COMPILER)
  202. aMsg << "Intel C++ " << __INTEL_COMPILER;
  203. #else
  204. aMsg << "Other Compiler ";
  205. #endif
  206. #if defined(__GXX_ABI_VERSION)
  207. aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
  208. #else
  209. aMsg << " without C++ ABI" << eol;
  210. #endif
  211. aMsg << eol;
  212. // Add build settings config (build options):
  213. aMsg << "Build settings:" << eol;
  214. #ifdef KICAD_USE_EGL
  215. aMsg << indent4 << "KICAD_USE_EGL=" << ON;
  216. #endif
  217. #ifndef NDEBUG
  218. aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
  219. #ifdef KICAD_STDLIB_DEBUG
  220. aMsg << ON;
  221. #else
  222. aMsg << OFF;
  223. aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
  224. #ifdef KICAD_STDLIB_LIGHT_DEBUG
  225. aMsg << ON;
  226. #else
  227. aMsg << OFF;
  228. #endif
  229. #endif
  230. aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
  231. #ifdef KICAD_SANITIZE_ADDRESS
  232. aMsg << ON;
  233. #else
  234. aMsg << OFF;
  235. #endif
  236. aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
  237. #ifdef KICAD_SANITIZE_THREADS
  238. aMsg << ON;
  239. #else
  240. aMsg << OFF;
  241. #endif
  242. #endif
  243. return aMsg;
  244. }