From 1ef78dafb1e45c45556b99b8c4113d841879914f Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 2 Nov 2021 23:26:11 +0000 Subject: [PATCH] Single definition of Bloom website domain --- CMakeLists.txt | 6 ++++++ src/Application.cpp | 11 ++++++++--- .../EDBG/AVR/EdbgAvr8Interface.cpp | 5 +++-- src/Helpers/Paths.hpp | 17 +++++++++++++++++ src/Insight/Insight.cpp | 2 +- .../Tasks/QueryLatestVersionNumber.cpp | 4 +++- .../InsightWindow/InsightWindow.cpp | 4 ++-- .../TargetRegisterInspectorWindow.cpp | 2 +- src/TargetController/TargetController.cpp | 8 ++++---- .../TargetDescription/TargetDescriptionFile.cpp | 3 ++- 10 files changed, 47 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06aab8c3..a1a8c6ef 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,12 @@ if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") # See Paths::compiledResourcesPath() for more. add_compile_definitions(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE="${CMAKE_CURRENT_SOURCE_DIR}") + # BLOOM_HOME_DOMAIN_NAME_OVERRIDE can be used to override the domain name used in URLs to the Bloom website. + # I (Nav) use this in debug builds, so I can test local changes that involve the Bloom website as well as Bloom + # itself. Other users can comment out this override if they don't have a copy of the Bloom website running on their + # local machine. See Paths::homeDomainName() for more. + add_compile_definitions(BLOOM_HOME_DOMAIN_NAME_OVERRIDE="http://bloom.local") + # CMAKE_SKIP_BUILD_RPATH needs to be set to true to use Gammaray during development. # This is because the distributed Qt binaries may not be compatible with the local installation of Gammaray set(CMAKE_BUILD_RPATH /opt/Qt/6.1.2/gcc_64/lib/) diff --git a/src/Application.cpp b/src/Application.cpp index 6d249bf1..5299a1be 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -204,7 +204,9 @@ int Application::presentHelpText() { if (!helpFile.open(QIODevice::ReadOnly)) { // This should never happen - if it does, something has gone very wrong - throw Exception("Failed to open help file - please report this issue at https://bloom.oscillate.io/report-issue"); + throw Exception( + "Failed to open help file - please report this issue at " + Paths::homeDomainName() + "/report-issue" + ); } std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; @@ -221,7 +223,7 @@ int Application::presentVersionText() { std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n"; #endif - std::cout << "https://bloom.oscillate.io/\n"; + std::cout << Paths::homeDomainName() + "/\n"; std::cout << "Nav Mohammed\n"; return EXIT_SUCCESS; } @@ -246,7 +248,10 @@ int Application::initProject() { ); if (!templateConfigFile.open(QIODevice::ReadOnly)) { - throw Exception("Failed to open template configuration file - please report this issue at https://bloom.oscillate.io/report-issue"); + throw Exception( + "Failed to open template configuration file - please report this issue at " + + Paths::homeDomainName() + "/report-issue" + ); } if (!configFile.open(QIODevice::ReadWrite)) { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index fd4a2647..7c18c15b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -8,6 +8,7 @@ #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp" #include "src/Logger/Logger.hpp" +#include "src/Helpers/Paths.hpp" // Command frames #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp" @@ -72,13 +73,13 @@ void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) { if (this->physicalInterface == PhysicalInterface::JTAG) { throw InvalidConfig("The JTAG physical interface cannot be used with an ambiguous target name" " - please specify the exact name of the target in your configuration file. " - "See https://bloom.oscillate.io/docs/supported-targets" + "See " + Paths::homeDomainName() + "/docs/supported-targets" ); } else if (this->physicalInterface == PhysicalInterface::UPDI) { throw InvalidConfig("The UPDI physical interface cannot be used with an ambiguous target name" " - please specify the exact name of the target in your configuration file. " - "See https://bloom.oscillate.io/docs/supported-targets" + "See " + Paths::homeDomainName() + "/docs/supported-targets" ); } } diff --git a/src/Helpers/Paths.hpp b/src/Helpers/Paths.hpp index bd85a822..bcbc4475 100644 --- a/src/Helpers/Paths.hpp +++ b/src/Helpers/Paths.hpp @@ -29,6 +29,7 @@ namespace Bloom * If the debug configuration is enabled, this function will return the absolute path to Bloom's source code, * meaning we won't use compiled resources for debug builds. This is useful for debugging and tweaking QT UI * files such as QT stylesheets and UI templates. + * * @return */ static inline std::string compiledResourcesPath() { @@ -36,6 +37,22 @@ namespace Bloom return std::string(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE); #else return std::string(":/compiled"); +#endif + } + + /** + * Returns the domain name for the Bloom website. + * + * The domain name can be overridden via the BLOOM_HOME_DOMAIN_NAME_OVERRIDE compile definition. + * See CMakeLists.txt + * + * @return + */ + static inline std::string homeDomainName() { +#ifdef BLOOM_HOME_DOMAIN_NAME_OVERRIDE + return std::string(BLOOM_HOME_DOMAIN_NAME_OVERRIDE); +#else + return std::string("https://bloom.oscillate.io"); #endif } }; diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 5a29dc64..b7d76a62 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -175,7 +175,7 @@ void Insight::checkBloomVersion() { if (latestVersionNumber > currentVersionNumber) { Logger::warning( "Bloom v" + latestVersionNumber.toString() - + " is available to download - upgrade via https://bloom.oscillate.io" + + " is available to download - upgrade via " + Paths::homeDomainName() ); } } diff --git a/src/Insight/InsightWorker/Tasks/QueryLatestVersionNumber.cpp b/src/Insight/InsightWorker/Tasks/QueryLatestVersionNumber.cpp index bf67ed6e..4005e99b 100644 --- a/src/Insight/InsightWorker/Tasks/QueryLatestVersionNumber.cpp +++ b/src/Insight/InsightWorker/Tasks/QueryLatestVersionNumber.cpp @@ -7,11 +7,13 @@ #include #include +#include "src/Helpers/Paths.hpp" + using namespace Bloom; void QueryLatestVersionNumber::run(TargetControllerConsole& targetControllerConsole) { auto* networkAccessManager = new QNetworkAccessManager(this); - auto queryVersionEndpointUrl = QUrl("http://bloom.local/latest-version"); + auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Paths::homeDomainName() + "/latest-version")); queryVersionEndpointUrl.setQuery(QUrlQuery({ {"currentVersionNumber", QString::fromStdString(this->currentVersionNumber.toString())} })); diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index f03eb98d..e582d980 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -184,7 +184,7 @@ void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) { } void InsightWindow::openReportIssuesUrl() { - auto url = QUrl("https://bloom.oscillate.io/report-issue"); + auto url = QUrl(QString::fromStdString(Paths::homeDomainName() + "/report-issue")); /* * The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page. * @@ -209,7 +209,7 @@ void InsightWindow::openReportIssuesUrl() { } void InsightWindow::openGettingStartedUrl() { - QDesktopServices::openUrl(QUrl("https://bloom.oscillate.io/docs/getting-started")); + QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/getting-started"))); } void InsightWindow::openAboutWindow() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp index 541b099e..4c61f2e2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp @@ -368,5 +368,5 @@ void TargetRegisterInspectorWindow::applyChanges() { } void TargetRegisterInspectorWindow::openHelpPage() { - QDesktopServices::openUrl(QUrl("https://bloom.oscillate.io/docs/register-inspection")); + QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/register-inspection"))); } diff --git a/src/TargetController/TargetController.cpp b/src/TargetController/TargetController.cpp index 7cb4b1f1..ba71c084 100644 --- a/src/TargetController/TargetController.cpp +++ b/src/TargetController/TargetController.cpp @@ -106,10 +106,10 @@ void TargetController::checkUdevRules() { // We can only install them if we're running as root if (!Application::isRunningAsRoot()) { Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n" - "Running Bloom once with root privileges will allow it to automatically install the udev rules." - " Alternatively, instructions on manually installing the udev rules can be found " - "here: https://bloom.oscillate.io/docs/getting-started\nBloom may fail to connect to some debug tools " - "until this is resolved."); + "Running Bloom once with root privileges will allow it to automatically install the udev rules. " + "Alternatively, instructions on manually installing the udev rules can be found " + "here: " + Paths::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some " + "debug tools until this is resolved."); return; } diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index d9ff014a..a3d2c4a4 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -5,6 +5,7 @@ #include "Exceptions/TargetDescriptionParsingFailureException.hpp" #include "src/Logger/Logger.hpp" +#include "src/Helpers/Paths.hpp" using namespace Bloom::Targets::TargetDescription; using namespace Bloom::Exceptions; @@ -24,7 +25,7 @@ void TargetDescriptionFile::init(const QString& xmlFilePath) { auto xml = QDomDocument(); if (!xml.setContent(file.readAll())) { throw Exception("Failed to parse target description file - please report this error " - "to Bloom developers via https://bloom.oscillate.io/report-issue"); + "to Bloom developers via " + Paths::homeDomainName() + "/report-issue"); } this->init(xml);