aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/qbs-setup-toolchains
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-05-14 12:20:33 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-06-01 07:19:24 +0000
commit40746dae36452398649481fecad9cdc5f25cc80f (patch)
treec97c73364bdd5dfd3069b7a0b062fcee8ef38182 /src/app/qbs-setup-toolchains
parent78e19d1f234bb1ba9957c877e57d128f09d1459a (diff)
Add support for system-level settings
In addition to the traditional per-user settings, there is now also a system-wide settings file affecting all users. The file's platform- specific default location can be overridden at build time. The qbs-config tool can write these settings via the new --system option. [ChangeLog] Introduced the concept of system-level qbs settings Change-Id: Ie6f675a74e96ce1fa7b2dd0712f6106071e848a6 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/app/qbs-setup-toolchains')
-rw-r--r--src/app/qbs-setup-toolchains/commandlineparser.cpp11
-rw-r--r--src/app/qbs-setup-toolchains/commandlineparser.h4
-rw-r--r--src/app/qbs-setup-toolchains/main.cpp1
3 files changed, 12 insertions, 4 deletions
diff --git a/src/app/qbs-setup-toolchains/commandlineparser.cpp b/src/app/qbs-setup-toolchains/commandlineparser.cpp
index 00e605f3f..fd2e0214f 100644
--- a/src/app/qbs-setup-toolchains/commandlineparser.cpp
+++ b/src/app/qbs-setup-toolchains/commandlineparser.cpp
@@ -50,6 +50,7 @@ static QString helpOptionLong() { return QLatin1String("--help"); }
static QString detectOption() { return QLatin1String("--detect"); }
static QString typeOption() { return QLatin1String("--type"); }
static QString settingsDirOption() { return QLatin1String("--settings-dir"); }
+static QString systemOption() { return QLatin1String("--system"); }
void CommandLineParser::parse(const QStringList &commandLine)
{
@@ -75,6 +76,8 @@ void CommandLineParser::parse(const QStringList &commandLine)
m_helpRequested = true;
else if (arg == detectOption())
m_autoDetectionMode = true;
+ else if (arg == systemOption())
+ m_settingsScope = qbs::Settings::SystemScope;
else if (arg == typeOption())
assignOptionArgument(typeOption(), m_toolchainType);
else if (arg == settingsDirOption())
@@ -111,11 +114,11 @@ QString CommandLineParser::usageString() const
{
QString s = Tr::tr("This tool creates qbs profiles from toolchains.\n");
s += Tr::tr("Usage:\n");
- s += Tr::tr(" %1 [%2 <settings directory>] %3\n")
- .arg(m_command, settingsDirOption(), detectOption());
- s += Tr::tr(" %1 [%3 <settings directory>] [%2 <toolchain type>] "
+ s += Tr::tr(" %1 [%2 <settings directory>] [%4] %3\n")
+ .arg(m_command, settingsDirOption(), detectOption(), systemOption());
+ s += Tr::tr(" %1 [%3 <settings directory>] [%4] [%2 <toolchain type>] "
"<compiler path> <profile name>\n")
- .arg(m_command, typeOption(), settingsDirOption());
+ .arg(m_command, typeOption(), settingsDirOption(), systemOption());
s += Tr::tr(" %1 %2|%3\n").arg(m_command, helpOptionShort(), helpOptionLong());
s += Tr::tr("The first form tries to auto-detect all known toolchains, looking them up "
"via the PATH environment variable.\n");
diff --git a/src/app/qbs-setup-toolchains/commandlineparser.h b/src/app/qbs-setup-toolchains/commandlineparser.h
index 94a7a6283..cb0949bf1 100644
--- a/src/app/qbs-setup-toolchains/commandlineparser.h
+++ b/src/app/qbs-setup-toolchains/commandlineparser.h
@@ -39,6 +39,8 @@
#ifndef QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H
#define QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H
+#include <tools/settings.h>
+
#include <QtCore/qstringlist.h>
class CommandLineParser
@@ -53,6 +55,7 @@ public:
QString toolchainType() const { return m_toolchainType; }
QString profileName() const { return m_profileName; }
QString settingsDir() const { return m_settingsDir; }
+ qbs::Settings::Scope settingsScope() const { return m_settingsScope; }
QString usageString() const;
@@ -63,6 +66,7 @@ private:
bool m_helpRequested;
bool m_autoDetectionMode;
+ qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope;
QString m_compilerPath;
QString m_toolchainType;
QString m_profileName;
diff --git a/src/app/qbs-setup-toolchains/main.cpp b/src/app/qbs-setup-toolchains/main.cpp
index 546ae3adb..87a2a842a 100644
--- a/src/app/qbs-setup-toolchains/main.cpp
+++ b/src/app/qbs-setup-toolchains/main.cpp
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}
Settings settings(clParser.settingsDir());
+ settings.setScopeForWriting(clParser.settingsScope());
if (clParser.autoDetectionMode()) {
probe(&settings);
return EXIT_SUCCESS;