diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-01-28 15:45:12 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-01-29 16:08:46 +0100 |
commit | 93a7d0e2dc4be3b3efa40c1fd507d039e478156a (patch) | |
tree | 829e9e8e8922ec8adb12e2b9ca2b9d49bb17b5ea /src/app | |
parent | ecc425798f7a38f8c2c48b274dcd20965dfa792f (diff) |
Do not hardcode the settings source in the library.
This is inherently application-specific. Therefore, the library must not
instantiate the Settings class itself anywhere; instead, a pre-allocated
object comes in via the API.
Change-Id: I04a101d5535508b9e165123b4efe06d957c0d171
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/app')
25 files changed, 145 insertions, 66 deletions
diff --git a/src/app/config/config.pro b/src/app/config/config.pro index 6d6b60fa0..02bc2884d 100644 --- a/src/app/config/config.pro +++ b/src/app/config/config.pro @@ -16,4 +16,5 @@ include(../../lib/use.pri) HEADERS += \ configcommand.h \ configcommandexecutor.h \ - configcommandlineparser.h + configcommandlineparser.h \ + ../shared/qbssettings.h diff --git a/src/app/config/configcommandexecutor.cpp b/src/app/config/configcommandexecutor.cpp index ba03c2023..e74b497b6 100644 --- a/src/app/config/configcommandexecutor.cpp +++ b/src/app/config/configcommandexecutor.cpp @@ -31,6 +31,7 @@ #include "configcommand.h" #include <lib/tools/error.h> +#include <lib/tools/settings.h> #include <logging/consolelogger.h> #include <QDir> @@ -41,7 +42,7 @@ using namespace qbs; -ConfigCommandExecutor::ConfigCommandExecutor() +ConfigCommandExecutor::ConfigCommandExecutor(Settings *settings) : m_settings(settings) { } @@ -52,14 +53,14 @@ void ConfigCommandExecutor::execute(const ConfigCommand &command) printSettings(command); break; case ConfigCommand::CfgGet: - puts(qPrintable(m_settings.value(command.varNames.first()).toString())); + puts(qPrintable(m_settings->value(command.varNames.first()).toString())); break; case ConfigCommand::CfgSet: - m_settings.setValue(command.varNames.first(), command.varValue); + m_settings->setValue(command.varNames.first(), command.varValue); break; case ConfigCommand::CfgUnset: foreach (const QString &varName, command.varNames) - m_settings.remove(varName); + m_settings->remove(varName); break; case ConfigCommand::CfgExport: exportSettings(command.fileName); @@ -81,14 +82,14 @@ void ConfigCommandExecutor::execute(const ConfigCommand &command) void ConfigCommandExecutor::printSettings(const ConfigCommand &command) { if (command.varNames.isEmpty()) { - foreach (const QString &key, m_settings.allKeys()) + foreach (const QString &key, m_settings->allKeys()) printOneSetting(key); } else { foreach (const QString &parentKey, command.varNames) { - if (m_settings.value(parentKey).isValid()) { // Key is a leaf. + if (m_settings->value(parentKey).isValid()) { // Key is a leaf. printOneSetting(parentKey); } else { // Key is a node. - foreach (const QString &key, m_settings.allKeysWithPrefix(parentKey)) + foreach (const QString &key, m_settings->allKeysWithPrefix(parentKey)) printOneSetting(parentKey + QLatin1Char('.') + key); } } @@ -97,7 +98,7 @@ void ConfigCommandExecutor::printSettings(const ConfigCommand &command) void ConfigCommandExecutor::printOneSetting(const QString &key) { - printf("%s: %s\n", qPrintable(key), qPrintable(m_settings.value(key).toString())); + printf("%s: %s\n", qPrintable(key), qPrintable(m_settings->value(key).toString())); } void ConfigCommandExecutor::exportSettings(const QString &filename) @@ -109,8 +110,8 @@ void ConfigCommandExecutor::exportSettings(const QString &filename) } QTextStream stream(&file); stream.setCodec("UTF-8"); - foreach (const QString &key, m_settings.allKeys()) - stream << key << ": " << m_settings.value(key).toString() << endl; + foreach (const QString &key, m_settings->allKeys()) + stream << key << ": " << m_settings->value(key).toString() << endl; } void ConfigCommandExecutor::importSettings(const QString &filename) @@ -121,8 +122,8 @@ void ConfigCommandExecutor::importSettings(const QString &filename) .arg(QDir::toNativeSeparators(filename), file.errorString())); } // Remove all current settings - foreach (const QString &key, m_settings.allKeys()) - m_settings.remove(key); + foreach (const QString &key, m_settings->allKeys()) + m_settings->remove(key); QTextStream stream(&file); stream.setCodec("UTF-8"); @@ -132,7 +133,7 @@ void ConfigCommandExecutor::importSettings(const QString &filename) if (colon >= 0 && !line.startsWith("#")) { const QString key = line.left(colon).trimmed(); const QString value = line.mid(colon + 1).trimmed(); - m_settings.setValue(key, value); + m_settings->setValue(key, value); } } } diff --git a/src/app/config/configcommandexecutor.h b/src/app/config/configcommandexecutor.h index e85bf17c0..8f0aeefd9 100644 --- a/src/app/config/configcommandexecutor.h +++ b/src/app/config/configcommandexecutor.h @@ -29,17 +29,17 @@ #ifndef CONFIGCOMMANDEXECUTOR_H #define CONFIGCOMMANDEXECUTOR_H -#include <tools/settings.h> - #include <QCoreApplication> +namespace qbs { class Settings; } + class ConfigCommand; class ConfigCommandExecutor { Q_DECLARE_TR_FUNCTIONS(ConfigCommandExecutor) public: - ConfigCommandExecutor(); + ConfigCommandExecutor(qbs::Settings *settings); void execute(const ConfigCommand &command); @@ -49,7 +49,7 @@ private: void exportSettings(const QString &filename); void importSettings(const QString &filename); - qbs::Settings m_settings; + qbs::Settings *m_settings; }; #endif // CONFIGCOMMANDEXECUTOR_H diff --git a/src/app/config/configmain.cpp b/src/app/config/configmain.cpp index 919557541..1ed662b2f 100644 --- a/src/app/config/configmain.cpp +++ b/src/app/config/configmain.cpp @@ -29,6 +29,7 @@ #include "configcommandlineparser.h" #include "configcommandexecutor.h" +#include "../shared/qbssettings.h" #include <logging/consolelogger.h> #include <logging/translator.h> @@ -43,8 +44,9 @@ using namespace qbs; int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); + SettingsPtr settings = qbsSettings(); ConfigCommandLineParser parser; - ConsoleLogger cl; + ConsoleLogger cl(settings.data()); try { parser.parse(app.arguments().mid(1)); if (parser.helpRequested()) { @@ -53,7 +55,7 @@ int main(int argc, char *argv[]) parser.printUsage(); return EXIT_SUCCESS; } - ConfigCommandExecutor().execute(parser.command()); + ConfigCommandExecutor(settings.data()).execute(parser.command()); } catch (const Error &e) { qbsError() << e.toString(); parser.printUsage(); diff --git a/src/app/detect-toolchains/detect-toolchains.pro b/src/app/detect-toolchains/detect-toolchains.pro index b9aacd9a2..2c4e1c7af 100644 --- a/src/app/detect-toolchains/detect-toolchains.pro +++ b/src/app/detect-toolchains/detect-toolchains.pro @@ -7,7 +7,7 @@ DESTDIR = ../../../bin/ CONFIG += console CONFIG -= app_bundle -HEADERS = probe.h msvcprobe.h +HEADERS = probe.h msvcprobe.h ../shared/qbssettings.h SOURCES += main.cpp probe.cpp msvcprobe.cpp include(../../lib/use.pri) diff --git a/src/app/detect-toolchains/main.cpp b/src/app/detect-toolchains/main.cpp index eff363a56..1b19a15e1 100644 --- a/src/app/detect-toolchains/main.cpp +++ b/src/app/detect-toolchains/main.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include "probe.h" +#include "../shared/qbssettings.h" #include <logging/consolelogger.h> #include <logging/translator.h> @@ -44,7 +45,8 @@ int main(int argc, char **argv) { QCoreApplication app(argc, argv); - ConsoleLogger cl; + SettingsPtr settings = qbsSettings(); + ConsoleLogger cl(settings.data()); const QStringList args = app.arguments().mid(1); if (args.count() == 1 && (args.first() == QLatin1String("--help") || args.first() == QLatin1String("-h"))) { @@ -60,7 +62,7 @@ int main(int argc, char **argv) } try { - probe(); + probe(settings.data()); return EXIT_SUCCESS; } catch (const Error &error) { qbsError() << Tr::tr("Probing for toolchains failed: %1").arg(error.toString()); diff --git a/src/app/detect-toolchains/probe.cpp b/src/app/detect-toolchains/probe.cpp index 2105d6bad..d49d9270a 100644 --- a/src/app/detect-toolchains/probe.cpp +++ b/src/app/detect-toolchains/probe.cpp @@ -222,25 +222,24 @@ static void mingwProbe(Settings *settings, QList<Profile> &profiles) profiles << profile; } -int probe() +int probe(Settings *settings) { QList<Profile> profiles; - Settings settings; if (HostOsInfo::isWindowsHost()) { - msvcProbe(&settings, profiles); - mingwProbe(&settings, profiles); + msvcProbe(settings, profiles); + mingwProbe(settings, profiles); } else { - specific_probe(&settings, profiles, QLatin1String("gcc")); - specific_probe(&settings, profiles, QLatin1String("clang")); + specific_probe(settings, profiles, QLatin1String("gcc")); + specific_probe(settings, profiles, QLatin1String("clang")); } if (profiles.isEmpty()) { qbsWarning() << Tr::tr("Could not detect any toolchains. No profile created."); - } else if (profiles.count() == 1 && settings.defaultProfile().isEmpty()) { + } else if (profiles.count() == 1 && settings->defaultProfile().isEmpty()) { const QString profileName = profiles.first().name(); qbsInfo() << DontPrintLogLevel << Tr::tr("Making profile '%1' the default.") .arg(profileName); - settings.setValue(QLatin1String("defaultProfile"), profileName); + settings->setValue(QLatin1String("defaultProfile"), profileName); } return 0; } diff --git a/src/app/detect-toolchains/probe.h b/src/app/detect-toolchains/probe.h index ab2f42534..b985f7600 100644 --- a/src/app/detect-toolchains/probe.h +++ b/src/app/detect-toolchains/probe.h @@ -29,6 +29,8 @@ #ifndef QBS_PROBE_H #define QBS_PROBE_H -int probe(); +namespace qbs { class Settings; } + +int probe(qbs::Settings *settings); #endif // Header guard diff --git a/src/app/qbs-qmltypes/main.cpp b/src/app/qbs-qmltypes/main.cpp index 4791e832e..8da818a1c 100644 --- a/src/app/qbs-qmltypes/main.cpp +++ b/src/app/qbs-qmltypes/main.cpp @@ -26,6 +26,7 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#include "../shared/qbssettings.h" #include <language/scriptengine.h> #include <language/loader.h> @@ -43,7 +44,8 @@ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - ConsoleLogger cl; + SettingsPtr settings = qbsSettings(); + ConsoleLogger cl(settings.data()); const QStringList args = app.arguments().mid(1); if (args.count() == 1 && (args.first() == QLatin1String("--help") || args.first() == QLatin1String("-h"))) { @@ -60,7 +62,7 @@ int main(int argc, char *argv[]) } Internal::ScriptEngine engine; - QByteArray typeData = Internal::Loader(&engine).qmlTypeInfo(); + QByteArray typeData = Internal::Loader(&engine, settings.data()).qmlTypeInfo(); std::cout << typeData.constData(); diff --git a/src/app/qbs-qmltypes/qbs-qmltypes.pro b/src/app/qbs-qmltypes/qbs-qmltypes.pro index a01914235..c77c9aac4 100644 --- a/src/app/qbs-qmltypes/qbs-qmltypes.pro +++ b/src/app/qbs-qmltypes/qbs-qmltypes.pro @@ -11,6 +11,6 @@ TEMPLATE = app SOURCES += \ main.cpp \ -HEADERS += \ +HEADERS += ../shared/qbssettings.h include(../../lib/use.pri) diff --git a/src/app/qbs-setup-qt/main.cpp b/src/app/qbs-setup-qt/main.cpp index f7b9f80ef..60906c27b 100644 --- a/src/app/qbs-setup-qt/main.cpp +++ b/src/app/qbs-setup-qt/main.cpp @@ -26,6 +26,9 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#include "setupqt.h" + +#include "../shared/qbssettings.h" #include <logging/consolelogger.h> #include <logging/translator.h> @@ -35,8 +38,6 @@ #include <QtDebug> #include <QStringList> -#include "setupqt.h" - using namespace qbs; static void printWrongQMakePath(const QString &qmakePath) @@ -55,7 +56,8 @@ static void printUsage(const QString &appName) int main(int argc, char *argv[]) { QCoreApplication application(argc, argv); - ConsoleLogger cl; + SettingsPtr settings = qbsSettings(); + ConsoleLogger cl(settings.data()); QStringList args = application.arguments(); const QString appName = QFileInfo(args.takeFirst()).fileName(); @@ -82,7 +84,7 @@ int main(int argc, char *argv[]) if (!prefixPathParts.isEmpty()) profileName += QLatin1String("-") + prefixPathParts.last(); } - SetupQt::saveToQbsSettings(profileName, qtEnvironment); + SetupQt::saveToQbsSettings(profileName, qtEnvironment, settings.data()); } return EXIT_SUCCESS; } @@ -95,7 +97,7 @@ int main(int argc, char *argv[]) QtEnviroment qtEnvironment = SetupQt::fetchEnviroment(qmakePath); QString profileName = QLatin1String("qt-") + qtEnvironment.qtVersion; profileName.replace(".", "-"); - SetupQt::saveToQbsSettings(profileName , qtEnvironment); + SetupQt::saveToQbsSettings(profileName , qtEnvironment, settings.data()); return EXIT_SUCCESS; } if (args.count() == 2) { @@ -107,7 +109,7 @@ int main(int argc, char *argv[]) QtEnviroment qtEnvironment = SetupQt::fetchEnviroment(qmakePath); QString profileName = args.at(1); profileName.replace(".", "-"); - SetupQt::saveToQbsSettings(profileName , qtEnvironment); + SetupQt::saveToQbsSettings(profileName , qtEnvironment, settings.data()); return EXIT_SUCCESS; } printUsage(appName); diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.pro b/src/app/qbs-setup-qt/qbs-setup-qt.pro index 9d1069819..e4f39071c 100644 --- a/src/app/qbs-setup-qt/qbs-setup-qt.pro +++ b/src/app/qbs-setup-qt/qbs-setup-qt.pro @@ -13,6 +13,7 @@ SOURCES += \ setupqt.cpp HEADERS += \ - setupqt.h + setupqt.h \ + ../shared/qbssettings.h include(../../lib/use.pri) diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp index b1871a68b..ee7659efb 100644 --- a/src/app/qbs-setup-qt/setupqt.cpp +++ b/src/app/qbs-setup-qt/setupqt.cpp @@ -204,12 +204,13 @@ QtEnviroment SetupQt::fetchEnviroment(const QString &qmakePath) return qtEnvironment; } -void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnviroment &qtEnviroment) +void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnviroment &qtEnviroment, + Settings *settings) { QString msg = QCoreApplication::translate("SetupQt", "Creating profile '%0'.").arg(qtVersionName); printf("%s\n", qPrintable(msg)); - Profile profile(qtVersionName); + Profile profile(qtVersionName, settings); const QString settingsTemplate(QLatin1String("qt.core.%1")); profile.setValue(settingsTemplate.arg("binPath"), qtEnviroment.binaryPath); profile.setValue(settingsTemplate.arg("libPath"), qtEnviroment.libraryPath); diff --git a/src/app/qbs-setup-qt/setupqt.h b/src/app/qbs-setup-qt/setupqt.h index cd25756fc..53d014db8 100644 --- a/src/app/qbs-setup-qt/setupqt.h +++ b/src/app/qbs-setup-qt/setupqt.h @@ -34,6 +34,7 @@ #include <QCoreApplication> namespace qbs { +class Settings; class QtEnviroment { public: @@ -61,7 +62,8 @@ public: static bool isQMakePathValid(const QString &qmakePath); static QList<QtEnviroment> fetchEnviroments(); static QtEnviroment fetchEnviroment(const QString &qmakePath); - static void saveToQbsSettings(const QString &qtVersionName, const QtEnviroment & qtEnviroment); + static void saveToQbsSettings(const QString &qtVersionName, const QtEnviroment & qtEnviroment, + Settings *settings); static bool checkIfMoreThanOneQtWithTheSameVersion(const QString &qtVersion, const QList<QtEnviroment> &qtEnviroments); }; diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp index c20629b3d..451cc78fd 100644 --- a/src/app/qbs/commandlinefrontend.cpp +++ b/src/app/qbs/commandlinefrontend.cpp @@ -43,8 +43,9 @@ namespace qbs { -CommandLineFrontend::CommandLineFrontend(const CommandLineParser &parser, QObject *parent) - : QObject(parent), m_parser(parser), m_observer(0), m_canceled(false) +CommandLineFrontend::CommandLineFrontend(const CommandLineParser &parser, Settings *settings, + QObject *parent) + : QObject(parent), m_parser(parser), m_settings(settings), m_observer(0), m_canceled(false) { } @@ -89,7 +90,7 @@ void CommandLineFrontend::start() m_observer = new ConsoleProgressObserver; foreach (const QVariantMap &buildConfig, m_parser.buildConfigurations()) { SetupProjectJob * const job = Project::setupProject(m_parser.projectFilePath(), - buildConfig, QDir::currentPath(), this); + buildConfig, QDir::currentPath(), m_settings, this); connectJob(job); m_resolveJobs << job; } @@ -335,7 +336,7 @@ int CommandLineFrontend::runShell() const QList<ProductData> &products = productMap.begin().value(); Q_ASSERT(products.count() == 1); RunEnvironment runEnvironment = project.getRunEnvironment(products.first(), - QProcessEnvironment::systemEnvironment()); + QProcessEnvironment::systemEnvironment(), m_settings); return runEnvironment.runShell(); } @@ -381,7 +382,7 @@ int CommandLineFrontend::runTarget() .arg(productToRun.name())); } RunEnvironment runEnvironment = project.getRunEnvironment(productToRun, - QProcessEnvironment::systemEnvironment()); + QProcessEnvironment::systemEnvironment(), m_settings); return runEnvironment.runTarget(executableFilePath, m_parser.runArgs()); } catch (const Error &error) { qbsError() << error.toString(); diff --git a/src/app/qbs/commandlinefrontend.h b/src/app/qbs/commandlinefrontend.h index 259f9d1ba..7d1062c2c 100644 --- a/src/app/qbs/commandlinefrontend.h +++ b/src/app/qbs/commandlinefrontend.h @@ -42,12 +42,14 @@ class AbstractJob; class ConsoleProgressObserver; class Error; class ProcessResult; +class Settings; class CommandLineFrontend : public QObject { Q_OBJECT public: - explicit CommandLineFrontend(const CommandLineParser &parser, QObject *parent = 0); + explicit CommandLineFrontend(const CommandLineParser &parser, Settings *settings, + QObject *parent = 0); void cancel(); @@ -79,6 +81,7 @@ private: void checkForExactlyOneProduct(); const CommandLineParser &m_parser; + Settings * const m_settings; QList<AbstractJob *> m_resolveJobs; QList<AbstractJob *> m_buildJobs; QList<Project> m_projects; diff --git a/src/app/qbs/main.cpp b/src/app/qbs/main.cpp index ccacc5405..88d21be10 100644 --- a/src/app/qbs/main.cpp +++ b/src/app/qbs/main.cpp @@ -31,6 +31,7 @@ #include "commandlinefrontend.h" #include "qbstool.h" #include "parser/commandlineparser.h" +#include "../shared/qbssettings.h" #include <qbs.h> #include <logging/consolelogger.h> @@ -52,7 +53,8 @@ static bool tryToRunTool(const QStringList &arguments, int &exitCode) int main(int argc, char *argv[]) { - ConsoleLogger cl; + SettingsPtr settings = qbsSettings(); + ConsoleLogger cl(settings.data()); try { Application app(argc, argv); @@ -64,7 +66,7 @@ int main(int argc, char *argv[]) return toolExitCode; CommandLineParser parser; - if (!parser.parseCommandLine(arguments)) + if (!parser.parseCommandLine(arguments, settings.data())) return EXIT_FAILURE; if (parser.command() == HelpCommandType) { @@ -72,7 +74,7 @@ int main(int argc, char *argv[]) return 0; } - CommandLineFrontend clFrontend(parser); + CommandLineFrontend clFrontend(parser, settings.data()); app.setCommandLineFrontend(&clFrontend); QTimer::singleShot(0, &clFrontend, SLOT(start())); return app.exec(); diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp index b577a175c..278d484ca 100644 --- a/src/app/qbs/parser/commandlineparser.cpp +++ b/src/app/qbs/parser/commandlineparser.cpp @@ -42,7 +42,7 @@ #include <tools/fileinfo.h> #include <tools/hostosinfo.h> #include <tools/installoptions.h> -#include <tools/settings.h> +#include <tools/preferences.h> #include <QCoreApplication> #include <QDir> @@ -71,6 +71,7 @@ public: QString propertyName(const QString &aCommandLineName) const; QStringList commandLine; + Settings *settings; Command *command; QString projectFilePath; BuildOptions buildOptions; @@ -219,11 +220,12 @@ QList<QVariantMap> CommandLineParser::buildConfigurations() const return buildConfigs; } -bool CommandLineParser::parseCommandLine(const QStringList &args) +bool CommandLineParser::parseCommandLine(const QStringList &args, Settings *settings) { delete d; d = new CommandLineParserPrivate; d->commandLine = args; + d->settings = settings; try { d->doParse(); return true; @@ -389,8 +391,8 @@ void CommandLineParser::CommandLineParserPrivate::setupBuildOptions() } buildOptions.keepGoing = optionPool.keepGoingOption()->enabled(); const JobsOption * jobsOption = optionPool.jobsOption(); - if (jobsOption->jobCount() != 0) - buildOptions.maxJobCount = jobsOption->jobCount(); + buildOptions.maxJobCount = jobsOption->jobCount() > 0 + ? jobsOption->jobCount() : Preferences(settings).jobs(); } void CommandLineParser::CommandLineParserPrivate::setupProgress() diff --git a/src/app/qbs/parser/commandlineparser.h b/src/app/qbs/parser/commandlineparser.h index ba9dd58ce..d0dc9c8f3 100644 --- a/src/app/qbs/parser/commandlineparser.h +++ b/src/app/qbs/parser/commandlineparser.h @@ -37,6 +37,7 @@ namespace qbs { class BuildOptions; class InstallOptions; +class Settings; class CommandLineParser { @@ -45,7 +46,7 @@ public: CommandLineParser(); ~CommandLineParser(); - bool parseCommandLine(const QStringList &args); + bool parseCommandLine(const QStringList &args, Settings *settings); void printHelp() const; CommandType command() const; diff --git a/src/app/qbs/qbs.pro b/src/app/qbs/qbs.pro index 370f0d96e..a1a655091 100644 --- a/src/app/qbs/qbs.pro +++ b/src/app/qbs/qbs.pro @@ -22,7 +22,8 @@ HEADERS += \ status.h \ consoleprogressobserver.h \ commandlinefrontend.h \ - qbstool.h + qbstool.h \ + ../shared/qbssettings.h include(../../lib/use.pri) include(../../../qbs_version.pri) diff --git a/src/app/setupmaddeplatforms/main.cpp b/src/app/setupmaddeplatforms/main.cpp index e89df1125..8b4a04e0a 100644 --- a/src/app/setupmaddeplatforms/main.cpp +++ b/src/app/setupmaddeplatforms/main.cpp @@ -26,6 +26,7 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#include "../shared/qbssettings.h" #include "../shared/specialplatformssetup.h" #include <logging/consolelogger.h> @@ -44,6 +45,8 @@ namespace qbs { class MaddePlatformsSetup : public SpecialPlatformsSetup { +public: + MaddePlatformsSetup(Settings *settings); private: QString defaultBaseDirectory() const; QString platformTypeName() const { return QLatin1String("MADDE"); } @@ -56,6 +59,10 @@ private: }; +MaddePlatformsSetup::MaddePlatformsSetup(Settings *settings) : SpecialPlatformsSetup(settings) +{ +} + QString MaddePlatformsSetup::defaultBaseDirectory() const { if (HostOsInfo::isWindowsHost()) @@ -177,8 +184,9 @@ SpecialPlatformsSetup::PlatformInfo MaddePlatformsSetup::gatherMaddePlatformInfo int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - qbs::ConsoleLogger cl; - qbs::MaddePlatformsSetup setup; + SettingsPtr settings = qbsSettings(); + qbs::ConsoleLogger cl(settings.data()); + qbs::MaddePlatformsSetup setup(settings.data()); try { setup.setup(); } catch (const qbs::SpecialPlatformsSetup::Exception &ex) { diff --git a/src/app/setupmaddeplatforms/setupmaddeplatforms.pro b/src/app/setupmaddeplatforms/setupmaddeplatforms.pro index b6c3231c0..a09530a3a 100644 --- a/src/app/setupmaddeplatforms/setupmaddeplatforms.pro +++ b/src/app/setupmaddeplatforms/setupmaddeplatforms.pro @@ -9,6 +9,6 @@ DESTDIR = ../../../bin TEMPLATE = app SOURCES += main.cpp ../shared/specialplatformssetup.cpp -HEADERS += ../shared/specialplatformssetup.h +HEADERS += ../shared/specialplatformssetup.h ../shared/qbssettings.h include(../../lib/use.pri) diff --git a/src/app/shared/qbssettings.h b/src/app/shared/qbssettings.h new file mode 100644 index 000000000..37afb61b9 --- /dev/null +++ b/src/app/shared/qbssettings.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef QBS_QBS_SETTINGS +#define QBS_QBS_SETTINGS + +#include <tools/settings.h> + +#include <QSharedPointer> + +typedef QSharedPointer<qbs::Settings> SettingsPtr; + +inline SettingsPtr qbsSettings() +{ + return SettingsPtr(new qbs::Settings(QLatin1String("QtProject"), QLatin1String("qbs"))); +} + +#endif // Include guard diff --git a/src/app/shared/specialplatformssetup.cpp b/src/app/shared/specialplatformssetup.cpp index 409cbd5a9..88d50d103 100644 --- a/src/app/shared/specialplatformssetup.cpp +++ b/src/app/shared/specialplatformssetup.cpp @@ -42,7 +42,8 @@ namespace qbs { -SpecialPlatformsSetup::SpecialPlatformsSetup() : m_stdout(stdout), m_helpRequested(false) {} +SpecialPlatformsSetup::SpecialPlatformsSetup(Settings *settings) + : m_stdout(stdout), m_helpRequested(false), m_settings(settings) {} SpecialPlatformsSetup::~SpecialPlatformsSetup() {} void SpecialPlatformsSetup::setup() @@ -143,7 +144,7 @@ void SpecialPlatformsSetup::registerProfile(const PlatformInfo &platformInfo) { m_stdout << tr("Setting up profile '%1'...").arg(platformInfo.name) << endl; - Profile profile(platformInfo.name); + Profile profile(platformInfo.name, m_settings); profile.removeProfile(); profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc")); profile.setValue(QLatin1String("qbs.endianness"), QLatin1String("little-endian")); diff --git a/src/app/shared/specialplatformssetup.h b/src/app/shared/specialplatformssetup.h index 64e18199f..b26b903d0 100644 --- a/src/app/shared/specialplatformssetup.h +++ b/src/app/shared/specialplatformssetup.h @@ -35,6 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QProcessEnvironment) namespace qbs { +class Settings; class SpecialPlatformsSetup { @@ -65,7 +66,7 @@ public: QHash<QString, QString> environment; }; - SpecialPlatformsSetup(); + SpecialPlatformsSetup(Settings *settings); virtual ~SpecialPlatformsSetup(); void setup(); @@ -92,6 +93,7 @@ private: QString m_baseDir; QTextStream m_stdout; bool m_helpRequested; + Settings *m_settings; }; } // namespace qbs |