aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-01-28 15:45:12 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2013-01-29 16:08:46 +0100
commit93a7d0e2dc4be3b3efa40c1fd507d039e478156a (patch)
tree829e9e8e8922ec8adb12e2b9ca2b9d49bb17b5ea /src
parentecc425798f7a38f8c2c48b274dcd20965dfa792f (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')
-rw-r--r--src/app/config/config.pro3
-rw-r--r--src/app/config/configcommandexecutor.cpp27
-rw-r--r--src/app/config/configcommandexecutor.h8
-rw-r--r--src/app/config/configmain.cpp6
-rw-r--r--src/app/detect-toolchains/detect-toolchains.pro2
-rw-r--r--src/app/detect-toolchains/main.cpp6
-rw-r--r--src/app/detect-toolchains/probe.cpp15
-rw-r--r--src/app/detect-toolchains/probe.h4
-rw-r--r--src/app/qbs-qmltypes/main.cpp6
-rw-r--r--src/app/qbs-qmltypes/qbs-qmltypes.pro2
-rw-r--r--src/app/qbs-setup-qt/main.cpp14
-rw-r--r--src/app/qbs-setup-qt/qbs-setup-qt.pro3
-rw-r--r--src/app/qbs-setup-qt/setupqt.cpp5
-rw-r--r--src/app/qbs-setup-qt/setupqt.h4
-rw-r--r--src/app/qbs/commandlinefrontend.cpp11
-rw-r--r--src/app/qbs/commandlinefrontend.h5
-rw-r--r--src/app/qbs/main.cpp8
-rw-r--r--src/app/qbs/parser/commandlineparser.cpp10
-rw-r--r--src/app/qbs/parser/commandlineparser.h3
-rw-r--r--src/app/qbs/qbs.pro3
-rw-r--r--src/app/setupmaddeplatforms/main.cpp12
-rw-r--r--src/app/setupmaddeplatforms/setupmaddeplatforms.pro2
-rw-r--r--src/app/shared/qbssettings.h43
-rw-r--r--src/app/shared/specialplatformssetup.cpp5
-rw-r--r--src/app/shared/specialplatformssetup.h4
-rw-r--r--src/lib/api/internaljobs.cpp10
-rw-r--r--src/lib/api/internaljobs.h4
-rw-r--r--src/lib/api/jobs.cpp3
-rw-r--r--src/lib/api/jobs.h3
-rw-r--r--src/lib/api/project.cpp25
-rw-r--r--src/lib/api/project.h9
-rw-r--r--src/lib/api/runenvironment.cpp8
-rw-r--r--src/lib/api/runenvironment.h3
-rw-r--r--src/lib/buildgraph/buildproject.cpp4
-rw-r--r--src/lib/buildgraph/buildproject.h3
-rw-r--r--src/lib/language/loader.cpp15
-rw-r--r--src/lib/language/loader.h3
-rw-r--r--src/lib/logging/consolelogger.cpp4
-rw-r--r--src/lib/logging/consolelogger.h3
-rw-r--r--src/lib/tools/buildoptions.cpp4
-rw-r--r--src/lib/tools/preferences.cpp23
-rw-r--r--src/lib/tools/preferences.h4
-rw-r--r--src/lib/tools/profile.cpp15
-rw-r--r--src/lib/tools/profile.h3
-rw-r--r--src/lib/tools/settings.cpp13
-rw-r--r--src/lib/tools/settings.h2
46 files changed, 220 insertions, 152 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
diff --git a/src/lib/api/internaljobs.cpp b/src/lib/api/internaljobs.cpp
index 4a4dc2aeb..4c1d51c8f 100644
--- a/src/lib/api/internaljobs.cpp
+++ b/src/lib/api/internaljobs.cpp
@@ -103,8 +103,8 @@ void InternalJob::storeBuildGraph(const BuildProject *buildProject)
}
}
-InternalSetupProjectJob::InternalSetupProjectJob(QObject *parent)
- : InternalJob(parent), m_running(false)
+InternalSetupProjectJob::InternalSetupProjectJob(Settings *settings, QObject *parent)
+ : InternalJob(parent), m_running(false), m_settings(settings)
{
}
@@ -158,9 +158,9 @@ void InternalSetupProjectJob::execute()
{
RulesEvaluationContextPtr evalContext(new RulesEvaluationContext);
evalContext->setObserver(observer());
- const QStringList searchPaths = Preferences().searchPaths();
+ const QStringList searchPaths = Preferences(m_settings).searchPaths();
const BuildProjectLoader::LoadResult loadResult = BuildProjectLoader().load(m_projectFilePath,
- evalContext, m_buildRoot, m_buildConfig, searchPaths);
+ evalContext, m_buildRoot, m_buildConfig, searchPaths, m_settings);
ResolvedProjectPtr rProject;
if (!loadResult.discardLoadedProject)
@@ -171,7 +171,7 @@ void InternalSetupProjectJob::execute()
if (loadResult.changedResolvedProject) {
rProject = loadResult.changedResolvedProject;
} else {
- Loader loader(evalContext->engine());
+ Loader loader(evalContext->engine(), m_settings);
loader.setSearchPaths(searchPaths);
loader.setProgressObserver(observer());
rProject = loader.loadProject(m_projectFilePath, m_buildRoot, m_buildConfig);
diff --git a/src/lib/api/internaljobs.h b/src/lib/api/internaljobs.h
index 219a38a59..9c3edef18 100644
--- a/src/lib/api/internaljobs.h
+++ b/src/lib/api/internaljobs.h
@@ -43,6 +43,7 @@
namespace qbs {
class ProcessResult;
+class Settings;
namespace Internal {
class Executor;
@@ -79,7 +80,7 @@ class InternalSetupProjectJob : public InternalJob
{
Q_OBJECT
public:
- InternalSetupProjectJob(QObject *parent = 0);
+ InternalSetupProjectJob(Settings *settings, QObject *parent = 0);
~InternalSetupProjectJob();
void resolve(const QString &projectFilePath, const QString &buildRoot,
@@ -103,6 +104,7 @@ private:
QString m_buildRoot;
QVariantMap m_buildConfig;
BuildProjectPtr m_buildProject;
+ Settings * const m_settings;
};
diff --git a/src/lib/api/jobs.cpp b/src/lib/api/jobs.cpp
index 9272be7c1..acbceace0 100644
--- a/src/lib/api/jobs.cpp
+++ b/src/lib/api/jobs.cpp
@@ -170,7 +170,8 @@ void AbstractJob::handleFinished()
* \sa AbstractJob::taskStarted()
*/
-SetupProjectJob::SetupProjectJob(QObject *parent) : AbstractJob(new InternalSetupProjectJob, parent)
+SetupProjectJob::SetupProjectJob(Settings *settings, QObject *parent)
+ : AbstractJob(new InternalSetupProjectJob(settings), parent)
{
}
diff --git a/src/lib/api/jobs.h b/src/lib/api/jobs.h
index c16800818..a0532e76a 100644
--- a/src/lib/api/jobs.h
+++ b/src/lib/api/jobs.h
@@ -40,6 +40,7 @@
namespace qbs {
class BuildOptions;
class InstallOptions;
+class Settings;
namespace Internal {
class InternalJob;
class ProjectPrivate;
@@ -89,7 +90,7 @@ public:
Project project() const;
private:
- SetupProjectJob(QObject *parent);
+ SetupProjectJob(Settings *settings, QObject *parent);
void resolve(const QString &projectFilePath, const QString &buildRoot,
const QVariantMap &buildConfig);
diff --git a/src/lib/api/project.cpp b/src/lib/api/project.cpp
index ab38a2b11..0793ef587 100644
--- a/src/lib/api/project.cpp
+++ b/src/lib/api/project.cpp
@@ -59,14 +59,14 @@ namespace Internal {
static bool pluginsLoaded = false;
static QMutex pluginsLoadedMutex;
-static void loadPlugins()
+static void loadPlugins(Settings *settings)
{
QMutexLocker locker(&pluginsLoadedMutex);
if (pluginsLoaded)
return;
QStringList pluginPaths;
- const QStringList settingsPluginPaths = Preferences().pluginPaths();
+ const QStringList settingsPluginPaths = Preferences(settings).pluginPaths();
foreach (const QString &pluginPath, settingsPluginPaths) {
if (!FileInfo::exists(pluginPath)) {
qbsWarning() << Tr::tr("Plugin path '%1' does not exist.")
@@ -257,11 +257,12 @@ Project &Project::operator=(const Project &other)
* track the results of the operation.
*/
SetupProjectJob *Project::setupProject(const QString &projectFilePath,
- const QVariantMap &buildConfig, const QString &buildRoot, QObject *jobOwner)
+ const QVariantMap &buildConfig, const QString &buildRoot, Settings *settings,
+ QObject *jobOwner)
{
- loadPlugins();
- SetupProjectJob * const job = new SetupProjectJob(jobOwner);
- job->resolve(projectFilePath, buildRoot, expandBuildConfiguration(buildConfig));
+ loadPlugins(settings);
+ SetupProjectJob * const job = new SetupProjectJob(settings, jobOwner);
+ job->resolve(projectFilePath, buildRoot, expandBuildConfiguration(buildConfig, settings));
return job;
}
@@ -271,9 +272,9 @@ SetupProjectJob *Project::setupProject(const QString &projectFilePath,
* configuration
* \return The expanded build configuration
*/
-QVariantMap Project::expandBuildConfiguration(const QVariantMap &buildConfig)
+QVariantMap Project::expandBuildConfiguration(const QVariantMap &buildConfig,
+ Settings *settings)
{
- Settings settings;
QVariantMap expandedConfig = buildConfig;
// Fill in buildCfg in this order (making sure not to overwrite a key already set by a previous stage)
@@ -281,7 +282,7 @@ QVariantMap Project::expandBuildConfiguration(const QVariantMap &buildConfig)
// 2) Everything from the profile key
QString profileName = expandedConfig.value("qbs.profile").toString();
if (profileName.isNull()) {
- profileName = settings.defaultProfile();
+ profileName = settings->defaultProfile();
if (profileName.isNull()) {
throw Error(Tr::tr("No profile given and no default profile set.\n"
"Either set the configuration value 'profile' to a valid profile's name\n"
@@ -291,7 +292,7 @@ QVariantMap Project::expandBuildConfiguration(const QVariantMap &buildConfig)
}
// (2)
- const Profile profile(profileName, &settings);
+ const Profile profile(profileName, settings);
const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive);
if (profileKeys.isEmpty())
throw Error(Tr::tr("Unknown or empty profile '%1'.").arg(profileName));
@@ -373,11 +374,11 @@ QString Project::targetExecutable(const ProductData &product, const QString &_in
}
RunEnvironment Project::getRunEnvironment(const ProductData &product,
- const QProcessEnvironment &environment) const
+ const QProcessEnvironment &environment, Settings *settings) const
{
Q_ASSERT(product.isEnabled());
const Internal::ResolvedProductPtr resolvedProduct = d->internalProduct(product)->rProduct;
- return RunEnvironment(resolvedProduct, environment);
+ return RunEnvironment(resolvedProduct, environment, settings);
}
/*!
diff --git a/src/lib/api/project.h b/src/lib/api/project.h
index d73d5ddba..537d75a7e 100644
--- a/src/lib/api/project.h
+++ b/src/lib/api/project.h
@@ -49,6 +49,7 @@ class InstallOptions;
class ProductData;
class ProjectData;
class RunEnvironment;
+class Settings;
class SetupProjectJob;
namespace Internal {
@@ -62,8 +63,10 @@ class Project
friend uint qHash(const Project &p);
public:
static SetupProjectJob *setupProject(const QString &projectFilePath,
- const QVariantMap &buildConfig, const QString &buildRoot, QObject *jobOwner);
- static QVariantMap expandBuildConfiguration(const QVariantMap &buildConfig);
+ const QVariantMap &buildConfig, const QString &buildRoot, Settings *settings,
+ QObject *jobOwner);
+ static QVariantMap expandBuildConfiguration(const QVariantMap &buildConfig,
+ Settings *settings);
Project(const Project &other);
Project &operator=(const Project &other);
@@ -73,7 +76,7 @@ public:
QString targetExecutable(const ProductData &product,
const QString &installRoot = QString()) const;
RunEnvironment getRunEnvironment(const ProductData &product,
- const QProcessEnvironment &environment) const;
+ const QProcessEnvironment &environment, Settings *settings) const;
BuildJob *buildAllProducts(const BuildOptions &options, const QProcessEnvironment &env,
QObject *jobOwner = 0) const;
diff --git a/src/lib/api/runenvironment.cpp b/src/lib/api/runenvironment.cpp
index 0d04f3d5e..610a108d7 100644
--- a/src/lib/api/runenvironment.cpp
+++ b/src/lib/api/runenvironment.cpp
@@ -36,7 +36,7 @@
#include <logging/translator.h>
#include <tools/error.h>
#include <tools/hostosinfo.h>
-#include <tools/settings.h>
+#include <tools/preferences.h>
#include <QDir>
#include <QProcess>
@@ -55,14 +55,16 @@ public:
ScriptEngine engine;
ResolvedProductPtr resolvedProduct;
QProcessEnvironment environment;
+ Settings *settings;
};
RunEnvironment::RunEnvironment(const ResolvedProductPtr &product,
- const QProcessEnvironment &environment)
+ const QProcessEnvironment &environment, Settings *settings)
: d(new RunEnvironmentPrivate)
{
d->resolvedProduct = product;
d->environment = environment;
+ d->settings = settings;
}
RunEnvironment::~RunEnvironment()
@@ -91,7 +93,7 @@ int RunEnvironment::runShell()
const QString prompt = environment.value(QLatin1String("PROMPT"));
command += QLatin1String(" /k prompt [qbs] ") + prompt;
} else {
- command = Settings().value(QLatin1String("shell")).toString();
+ command = Preferences(d->settings).shell();
if (command.isEmpty())
command = environment.value(QLatin1String("SHELL"), QLatin1String("/bin/sh"));
diff --git a/src/lib/api/runenvironment.h b/src/lib/api/runenvironment.h
index e78d7db58..9ba8effd1 100644
--- a/src/lib/api/runenvironment.h
+++ b/src/lib/api/runenvironment.h
@@ -39,6 +39,7 @@ class QProcessEnvironment;
QT_END_NAMESPACE
namespace qbs {
+class Settings;
namespace Internal {
class ResolvedProduct;
@@ -56,7 +57,7 @@ public:
private:
RunEnvironment(const Internal::ResolvedProductPtr &product,
- const QProcessEnvironment &environment);
+ const QProcessEnvironment &environment, Settings *settings);
class RunEnvironmentPrivate;
RunEnvironmentPrivate * const d;
diff --git a/src/lib/buildgraph/buildproject.cpp b/src/lib/buildgraph/buildproject.cpp
index c0cda6f7d..5ba489e80 100644
--- a/src/lib/buildgraph/buildproject.cpp
+++ b/src/lib/buildgraph/buildproject.cpp
@@ -444,7 +444,7 @@ static bool isConfigCompatible(const QVariantMap &userCfg, const QVariantMap &pr
BuildProjectLoader::LoadResult BuildProjectLoader::load(const QString &projectFilePath,
const RulesEvaluationContextPtr &evalContext, const QString &buildRoot, const QVariantMap &cfg,
- const QStringList &loaderSearchPaths)
+ const QStringList &loaderSearchPaths, Settings *settings)
{
m_result = LoadResult();
m_evalContext = evalContext;
@@ -504,7 +504,7 @@ BuildProjectLoader::LoadResult BuildProjectLoader::load(const QString &projectFi
}
if (projectFileChanged || referencedProductRemoved || !changedProducts.isEmpty()) {
- Loader ldr(evalContext->engine());
+ Loader ldr(evalContext->engine(), settings);
ldr.setSearchPaths(loaderSearchPaths);
const ResolvedProjectPtr changedProject
= ldr.loadProject(project->resolvedProject()->location.fileName, buildRoot, cfg);
diff --git a/src/lib/buildgraph/buildproject.h b/src/lib/buildgraph/buildproject.h
index ba0b26dcc..f3fd4ff9e 100644
--- a/src/lib/buildgraph/buildproject.h
+++ b/src/lib/buildgraph/buildproject.h
@@ -43,6 +43,7 @@
#include <QVariantMap>
namespace qbs {
+class Settings;
namespace Internal {
class BuildProjectLoader;
class BuildProjectResolver;
@@ -133,7 +134,7 @@ public:
LoadResult load(const QString &projectFilePath, const RulesEvaluationContextPtr &evalContext,
const QString &buildRoot, const QVariantMap &cfg,
- const QStringList &loaderSearchPaths);
+ const QStringList &loaderSearchPaths, qbs::Settings *settings);
private:
void onProductRemoved(const BuildProductPtr &product);
diff --git a/src/lib/language/loader.cpp b/src/lib/language/loader.cpp
index 007b6384a..4ceff540a 100644
--- a/src/lib/language/loader.cpp
+++ b/src/lib/language/loader.cpp
@@ -77,7 +77,7 @@ namespace Internal {
class Loader::LoaderPrivate
{
public:
- LoaderPrivate(ScriptEngine *engine);
+ LoaderPrivate(ScriptEngine *engine, Settings *settings);
void loadProject(const QString &fileName);
ResolvedProjectPtr resolveProject(const QString &buildRoot,
@@ -172,13 +172,13 @@ public:
QStringList m_searchPaths;
QStringList m_moduleSearchPaths;
ScriptEngine * const m_engine;
+ Settings * const m_settings;
ScopesCachePtr m_scopesWithEvaluatedProperties;
QScriptValue m_jsFunction_getHostOS;
QScriptValue m_jsFunction_getHostDefaultArchitecture;
QScriptValue m_jsFunction_getenv;
QScriptValue m_jsFunction_configurationValue;
QScriptValue m_probeScriptScope;
- Settings m_settings;
ProjectFile::Ptr m_project;
QHash<QString, ProjectFile::Ptr> m_parsedFiles;
QHash<QString, PropertyDeclaration> m_dependsPropertyDeclarations;
@@ -249,7 +249,7 @@ static const uint hashName_Probe = qHash(name_Probe);
static const QLatin1String name_productPropertyScope("product property scope");
static const QLatin1String name_projectPropertyScope("project property scope");
-Loader::Loader(ScriptEngine *engine) : d(new LoaderPrivate(engine))
+Loader::Loader(ScriptEngine *engine, Settings *settings) : d(new LoaderPrivate(engine, settings))
{
}
@@ -356,8 +356,11 @@ QByteArray Loader::qmlTypeInfo()
return result;
}
-Loader::LoaderPrivate::LoaderPrivate(ScriptEngine *engine)
- : m_progressObserver(0), m_engine(engine), m_scopesWithEvaluatedProperties(new ScopesCache)
+Loader::LoaderPrivate::LoaderPrivate(ScriptEngine *engine, Settings *settings)
+ : m_progressObserver(0)
+ , m_engine(engine)
+ , m_settings(settings)
+ , m_scopesWithEvaluatedProperties(new ScopesCache)
{
QVariant v;
v.setValue(static_cast<void*>(this));
@@ -2275,7 +2278,7 @@ QScriptValue Loader::LoaderPrivate::js_configurationValue(QScriptContext *contex
QString("configurationValue expects 1 or 2 arguments"));
}
- const Settings &settings = get(engine)->m_settings;
+ const Settings &settings = *get(engine)->m_settings;
const bool defaultValueProvided = context->argumentCount() > 1;
const QString key = context->argument(0).toString();
QString defaultValue;
diff --git a/src/lib/language/loader.h b/src/lib/language/loader.h
index b9d4510a0..433815ab0 100644
--- a/src/lib/language/loader.h
+++ b/src/lib/language/loader.h
@@ -35,6 +35,7 @@
#include <QVariantMap>
namespace qbs {
+class Settings;
namespace Internal {
class ProgressObserver;
class ScriptEngine;
@@ -42,7 +43,7 @@ class ScriptEngine;
class Loader
{
public:
- Loader(ScriptEngine *engine);
+ Loader(ScriptEngine *engine, Settings *settings);
~Loader();
void setProgressObserver(ProgressObserver *observer);
diff --git a/src/lib/logging/consolelogger.cpp b/src/lib/logging/consolelogger.cpp
index bd0a30659..bd936aedd 100644
--- a/src/lib/logging/consolelogger.cpp
+++ b/src/lib/logging/consolelogger.cpp
@@ -77,9 +77,9 @@ void ConsolePrintLogSink::fprintfWrapper(TextColor color, FILE *file, const char
}
-ConsoleLogger::ConsoleLogger()
+ConsoleLogger::ConsoleLogger(Settings *settings)
{
- m_logSink.setColoredOutputEnabled(Preferences().useColoredOutput());
+ m_logSink.setColoredOutputEnabled(Preferences(settings).useColoredOutput());
ILogSink::setGlobalLogSink(&m_logSink);
}
diff --git a/src/lib/logging/consolelogger.h b/src/lib/logging/consolelogger.h
index b320fa176..15077f6f2 100644
--- a/src/lib/logging/consolelogger.h
+++ b/src/lib/logging/consolelogger.h
@@ -34,6 +34,7 @@
#include "logger.h"
namespace qbs {
+class Settings;
class ConsolePrintLogSink : public ILogSink
{
@@ -55,7 +56,7 @@ private:
class ConsoleLogger
{
public:
- ConsoleLogger();
+ ConsoleLogger(Settings *settings);
~ConsoleLogger();
private:
diff --git a/src/lib/tools/buildoptions.cpp b/src/lib/tools/buildoptions.cpp
index c77a291d7..935001c26 100644
--- a/src/lib/tools/buildoptions.cpp
+++ b/src/lib/tools/buildoptions.cpp
@@ -28,8 +28,6 @@
****************************************************************************/
#include "buildoptions.h"
-#include <tools/preferences.h>
-
namespace qbs {
/*!
@@ -44,7 +42,7 @@ namespace qbs {
BuildOptions::BuildOptions()
: dryRun(false)
, keepGoing(false)
- , maxJobCount(Preferences().jobs())
+ , maxJobCount(0)
{
}
diff --git a/src/lib/tools/preferences.cpp b/src/lib/tools/preferences.cpp
index c89a91183..62b0481ca 100644
--- a/src/lib/tools/preferences.cpp
+++ b/src/lib/tools/preferences.cpp
@@ -42,22 +42,10 @@ using namespace Internal;
* \brief The \c Preferences class gives access to all general qbs preferences.
*/
-Preferences::Preferences(Settings *settings)
+Preferences::Preferences(Settings *settings) : m_settings(settings)
{
- if (settings) {
- m_settings = settings;
- m_deleteSettings = false;
- } else {
- m_settings = new Settings;
- m_deleteSettings = true;
- }
}
-Preferences::~Preferences()
-{
- if (m_deleteSettings)
- delete m_settings;
-}
/*!
* \brief Returns true <=> colored output should be used for printing messages.
@@ -77,6 +65,15 @@ int Preferences::jobs() const
}
/*!
+ * \brief Returns the shell to use for the "qbs shell" command.
+ * This is only relevant for command-line frontends.
+ */
+QString Preferences::shell() const
+{
+ return getPreference(QLatin1String("shell")).toString();
+}
+
+/*!
* \brief Returns the list of paths where qbs looks for module definitions and such.
* The separator is ":" on UNIX-like systems and ";" on Windows.
*/
diff --git a/src/lib/tools/preferences.h b/src/lib/tools/preferences.h
index b4f71cf74..69808a997 100644
--- a/src/lib/tools/preferences.h
+++ b/src/lib/tools/preferences.h
@@ -38,11 +38,11 @@ class Settings;
class Preferences
{
public:
- explicit Preferences(Settings *settings = 0);
- ~Preferences();
+ explicit Preferences(Settings *settings);
bool useColoredOutput() const;
int jobs() const;
+ QString shell() const;
QStringList searchPaths() const;
QStringList pluginPaths() const;
diff --git a/src/lib/tools/profile.cpp b/src/lib/tools/profile.cpp
index e23b38e43..b0a6dbd0d 100644
--- a/src/lib/tools/profile.cpp
+++ b/src/lib/tools/profile.cpp
@@ -52,21 +52,8 @@ namespace qbs {
/*!
* \brief Creates an object giving access to the settings for profile \c name.
*/
-Profile::Profile(const QString &name, Settings *settings) : m_name(name)
-{
- if (settings) {
- m_settings = settings;
- m_deleteSettings = false;
- } else {
- m_settings = new Settings;
- m_deleteSettings = true;
- }
-}
-
-Profile::~Profile()
+Profile::Profile(const QString &name, Settings *settings) : m_name(name), m_settings(settings)
{
- if (m_deleteSettings)
- delete m_settings;
}
/*!
diff --git a/src/lib/tools/profile.h b/src/lib/tools/profile.h
index d667a219d..c06bf62ba 100644
--- a/src/lib/tools/profile.h
+++ b/src/lib/tools/profile.h
@@ -39,8 +39,7 @@ class Settings;
class Profile
{
public:
- explicit Profile(const QString &name, Settings *settings = 0);
- ~Profile();
+ explicit Profile(const QString &name, Settings *settings);
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
void setValue(const QString &key, const QVariant &value);
diff --git a/src/lib/tools/settings.cpp b/src/lib/tools/settings.cpp
index 920ae5762..3c8617c9e 100644
--- a/src/lib/tools/settings.cpp
+++ b/src/lib/tools/settings.cpp
@@ -46,19 +46,10 @@ static QSettings::Format format()
using namespace Internal;
-Settings::Settings()
- : m_settings(new QSettings(format(), QSettings::UserScope, QLatin1String("QtProject"),
- QLatin1String("qbs")))
+Settings::Settings(const QString &organization, const QString &application)
+ : m_settings(new QSettings(format(), QSettings::UserScope, organization, application))
{
m_settings->setFallbacksEnabled(false);
-
- // Fetch data from old Nokia settings, if necessary. TODO: Remove in 0.4.
- if (m_settings->allKeys().isEmpty()) {
- QSettings oldSettings(QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("qbs"));
- oldSettings.setFallbacksEnabled(false);
- foreach (const QString &key, oldSettings.allKeys())
- m_settings->setValue(key, oldSettings.value(key));
- }
}
Settings::~Settings()
diff --git a/src/lib/tools/settings.h b/src/lib/tools/settings.h
index 488ad1eb6..89032a6ab 100644
--- a/src/lib/tools/settings.h
+++ b/src/lib/tools/settings.h
@@ -42,7 +42,7 @@ namespace qbs {
class Settings
{
public:
- Settings();
+ Settings(const QString &organization, const QString &application);
~Settings();
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;