From a8e9a0053db1f502c95033503dd99b1cbb11a24f Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Sun, 25 Jul 2021 00:40:45 -0400 Subject: [PATCH] Refactor `AboutDialog.cpp` and create `BuildInfo.h` Move build information functionality into new `BuildInfo.h` header. Fix formatting issues in credits list. Add missing libraries to library list. Fix translation issues for contributor credits. Hide ugly macro and `#ifdef` usage inside `BuildInfo.h`. Convert some `#ifdef` usage into `constexpr` uses. Reassure the compiler that the compiler specific version macros exist. Reference-to: https://github.com/tenacityteam/tenacity/pull/361 Signed-off-by: Emily Mabrey --- locale/en.po | 44 ++++++------ src/AboutDialog.cpp | 160 ++++++++++++++------------------------------ src/AboutDialog.h | 16 +++-- src/BuildInfo.h | 157 +++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 1 + 5 files changed, 241 insertions(+), 137 deletions(-) create mode 100644 src/BuildInfo.h diff --git a/locale/en.po b/locale/en.po index e4f35dab9..b96dba6ca 100644 --- a/locale/en.po +++ b/locale/en.po @@ -619,119 +619,119 @@ msgstr "GPL License" #: src/AboutDialog.cpp #, c-format msgid "%s, system administration" -msgstr "%s, pre-fork system administration" +msgstr "%s, Audacity system administration" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, co-founder and developer" -msgstr "%s, pre-fork co-founder and developer" +msgstr "%s, Audacity co-founder and developer" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, developer" -msgstr "%s, pre-fork developer" +msgstr "%s, Audacity developer" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, developer and support" -msgstr "%s, pre-fork developer and support" +msgstr "%s, Audacity developer and support" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, documentation and support" -msgstr "%s, pre-fork documentation and support" +msgstr "%s, Audacity documentation and support" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, QA tester, documentation and support" -msgstr "%s, pre-fork QA tester, documentation and support" +msgstr "%s, Audacity QA tester, documentation and support" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, documentation and support, French" -msgstr "%s, pre-fork documentation and support, French" +msgstr "%s, Audacity documentation and support, French" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, quality assurance" -msgstr "%s, pre-fork quality assurance" +msgstr "%s, Audacity quality assurance" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, accessibility advisor" -msgstr "%s, pre-fork accessibility advisor" +msgstr "%s, Audacity accessibility advisor" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, graphic artist" -msgstr "%s, pre-fork graphic artist" +msgstr "%s, Audacity graphic artist" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, composer" -msgstr "%s, pre-fork composer" +msgstr "%s, Audacity composer" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, tester" -msgstr "%s, pre-fork tester" +msgstr "%s, Audacity tester" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, Nyquist plug-ins" -msgstr "%s, pre-fork Nyquist plug-ins" +msgstr "%s, Audacity Nyquist plug-ins" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, web developer" -msgstr "%s, pre-fork web developer" +msgstr "%s, Audacity web developer" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, c-format msgid "%s, graphics" -msgstr "%s, pre-fork graphics" +msgstr "%s, Audacity graphics" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, fuzzy, c-format msgid "%s, lead Tenacity developer" -msgstr "%s, pre-fork web developer" +msgstr "%s, lead Tenacity developer" #. i18n-hint: For "About Tenacity..." credits, substituting a person's proper #. name #: src/AboutDialog.cpp #, fuzzy, c-format msgid "%s, Tenacity developer" -msgstr "%s, pre-fork web developer" +msgstr "%s, Tenacity developer" #: src/AboutDialog.cpp #, c-format @@ -779,15 +779,15 @@ msgstr "%s includes code from the following projects:" #: src/AboutDialog.cpp msgid "Emeritus:" -msgstr "Pre-fork Emeritus:" +msgstr "Audacity Emeritus:" #: src/AboutDialog.cpp msgid "Contributors" -msgstr "Pre-fork Contributors" +msgstr "Audacity Contributors" #: src/AboutDialog.cpp msgid "Website and Graphics" -msgstr "Pre-fork Website and Graphics" +msgstr "Audacity Website and Graphics" #. i18n-hint: The translation of "translator_credits" will appear #. * in the credits in the About Audacity window. Use this to add @@ -800,11 +800,11 @@ msgstr "translator_credits" #: src/AboutDialog.cpp msgid "Translators" -msgstr "Pre-fork Translators" +msgstr "Audacity Translators" #: src/AboutDialog.cpp msgid "Special thanks:" -msgstr "Pre-fork Special thanks:" +msgstr "Audacity Special thanks:" #. i18n-hint: The program's name substitutes for %s #: src/AboutDialog.cpp diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 052579396..b40890aa5 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -29,6 +29,7 @@ hold information about a credit item in the Credits list #include #include +#include #include "FileNames.h" #include "HelpText.h" #include "ShuttleGui.h" @@ -44,28 +45,10 @@ hold information about a credit item in the Credits list #include "../images/AudacityLogoWithName.xpm" #endif -// RevisionIdent contains the REV_TIME and REV_LONG defines from git commit information -#include "RevisionIdent.h" -//This needs to be outside the #ifdef or it won't end up in the POT file consistently -static wxString NoDateTimeText = XO("Unknown date and time").Translation(); - -#ifndef REV_TIME -#define REV_TIME NoDateTimeText -#endif - -//This needs to be outside the #ifdef or it won't end up in the POT file consistently -static wxString NoRevisionText = XO("No revision identifier was provided").Translation(); - -#ifdef REV_LONG -#define REV_IDENT wxString( "[[https://github.com/tenacityteam/tenacity/commit/" )+ REV_LONG + "|" + wxString( REV_LONG ).Left(6) + "]] of " + REV_TIME -#else -#define REV_IDENT (NoRevisionText) -#endif // To substitute into many other translatable strings static const auto ProgramName = Verbatim("Tenacity"); - static const auto PreforkProgramName = Verbatim("Audacity"); // ---------------------------------------------------------------------------- @@ -110,37 +93,29 @@ void AboutDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { EndModal(wxID_OK); } - -#define ABOUT_DIALOG_WIDTH 506 -#define ABOUT_DIALOG_HEIGHT 359 - void AboutDialog::CreateTenacityTab(ShuttleGui& AboutDialogGUI) { PopulateCreditsList(); wxStringOutputStream tenacityPageGeneratedContent; wxTextOutputStream tenacityPageContent(tenacityPageGeneratedContent); // string to build up list of information in - GenerateTenacityPageDescription(tenacityPageContent); - - GenerateTenacityTeamMembersInfo(tenacityPageContent); - GenerateSpecialThanksInfo(tenacityPageContent); - GenerateTenacityLibsInfo(tenacityPageContent); - - // Pre-form (Audacity) credits - - tenacityPageContent - << wxT("

