aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-03-09 17:26:10 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-03-31 08:04:22 +0000
commit24000d556fefdb3dcd4103d3d1679429434e6f58 (patch)
tree2bba620fe4ab8c94035700a02f4b8c2aa5be2573 /src/lib/corelib
parent03fa92611c6e3472ca9acd722e029fe5c5a18d79 (diff)
Allow running qbs without a profile
When no profile is given and no default one exists, simply use the modules' default values. The most relevant effect of this is that users can now build for the host platform by simply typing "qbs" without having done any manual setup, if there is a compiler in the PATH. [ChangeLog] It is no longer strictly required to provide a profile. Change-Id: Ifee09d2653dfbd4ea06c59248d78e376da2f217b Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/language/moduleloader.cpp2
-rw-r--r--src/lib/corelib/tools/profile.h2
-rw-r--r--src/lib/corelib/tools/settings.cpp5
-rw-r--r--src/lib/corelib/tools/settingsmodel.cpp6
-rw-r--r--src/lib/corelib/tools/setupprojectparameters.cpp2
5 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 1ec32338e..11e38518f 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -639,7 +639,7 @@ QList<Item *> ModuleLoader::multiplexProductItem(ProductContext *dummyContext, I
Settings settings(m_parameters.settingsDirectory());
for (int i = 0; i < profileNames.count(); ++i) {
Profile profile(profileNames.at(i), &settings);
- if (!profile.exists()) {
+ if (profile.name() != Profile::fallbackName() && !profile.exists()) {
throw ErrorInfo(Tr::tr("The profile '%1' does not exist.").arg(profile.name()),
productItem->location()); // TODO: profilesValue->location() is invalid, why?
}
diff --git a/src/lib/corelib/tools/profile.h b/src/lib/corelib/tools/profile.h
index 01663a09e..3f207e09e 100644
--- a/src/lib/corelib/tools/profile.h
+++ b/src/lib/corelib/tools/profile.h
@@ -73,6 +73,8 @@ public:
static QString cleanName(const QString &name);
+ static QString fallbackName() { return QLatin1String("none"); }
+
private:
static QString baseProfileKey();
void checkBaseProfileExistence(const Profile &baseProfile) const;
diff --git a/src/lib/corelib/tools/settings.cpp b/src/lib/corelib/tools/settings.cpp
index a8d51f099..f4649df0b 100644
--- a/src/lib/corelib/tools/settings.cpp
+++ b/src/lib/corelib/tools/settings.cpp
@@ -40,6 +40,7 @@
#include "settings.h"
#include "error.h"
+#include "profile.h"
#include "settingscreator.h"
#include <logging/translator.h>
@@ -97,6 +98,10 @@ QStringList Settings::allKeysWithPrefix(const QString &group) const
void Settings::setValue(const QString &key, const QVariant &value)
{
+ if (key.startsWith(QLatin1String("profiles.") + Profile::fallbackName())) {
+ throw ErrorInfo(Tr::tr("Invalid use of special profile name '%1'.")
+ .arg(Profile::fallbackName()));
+ }
m_settings->setValue(internalRepresentation(key), value);
}
diff --git a/src/lib/corelib/tools/settingsmodel.cpp b/src/lib/corelib/tools/settingsmodel.cpp
index 895e5e9e7..ba0713a05 100644
--- a/src/lib/corelib/tools/settingsmodel.cpp
+++ b/src/lib/corelib/tools/settingsmodel.cpp
@@ -39,6 +39,7 @@
#include "settingsmodel.h"
#include <tools/jsliterals.h>
+#include <tools/profile.h>
#include <tools/qttools.h>
#include <tools/settings.h>
@@ -279,7 +280,10 @@ bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int
const QString valueString = value.toString();
QString *toChange = 0;
if (index.column() == keyColumn() && !valueString.isEmpty()
- && !node->parent->hasDirectChildWithName(valueString)) {
+ && !node->parent->hasDirectChildWithName(valueString)
+ && !(node->parent->parent == &d->rootNode
+ && node->parent->name == QLatin1String("profiles")
+ && valueString == Profile::fallbackName())) {
toChange = &node->name;
} else if (index.column() == valueColumn() && valueString != node->value) {
toChange = &node->value;
diff --git a/src/lib/corelib/tools/setupprojectparameters.cpp b/src/lib/corelib/tools/setupprojectparameters.cpp
index f12ea9de0..5eb4d18eb 100644
--- a/src/lib/corelib/tools/setupprojectparameters.cpp
+++ b/src/lib/corelib/tools/setupprojectparameters.cpp
@@ -340,7 +340,7 @@ static QVariantMap expandedBuildConfigurationInternal(const QString &settingsBas
QVariantMap buildConfig;
// (1) Values from profile, if given.
- if (!profileName.isEmpty()) {
+ if (!profileName.isEmpty() && profileName != Profile::fallbackName()) {
ErrorInfo err;
const Profile profile(profileName, &settings);
const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive, &err);