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.

307 lines
8.8 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-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. // 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/outline_font.h>
  30. #include <tuple>
  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. #include <Standard_Version.hxx>
  39. #include <ngspice/sharedspice.h>
  40. // The include file version.h is always created even if the repo version cannot be
  41. // determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
  42. // that is set in KiCadVersion.cmake.
  43. #define INCLUDE_KICAD_VERSION
  44. #include <kicad_build_version.h>
  45. #undef INCLUDE_KICAD_VERSION
  46. wxString GetPlatformGetBitnessName()
  47. {
  48. wxPlatformInfo platform;
  49. // TODO (ISM): Read conditional once our wx fork and flatpaks are running released 3.1.5
  50. // On Windows, use GetBitnessName if exists
  51. // I (J-PC) hope 3.1.6 has no problem
  52. #if defined( __WINDOWS__ ) && wxCHECK_VERSION( 3, 1, 5 )
  53. return platform.GetBitnessName();
  54. #elif wxCHECK_VERSION( 3, 1, 6 )
  55. return platform.GetBitnessName();
  56. #else
  57. return platform.GetArchName();
  58. #endif
  59. }
  60. bool IsNightlyVersion()
  61. {
  62. return !!KICAD_IS_NIGHTLY;
  63. }
  64. wxString GetBuildVersion()
  65. {
  66. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_VERSION_FULL ) );
  67. return msg;
  68. }
  69. wxString GetBuildDate()
  70. {
  71. wxString msg = wxString::Format( wxT( "%s %s" ), wxT( __DATE__ ), wxT( __TIME__ ) );
  72. return msg;
  73. }
  74. wxString GetSemanticVersion()
  75. {
  76. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_SEMANTIC_VERSION ) );
  77. return msg;
  78. }
  79. wxString GetMajorMinorVersion()
  80. {
  81. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
  82. return msg;
  83. }
  84. wxString GetCommitHash()
  85. {
  86. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_COMMIT_HASH ) );
  87. return msg;
  88. }
  89. wxString GetMajorMinorPatchVersion()
  90. {
  91. wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_PATCH_VERSION ) );
  92. return msg;
  93. }
  94. const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
  95. {
  96. static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;
  97. return retval;
  98. }
  99. wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
  100. {
  101. wxString aMsg;
  102. // DO NOT translate information in the msg_version string
  103. wxString eol = aHtml ? "<br>" : "\n";
  104. // Tabs instead of spaces for the plaintext version for shorter string length
  105. wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
  106. #define ON "ON" << eol
  107. #define OFF "OFF" << eol
  108. wxString version;
  109. version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? wxString( wxS( "(UNSUPPORTED)" ) )
  110. : GetBuildVersion() )
  111. #ifdef DEBUG
  112. << ", debug"
  113. #else
  114. << ", release"
  115. #endif
  116. << " build";
  117. wxPlatformInfo platform;
  118. aMsg << "Application: " << aTitle;
  119. #if wxCHECK_VERSION( 3, 1, 6 )
  120. aMsg << " " << wxGetCpuArchitectureName() << " on " << wxGetNativeCpuArchitectureName();
  121. #elif defined( KICAD_BUILD_ARCH_X64 )
  122. aMsg << " (64-bit)";
  123. #elif defined( KICAD_BUILD_ARCH_X86 )
  124. aMsg << " (32-bit)";
  125. #elif defined( KICAD_BUILD_ARCH_ARM )
  126. aMsg << " (ARM 32-bit)";
  127. #elif defined( KICAD_BUILD_ARCH_ARM64 )
  128. aMsg << " (ARM 64-bit)";
  129. #endif
  130. aMsg << eol << eol;
  131. aMsg << "Version: " << version << eol << eol;
  132. aMsg << "Libraries:" << eol;
  133. aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
  134. aMsg << indent4 << "FreeType " << KIFONT::OUTLINE_FONT::FreeTypeVersion() << eol;
  135. aMsg << indent4 << "HarfBuzz " << KIFONT::OUTLINE_FONT::HarfBuzzVersion() << eol;
  136. aMsg << indent4 << "FontConfig " << KIFONT::OUTLINE_FONT::FontConfigVersion() << eol;
  137. if( !aBrief )
  138. aMsg << indent4 << GetKicadCurlVersion() << eol;
  139. aMsg << eol;
  140. wxString osDescription;
  141. #if __LINUX__
  142. osDescription = wxGetLinuxDistributionInfo().Description;
  143. #endif
  144. // Linux uses the lsb-release program to get the description of the OS, if lsb-release
  145. // isn't installed, then the string will be empty and we fallback to the method used on
  146. // the other platforms (to at least get the kernel/uname info).
  147. if( osDescription.empty() )
  148. osDescription = wxGetOsDescription();
  149. aMsg << "Platform: "
  150. << osDescription << ", "
  151. << GetPlatformGetBitnessName() << ", "
  152. << platform.GetEndiannessName() << ", "
  153. << platform.GetPortIdName();
  154. #ifdef __WXGTK__
  155. aMsg << ", " << wxGetenv( "XDG_SESSION_DESKTOP" )
  156. << ", " << wxGetenv( "XDG_SESSION_TYPE" );
  157. #endif
  158. aMsg << eol << eol;
  159. if( !aBrief )
  160. {
  161. aMsg << "Build Info:" << eol;
  162. aMsg << indent4 << "Date: " << GetBuildDate() << eol;
  163. }
  164. aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
  165. aMsg << __WX_BO_UNICODE __WX_BO_STL;
  166. // wx changed compatibility macros in 3.3, adding the 3.0 macro and removing the 2.8 macro
  167. #if wxCHECK_VERSION( 3, 3, 0 )
  168. aMsg << __WX_BO_WXWIN_COMPAT_3_0 ")";
  169. #else
  170. aMsg << __WX_BO_WXWIN_COMPAT_2_8 ")";
  171. #endif
  172. // Get the GTK+ version where possible.
  173. #ifdef __WXGTK__
  174. int major, minor;
  175. major = wxPlatformInfo().Get().GetToolkitMajorVersion();
  176. minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
  177. aMsg << " GTK+ " << major << "." << minor;
  178. #endif
  179. aMsg << eol;
  180. aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
  181. << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
  182. << ( BOOST_VERSION % 100 ) << eol;
  183. aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
  184. aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
  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. aMsg << indent4 << "Compiler: ";
  197. #if defined(__clang__)
  198. aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
  199. #elif defined(__GNUG__)
  200. aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
  201. #elif defined(_MSC_VER)
  202. aMsg << "Visual C++ " << _MSC_VER;
  203. #elif defined(__INTEL_COMPILER)
  204. aMsg << "Intel C++ " << __INTEL_COMPILER;
  205. #else
  206. aMsg << "Other Compiler ";
  207. #endif
  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. aMsg << eol;
  214. // Add build settings config (build options):
  215. aMsg << "Build settings:" << eol;
  216. #ifdef KICAD_USE_EGL
  217. aMsg << indent4 << "KICAD_USE_EGL=" << ON;
  218. #endif
  219. #ifndef NDEBUG
  220. aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
  221. #ifdef KICAD_STDLIB_DEBUG
  222. aMsg << ON;
  223. #else
  224. aMsg << OFF;
  225. aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
  226. #ifdef KICAD_STDLIB_LIGHT_DEBUG
  227. aMsg << ON;
  228. #else
  229. aMsg << OFF;
  230. #endif
  231. #endif
  232. aMsg << indent4 << "KICAD_SANITIZE_ADDRESS=";
  233. #ifdef KICAD_SANITIZE_ADDRESS
  234. aMsg << ON;
  235. #else
  236. aMsg << OFF;
  237. #endif
  238. aMsg << indent4 << "KICAD_SANITIZE_THREADS=";
  239. #ifdef KICAD_SANITIZE_THREADS
  240. aMsg << ON;
  241. #else
  242. aMsg << OFF;
  243. #endif
  244. #endif
  245. return aMsg;
  246. }