") - << PreforkProgramName - << wxT("

"); - - GeneratePreforkTeamMembersInfo(tenacityPageContent); - GeneratePreforkEmeritusInfo(tenacityPageContent); - GeneratePreforkContributorInfo(tenacityPageContent); - GeneratePreforkTranslatorsInfo(tenacityPageContent); - GeneratePreforkGraphicsInfo(tenacityPageContent); - GeneratePreforkSpecialThanksInfo(tenacityPageContent); - GeneratePreforkWebsiteInfo(tenacityPageContent); + tenacityPageContent << wxT("
"); + // Tenacity specific credits + GenerateTenacityPageDescription(tenacityPageContent); + GenerateTenacityTeamMembersInfo(tenacityPageContent); + GenerateTenacitySpecialThanksInfo(tenacityPageContent); + GenerateTenacityLibsInfo(tenacityPageContent); + // Pre-fork (Audacity) credits + GeneratePreforkSubheader(tenacityPageContent); + GeneratePreforkTeamMembersInfo(tenacityPageContent); + GeneratePreforkEmeritusInfo(tenacityPageContent); + GeneratePreforkContributorInfo(tenacityPageContent); + GeneratePreforkTranslatorsInfo(tenacityPageContent); + GeneratePreforkGraphicsInfo(tenacityPageContent); + GeneratePreforkSpecialThanksInfo(tenacityPageContent); + GeneratePreforkWebsiteInfo(tenacityPageContent); + GeneratePreforkTrademarkDisclaimer(tenacityPageContent); tenacityPageContent << wxT("
"); auto pPage = AboutDialogGUI.StartNotebookPage(ProgramName); @@ -157,9 +132,9 @@ void AboutDialog::CreateTenacityTab(ShuttleGui& AboutDialogGUI) { AboutDialogGUI.Prop(MINIMUM_PROPORTION).AddWindow(AboutDialog::icon); } - HtmlWindow* html = safenew LinkingHtmlWindow(AboutDialogGUI.GetParent(), -1, + HtmlWindow* html = safenew LinkingHtmlWindow(AboutDialogGUI.GetParent(), wxID_ANY, wxDefaultPosition, - wxSize(ABOUT_DIALOG_WIDTH, ABOUT_DIALOG_HEIGHT), + ABOUT_DIALOG_DEFAULT_SIZE, wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); html->SetPage(FormatHtmlText(tenacityPageGeneratedContent.GetString())); @@ -168,42 +143,6 @@ void AboutDialog::CreateTenacityTab(ShuttleGui& AboutDialogGUI) { AboutDialogGUI.EndNotebookPage(); } -static const wxString getCompilerVersion() { -#if defined(_MSC_FULL_VER) - return wxString::Format(wxT("MSVC %02d.%02d.%05d.%02d"), _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000, _MSC_BUILD); -#elif defined(__GNUC_PATCHLEVEL__) && defined(__MINGW32__) - return wxT("MinGW ") wxMAKE_VERSION_DOT_STRING_T(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); -#elif defined(__GNUC_PATCHLEVEL__) - return wxT("GCC ") wxMAKE_VERSION_DOT_STRING_T(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); -#elif defined(__clang_version__) - return wxT("clang ") __clang_version__; -#else - return wxt("Unknown!!!"); -#endif -} - -static const TranslatableString getBuildType() { - - auto buildType = Verbatim("Unknown Build Type!!!"); - -#ifdef _DEBUG - buildType = XO("Debug build (debug level %d)").Format(wxDEBUG_LEVEL); -#else - buildType = XO("Release build (debug level %d)").Format(wxDEBUG_LEVEL); -#endif - - if ((sizeof(void*) == 8)) { - buildType = XO("%s, 64 bits").Format(buildType); - } - - // Remove this once the transition to CMake is complete -#ifdef CMAKE - buildType = Verbatim("CMake %s").Format(buildType); -#endif - - return buildType; -} - /** \brief: Fills out the "Information" tab of the preferences dialogue * * Provides as much information as possible about build-time options and @@ -237,9 +176,9 @@ void AboutDialog::CreateInformationTab(ShuttleGui& AboutDialogGUI) { << XO("The Build") << wxT("\n"); // start build info table - AddBuildInfoRow(&informationStr, XO("Commit Id:"), REV_IDENT); - AddBuildInfoRow(&informationStr, XO("Build type:"), getBuildType().Translation()); - AddBuildInfoRow(&informationStr, XO("Compiler:"), getCompilerVersion()); + AddBuildInfoRow(&informationStr, XO("Commit Id:"), BuildInfo::getRevisionIdentifier()); + AddBuildInfoRow(&informationStr, XO("Build type:"), BuildInfo::getBuildType()); + AddBuildInfoRow(&informationStr, XO("Compiler:"), BuildInfo::getCompilerVersionString()); // Install prefix #ifdef __WXGTK__ @@ -250,21 +189,6 @@ void AboutDialog::CreateInformationTab(ShuttleGui& AboutDialogGUI) { // Location of settings AddBuildInfoRow(&informationStr, XO("Settings folder:"), FileNames::DataDir()); - /* - informationStr << wxT("
\n"); // end of build info table - informationStr - << wxT("

