aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--doc/qbs.qdoc4
-rw-r--r--src/app/qbs/commandlinefrontend.cpp7
-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
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp15
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
9 files changed, 19 insertions, 25 deletions
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc
index 7a644a53d..bea692338 100644
--- a/doc/qbs.qdoc
+++ b/doc/qbs.qdoc
@@ -521,10 +521,10 @@
You can set these properties on the command line or by using a profile.
\code
- $ qbs # qbs.buildVariant:debug, profile:<default profile>
+ $ qbs # qbs.buildVariant:debug, profile:<default profile> (or profile:none, if no default profile exists)
$ qbs release # qbs.buildVariant:release, profile:<default profile>
- $ qbs profile:Maemo # qbs.buildVariant:debug, profile:Maemo
$ qbs debug release # builds two configurations of the project
+ $ qbs profile:none # all module properties have their default values
\endcode
To select files by build variant:
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index 10b19a382..7c3905d50 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -163,10 +163,9 @@ void CommandLineFrontend::start()
if (profileName.isEmpty())
profileName = m_settings->defaultProfile();
if (profileName.isEmpty()) {
- ErrorInfo error(Tr::tr("No profile specified and no default profile exists."));
- error.append(Tr::tr("To set a default profile, run "
- "'qbs config defaultProfile <profile name>'."));
- throw error;
+ qbsDebug() << Tr::tr("No profile specified and no default profile exists. "
+ "Using default property values.");
+ profileName = Profile::fallbackName();
}
const Preferences prefs(m_settings);
params.setSearchPaths(prefs.searchPaths(QDir::cleanPath(QCoreApplication::applicationDirPath()
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);
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 23fc51394..3e40e18ce 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -4016,21 +4016,6 @@ private:
const QString m_defaultProfile;
};
-void TestBlackbox::missingProfile()
-{
- Settings settings((QString()));
- TemporaryDefaultProfileRemover dpr(&settings);
- settings.sync();
- QVERIFY(settings.defaultProfile().isEmpty());
- QDir::setCurrent(testDataDir + "/project_filepath_check");
- QbsRunParameters params;
- params.arguments = QStringList("-f") << "project1.qbs";
- params.expectFailure = true;
- params.useProfile = false;
- QVERIFY(runQbs(params) != 0);
- QVERIFY(m_qbsStderr.contains("No profile"));
-}
-
void TestBlackbox::assembly()
{
Settings settings((QString()));
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 2468bdc7c..fed051edf 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -122,7 +122,6 @@ private slots:
void loadableModule();
void lrelease();
void missingDependency();
- void missingProfile();
void mixedBuildVariants();
void mocFlags();
void multipleChanges();