") - /* i18n-hint: Libraries that are essential to Tenacity *//* - << XO("Core Libraries") - << wxT("

\n"); // start table of core libraries - - AddBuildInfoRow(&informationStr, wxT("wxWidgets"), XO("Cross-platform GUI library"), Verbatim(wxVERSION_NUM_DOT_STRING_T)); - AddBuildInfoRow(&informationStr, wxT("PortAudio"), XO("Audio playback and recording"), Verbatim(wxT("v19"))); - AddBuildInfoRow(&informationStr, wxT("libsoxr"), XO("Sample rate conversion"), enabled); - - informationStr << wxT("
\n"); // end table of core libraries - */ - informationStr << wxT("

") << XO("File Format Support") @@ -273,6 +197,9 @@ void AboutDialog::CreateInformationTab(ShuttleGui& AboutDialogGUI) { informationStr << wxT(""); // start table of file formats supported + AddBuildInfoRow(&informationStr, wxT("wxWidgets"), XO("Cross-platform GUI library"), Verbatim(wxVERSION_NUM_DOT_STRING_T)); + AddBuildInfoRow(&informationStr, wxT("PortAudio"), XO("Audio playback and recording"), Verbatim(wxT("v19"))); + AddBuildInfoRow(&informationStr, wxT("libsoxr"), XO("Sample rate conversion"), enabled); AddBuildInfoRow(&informationStr, wxT("libmad"), XO("MP3 Importing"), USE_LIBMAD ? enabled : disabled); /* i18n-hint: Ogg is the container format. Vorbis is the compression codec. Both are proper nouns and shouldn't be translated */ AddBuildInfoRow(&informationStr, wxT("libvorbis"), XO("Ogg Vorbis Import and Export"), USE_LIBVORBIS ? enabled : disabled); @@ -683,8 +610,8 @@ void AboutDialog::PopulateCreditsList() { // Thanks - AddCredit(wxT("Drew \"SirCmpwn\" DeVault"), roleThanks); - AddCredit(wxT("Filipe \"falkTX\" Coelho"), roleThanks); + AddCredit(wxT("Drew \"SirCmpwn\" DeVault"), roleTenacityThanks); + AddCredit(wxT("Filipe \"falkTX\" Coelho"), roleTenacityThanks); // Libraries section @@ -834,16 +761,14 @@ wxImage AboutDialog::GenerateTenacityLogoRescaledImage(const float fScale) { void AboutDialog::GenerateTenacityPageDescription(wxTextOutputStream& tos) { tos - << wxT("
") // DA: Description and provenance in About box #ifdef EXPERIMENTAL_DA #undef _ #define _(s) wxGetTranslation((s)) << wxT("

DarkTenacity ") << wxString(AUDACITY_VERSION_STRING) - << wxT("

") - << wxT("Customised version of the Tenacity free, open source, cross-platform software ") - << wxT("for recording and editing sounds.") + << wxT("") + << wxT("Customised version of the free, open source, cross-platform audio recorder and editor Tenacity.") #else << XO("

") @@ -853,7 +778,6 @@ void AboutDialog::GenerateTenacityPageDescription(wxTextOutputStream& tos) { << wxT("

") /* i18n-hint: The program's name substitutes for %s */ << XO("Free, open source, cross-platform audio recorder and editor.") - << wxT("") #endif // << wxT("


") @@ -889,13 +813,13 @@ void AboutDialog::GenerateTenacityTeamMembersInfo(wxTextOutputStream& tos) { << GetCreditsByRole(roleTenacityTeamMember); } -void AboutDialog::GenerateSpecialThanksInfo(wxTextOutputStream& tos) { +void AboutDialog::GenerateTenacitySpecialThanksInfo(wxTextOutputStream& tos) { tos << wxT("

") - << XO("Special thanks:") + << XO("Tenacity Special thanks:") << wxT("
") - << GetCreditsByRole(roleThanks); + << GetCreditsByRole(roleTenacityThanks); } void AboutDialog::GenerateTenacityLibsInfo(wxTextOutputStream& tos) { @@ -910,7 +834,15 @@ void AboutDialog::GenerateTenacityLibsInfo(wxTextOutputStream& tos) { << GetCreditsByRole(roleLibrary); } -void AboutDialog::GeneratePreforkTeamMembersInfo(wxTextOutputStream& tos) { +void AboutDialog::GeneratePreforkSubheader(wxTextOutputStream &tos) { + tos + << wxT("

") + << PreforkProgramName + << wxT("

") + << wxT("
"); +} + +void AboutDialog::GeneratePreforkTeamMembersInfo(wxTextOutputStream &tos) { tos << wxT("

") /* i18n-hint: The program's name substitutes for %s */ @@ -1000,6 +932,15 @@ void AboutDialog::GeneratePreforkWebsiteInfo(wxTextOutputStream& tos) { #endif } +void AboutDialog::GeneratePreforkTrademarkDisclaimer(wxTextOutputStream& tos) { + + tos + /* i18n-hint The registered trademark symbol (r) is substituted at %s*/ + << XO("The Audacity%s trademark is used within this software for descriptive and informational purposes only.").Format("®") + << wxT("\n") + << XO("Tenacity is not produced or endorsed by MuseCY SM Ltd. or Dominic M Mazzoni."); +} + void AboutDialog::AddCredit(const wxString& name, const Role role) { AddCredit(name, {}, role); } @@ -1008,6 +949,7 @@ void AboutDialog::AddCredit(const wxString& name, TranslatableString format, con auto str = format.empty() ? Verbatim(name) : TranslatableString{format}.Format(name); + creditItems.emplace_back(std::move(str), role); } diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 5b27b78aa..cf29627f3 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -32,6 +32,10 @@ class AUDACITY_DLL_API AboutDialog final : public wxDialogWrapper{ public: + static constexpr int ABOUT_DIALOG_WIDTH = 506; + static constexpr int ABOUT_DIALOG_HEIGHT = 359; + static const inline wxSize ABOUT_DIALOG_DEFAULT_SIZE = wxSize(ABOUT_DIALOG_WIDTH, ABOUT_DIALOG_HEIGHT); + AboutDialog() : AboutDialog(nullptr){}; AboutDialog(wxWindow * parent); virtual ~AboutDialog(); @@ -46,7 +50,7 @@ class AUDACITY_DLL_API AboutDialog final : public wxDialogWrapper{ enum Role { roleTenacityTeamMember, - roleThanks, + roleTenacityThanks, roleLibrary, rolePreforkTeamMember, rolePreforkEmeritusTeam, @@ -64,9 +68,10 @@ class AUDACITY_DLL_API AboutDialog final : public wxDialogWrapper{ static wxImage GenerateTenacityLogoRescaledImage(const float fScale); void GenerateTenacityPageDescription(wxTextOutputStream & tos); void GenerateTenacityTeamMembersInfo(wxTextOutputStream & tos); - void GenerateSpecialThanksInfo(wxTextOutputStream & tos); + void GenerateTenacitySpecialThanksInfo(wxTextOutputStream & tos); void GenerateTenacityLibsInfo(wxTextOutputStream & tos); + void GeneratePreforkSubheader(wxTextOutputStream & tos); void GeneratePreforkTeamMembersInfo(wxTextOutputStream & tos); void GeneratePreforkEmeritusInfo(wxTextOutputStream & tos); void GeneratePreforkContributorInfo(wxTextOutputStream & tos); @@ -74,16 +79,15 @@ class AUDACITY_DLL_API AboutDialog final : public wxDialogWrapper{ void GeneratePreforkTranslatorsInfo(wxTextOutputStream & tos); void GeneratePreforkSpecialThanksInfo(wxTextOutputStream & tos); void GeneratePreforkWebsiteInfo(wxTextOutputStream & tos); + void GeneratePreforkTrademarkDisclaimer(wxTextOutputStream & tos); void PopulateCreditsList(); void AddCredit(const wxString & name, Role role); void AddCredit(const wxString & name, TranslatableString format, Role role); wxString GetCreditsByRole(Role role); - static void AddBuildInfoRow(wxTextOutputStream * str, const wxChar * libname, - const TranslatableString & libdesc, const TranslatableString & status); - static void AddBuildInfoRow(wxTextOutputStream * str, - const TranslatableString & description, const wxChar * spec); + static void AddBuildInfoRow(wxTextOutputStream * str, const wxChar * libname, const TranslatableString & libdesc, const TranslatableString & status); + static void AddBuildInfoRow(wxTextOutputStream * str, const TranslatableString & description, const wxChar * spec); }; #endif diff --git a/src/BuildInfo.h b/src/BuildInfo.h new file mode 100644 index 000000000..afd48705a --- /dev/null +++ b/src/BuildInfo.h @@ -0,0 +1,157 @@ +/********************************************************************** + + Tenacity + + BuildInfo.h + +**********************************************************************/ + +#ifndef BUILD_INFO_H +#define BUILD_INFO_H + +#include "wx/cpp.h" +#include +#include +#include +#include + +#include + +// RevisionIdent contains the REV_TIME and REV_LONG defines from git commit information +#include "RevisionIdent.h" + +// This define replaces the original that modified the macro in wxwidgets +#define CUSTOM_wxMAKE_VERSION_DOT_STRING_T(x, y, z) wxSTRINGIZE_T(x) wxT(".") wxSTRINGIZE_T(y) wxT(".") wxSTRINGIZE_T(z) wxT("(Tenacity)") + +class BuildInfo { + +public: + enum class CompilerType { MSVC, MinGW, GCC, Clang, Unknown }; + + static constexpr auto CurrentBuildCompiler = + #if defined(_MSC_FULL_VER) + CompilerType::MSVC; + #elif defined(__GNUC_PATCHLEVEL__) && defined(__MINGW32__) + CompilerType::MinGW; + #elif defined(__GNUC_PATCHLEVEL__) + CompilerType::GCC; + #elif defined(__clang_version__) + CompilerType::Clang; + #else + CompilerType::Unknown; + #endif + + static const inline wxString getCompilerVersionString(){ + + switch (BuildInfo::CurrentBuildCompiler) { + + case BuildInfo::CompilerType::MSVC: + #if !defined(_MSC_VER) || !defined(_MSC_FULL_VER) || !defined (_MSC_BUILD) + // This should be unreachable, but it makes the compiler realize that they will always be defined + #define _MSC_VER 0 + #define _MSC_FULL_VER 0 + #define _MSC_BUILD 0 + #endif + return wxString::Format(wxT("MSVC %02d.%02d.%05d.%02d"), _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000, _MSC_BUILD); + + case BuildInfo::CompilerType::MinGW: + #if !defined(__GNUC__) || !defined (__GNUC_MINOR__) || !defined(__GNUC_PATCHLEVEL__) + // This should be unreachable, but it makes the compiler realize that they will always be defined + #define __GNUC__ 0 + #define __GNUC_MINOR__ 0 + #define __GNUC_PATCHLEVEL__ 0 + #endif + return wxString::Format(wxT("MinGW %s"), CUSTOM_wxMAKE_VERSION_DOT_STRING_T( __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)); + + case BuildInfo::CompilerType::GCC: + #if !defined(__GNUC__) || !defined (__GNUC_MINOR__) || !defined(__GNUC_PATCHLEVEL__) + // This should be unreachable, but it makes the compiler realize that they will always be defined + #define __GNUC__ 0 + #define __GNUC_MINOR__ 0 + #define __GNUC_PATCHLEVEL__ 0 + #endif + return wxString::Format(wxT("GCC %s"), CUSTOM_wxMAKE_VERSION_DOT_STRING_T( __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)); + + case BuildInfo::CompilerType::Clang: + #if !defined(__clang_major__) || !defined (__clang_minor__) || !defined(__clang_patchlevel__) + // This should be unreachable, but it makes the compiler realize that they will always be defined + #define __clang_major__ 0 + #define __clang_minor__ 0 + #define __clang_patchlevel__ 0 + #endif + return wxString::Format( wxT("clang %s"), CUSTOM_wxMAKE_VERSION_DOT_STRING_T(__clang_major__, __clang_minor__, __clang_patchlevel__)); + + case BuildInfo::CompilerType::Unknown: + default: + return wxT("Unknown!!!"); + } + }; + + static const inline wxString getRevisionIdentifier(){ + + static wxString NoRevisionText = XO("No revision identifier was provided").Translation(); + + #ifdef REV_LONG + return wxString( "[[https://github.com/tenacityteam/tenacity/commit/" ) + REV_LONG + "|" + wxString( REV_LONG ).Left(6) + "]] of " + getRevisionDateTime(); + #else + return NoRevisionText; + #endif + } + + static const inline wxString getRevisionDateTime(){ + + + //This needs to be outside the #ifdef or it won't end up in the POT file consistently + static wxString NoDateTimeText = XO("Unknown date and time").Translation(); + + #ifdef REV_TIME + return wxString(REV_TIME); + #else + return NoDateTimeText; + #endif + } + + static constexpr inline bool is64bits(){ + return (sizeof(void*) == 8); + } + + static constexpr inline bool isCMakeBuild(){ + #ifdef CMAKE + return true; + #else + return false; + #endif + } + + static constexpr inline bool isDebugBuild(){ + #ifdef _DEBUG + return true; + #else + return false; + #endif + } + + static const wxString getBuildType() { + + wxStringOutputStream o; + wxTextOutputStream buildTypeString(o); + + if constexpr (isCMakeBuild()){ + buildTypeString << Verbatim("CMake "); + } + + if constexpr (isDebugBuild()){ + buildTypeString << XO("Debug build (debug level %d)").Format(wxDEBUG_LEVEL).Translation(); + }else{ + buildTypeString << XO("Release build (debug level %d)").Format(wxDEBUG_LEVEL).Translation(); + } + + if constexpr (is64bits()) { + buildTypeString << XO(", 64 bits").Translation(); + } + + + return o.GetString(); + } +}; +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b7355f21..55eb87105 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -111,6 +111,7 @@ list( APPEND SOURCES BatchProcessDialog.h Benchmark.cpp Benchmark.h + BuildInfo.h CellularPanel.cpp CellularPanel.h ClassicThemeAsCeeCode.h